Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APK Build fail with errors "Superclass has no method named 'inheritFromElement'" #3

Open
emanuelb opened this issue Mar 7, 2021 · 5 comments

Comments

@emanuelb
Copy link

emanuelb commented Mar 7, 2021

Running flutter build apk result in errors:

Building without sound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety

../../sdk/flutter/.pub-cache/hosted/pub.dartlang.org/provider-3.2.0/lib/src/delegate_widget.dart:194:18: Error: Superclass has no method named 'inheritFromElement'.
    return super.inheritFromElement(ancestor, aspect: aspect);          
                 ^^^^^^^^^^^^^^^^^^                                     
../../sdk/flutter/.pub-cache/hosted/pub.dartlang.org/provider-3.2.0/lib/src/provider.dart:259:19: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.
 - 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../sdk/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'.
        ? context.inheritFromWidgetOfExactType(type) as InheritedProvider<T>
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^                          
../../sdk/flutter/.pub-cache/hosted/pub.dartlang.org/provider-3.2.0/lib/src/provider.dart:260:19: Error: The method 'ancestorInheritedElementForWidgetOfExactType' isn't defined for the class 'BuildContext'.
 - 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../sdk/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'ancestorInheritedElementForWidgetOfExactType'.
        : context.ancestorInheritedElementForWidgetOfExactType(type)?.widget
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^          
../../sdk/flutter/.pub-cache/hosted/pub.dartlang.org/modal_bottom_sheet-0.2.0/lib/src/material_with_modal_page_route.dart:21:16: Error: Getter not found: 'opaque'.
        assert(opaque),                                                 
               ^^^^^^                                                   
../../sdk/flutter/.pub-cache/hosted/pub.dartlang.org/modal_bottom_sheet-0.2.0/lib/src/bottom_sheets/cupertino_bottom_sheet.dart:339:46: Error: No named parameter with the name 'shadowThemeOnly'.
    final isCupertinoApp = Theme.of(context, shadowThemeOnly: true) == null;
                                             ^^^^^^^^^^^^^^^            
../../sdk/flutter/packages/flutter/lib/src/material/theme.dart:107:20: Context: Found this candidate, but the arguments don't match.
  static ThemeData of(BuildContext context) {                           
                   ^^                                                   
../../sdk/flutter/.pub-cache/hosted/pub.dartlang.org/modal_bottom_sheet-0.2.0/lib/src/bottom_sheets/material_bottom_sheet.dart:40:32: Error: No named parameter with the name 'shadowThemeOnly'.
      theme: Theme.of(context, shadowThemeOnly: true),                  
                               ^^^^^^^^^^^^^^^                          
../../sdk/flutter/packages/flutter/lib/src/material/theme.dart:107:20: Context: Found this candidate, but the arguments don't match.
  static ThemeData of(BuildContext context) {                           
                   ^^                                                   
                                                                        
                                                                        
FAILURE: Build failed with an exception.                                
                                                                        
* Where:                                                                
Script '/app/sdk/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 991
                                                                        
* What went wrong:                                                      
Execution failed for task ':app:compileFlutterBuildRelease'.            
> Process 'command '/app/sdk/flutter/bin/flutter'' finished with non-zero exit value 1

used the following Containerfile which was added after cloning this repo:

FROM frolvlad/alpine-glibc

RUN set -ex; \
    apk update; \
    apk add --no-cache \
        gradle \
        bash curl file git zip; \
    adduser -D appuser;

USER appuser

COPY --chown=appuser:root . /app/paymint/

ENV ANDROID_SDK_ROOT="/app/sdk" \
    ANDROID_HOME="/app/sdk"

RUN set -ex; \
    ANDROID_SDK_LICENSES="${ANDROID_SDK_ROOT}/licenses"; \
    mkdir -p "${ANDROID_SDK_LICENSES}"; \
    printf "\n24333f8a63b6825ea9c5514f83c2829b004d1fee" > "${ANDROID_SDK_LICENSES}/android-sdk-license"; \
    cd /app/sdk/; \
    wget https://storage.googleapis.com/flutter_infra/releases/stable/linux/flutter_linux_2.0.1-stable.tar.xz; \
    tar xf flutter_linux_2.0.1-stable.tar.xz; \
    rm flutter_linux_2.0.1-stable.tar.xz
    
WORKDIR /app/paymint/
RUN /app/sdk/flutter/bin/flutter build apk

Run with podman build --rm -t paymint_build_apk . and the errors as shown above happen.

@mejdi14
Copy link

mejdi14 commented Mar 19, 2021

some packages must be updated for the null safety support
for example start by upgrading the modal_bottom_sheet package version to 2.0.0 and provider package to 5.0.0

@emanuelb
Copy link
Author

Can you provide PR and merge the changes required to build the app using modern flutter version?

I tried using older flutter version 1.22.1 instead which was released before the latest commit, and the build worked, here the modified Containerfile (with keystore generation)

FROM frolvlad/alpine-glibc

RUN set -ex; \
    apk update; \
    apk add --no-cache \
        gradle \
        bash curl file git zip; \
    adduser -D appuser;

USER appuser

COPY --chown=appuser:root . /app/paymint/

ENV ANDROID_SDK_ROOT="/app/sdk" \
    ANDROID_HOME="/app/sdk"

RUN set -ex; \
    ANDROID_SDK_LICENSES="${ANDROID_SDK_ROOT}/licenses"; \
    mkdir -p "${ANDROID_SDK_LICENSES}"; \
    printf "\n24333f8a63b6825ea9c5514f83c2829b004d1fee" > "${ANDROID_SDK_LICENSES}/android-sdk-license"; \
    cd /app/sdk/; \
    wget https://storage.googleapis.com/flutter_infra/releases/stable/linux/flutter_linux_1.22.1-stable.tar.xz; \
    tar xf flutter_linux_1.22.1-stable.tar.xz; \
    rm flutter_linux_1.22.1-stable.tar.xz; \
    cd /app/paymint/android/; \
    keytool -genkey -alias paymint_alias -keystore app/paymint.pfx -storetype PKCS12 -keyalg RSA -keysize 4096 -storepass paymint_alias -keypass paymint_alias -validity 10000 -dname CN=IL; \
    printf "\nstoreFile=paymint.pfx\nstorePassword=paymint_alias\nkeyPassword=paymint_alias\nkeyAlias=paymint_alias\n" >> key.properties;
    
WORKDIR /app/paymint/
RUN /app/sdk/flutter/bin/flutter build apk
podman build --rm -t paymint_build_apk .
podman run --rm --name paymint_built_apk -ti paymint_build_apk
podman cp paymint_built_apk:/app/paymint/build/app/outputs/flutter-apk/app-release.apk ~/paymint_rebuild.apk

@HusseinKamal
Copy link

Is there any solution for this issue please?

@emanuelb
Copy link
Author

Is there any solution for this issue please?

Building the app with flutter 1.22.1 works, building with newer flutter versions may fail, the solution for this might be to upgrading the packages in pubspec.yaml as explained in: #3 (comment)

for example start by upgrading the modal_bottom_sheet package version to 2.0.0 and provider package to 5.0.0

@Thomalexa
Copy link

Is there any solution for this issue please?

Building the app with flutter 1.22.1 works, building with newer flutter versions may fail, the solution for this might be to upgrading the packages in pubspec.yaml as explained in: #3 (comment)

for example start by upgrading the modal_bottom_sheet package version to 2.0.0 and provider package to 5.0.0

Forgive me for asking, I'm a new developer. How do I get an older version of flutter, like 1.22.1? I have older apps and it seems the new version of flutter breaks them and they won't compile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants