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

Release build fails to install with signed apk and debug build works with flutter for android #37935

Closed
muthufmass opened this issue Aug 9, 2019 · 9 comments
Labels
platform-android Android applications specifically tool Affects the "flutter" command-line tool. See also t: labels.

Comments

@muthufmass
Copy link

muthufmass commented Aug 9, 2019

Android sdk - 29.0.2
Android Studio - 3.4.2
Flutter - 1.8.1 Dev Channel

Steps to reproduce:

flutter create --org com.example -i swift -a kotlin --description 'sampleapp' sampleapp

Created a keystore file suing keytool for release build with alias and password
created key.properties file

flutter build apk --target-platform android-arm64

added these to app -> build.gradle

`
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

signingConfigs {
    release {
        keyAlias keystoreProperties['keyAlias']
        keyPassword keystoreProperties['keyPassword']
        storeFile file(keystoreProperties['storeFile'])
        storePassword keystoreProperties['storePassword']
    }
}

buildTypes {
    release {
        profile {
            matchingFallbacks = ['debug', 'release']
        }
        signingConfig signingConfigs.release
        useProguard true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}`

added progaurd-rules.pro
## Flutter wrapper -keep class io.flutter.app.** { *; } -keep class io.flutter.plugin.** { *; } -keep class io.flutter.util.** { *; } -keep class io.flutter.view.** { *; } -keep class io.flutter.** { *; } -keep class io.flutter.plugins.** { *; } -keep class com.google.**{*;} -keepclassmembers class * implements java.io.Serializable { *; } #or -keep class com.baseflow.permissionhandler.** { *; }

Ran the build for release, it comes up with an apk and following error on opening in an emulator or actual device.

Screen Shot 2019-08-09 at 8 29 12 PM

Flutter doctor -v

`[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.3, Build version 10G8
• CocoaPods version 1.7.3

[✓] Android Studio (version 3.4)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 38.2.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[✓] VS Code (version 1.36.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.3.0

[✓] Connected device (3 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28)
(emulator)`

@muthufmass
Copy link
Author

muthufmass commented Aug 9, 2019

Significant difference between prod and dev version of apk on size. Tried all the steps of #18494, unable to build a release version that runs. Build happens super fast and file comes less than 11 mb with release, while with debug apk it comes around 40mb+. Debug apk works, while prod release signed apk doesnt install even.

@tvolkert tvolkert added platform-android Android applications specifically tool Affects the "flutter" command-line tool. See also t: labels. labels Aug 9, 2019
@tvolkert
Copy link
Contributor

tvolkert commented Aug 9, 2019

Thanks for the bug report!

Flutter doesn't support deploying release builds to emulators, so what physical device are you trying to deploy to in release mode? (your doctor output only shows a connected emulator)

@tvolkert
Copy link
Contributor

tvolkert commented Aug 9, 2019

/cc @blasten

@muthufmass
Copy link
Author

I connect my one-plus android phone and tried running
flutter run --release -d deviceId

It works now with 1.8.1 dev channel on actual device alone, with 1.7.8 +hotfix it fails. If I do a pull latest on the flutter folder, a merge conflict also comes up.

Can we trust this and generate an .aab and release to playstore, will it work ?

If we take a build opening only android folder in android studio of flutter project like a standard android project, and generate signed apk. It doesn't open up on emulator or actual device. However standard kotlin android project release build works both on emulator & actual device.

When can we expect similar experience with flutter projects ?

@muthufmass
Copy link
Author

Not sure what magic happened now from yest to today, builds are working on actual device, if i use flutter commands. May be my bad I should have tried on a device first. I was behind emulator for release builds to be tested, since used with kotlin projects.

Thanks for letting me know that emulator it wont work with release build. will it be fixed in future ?

Now the release apk that comes up through --release is about 11.9 mb. why different sizes building from android studio directly through android folder(10.9 mb), or vscode with flutter build apk (18.3 mb) or vscode with flutter run --release (11.9 mb). All have different sizes.

Are these flutter core libraries like flutterlib.so etc are part of all android devices now ? So that It picks that to render the app ?

@blasten
Copy link

blasten commented Aug 10, 2019

When you build the APK for release, you need an emulator that can run code compiled for arm32 or arm64. However, if your computer has x64 or x86 CPU, Android Studio suggests an emulator that is compatible with your computer architecture, which might not allow you to run the release APK.

@muthufmass
Copy link
Author

closing the issue, as I got confirmation that release versions wont work on emulator

@rayliverified
Copy link

MaxthonSnap20191114091433
Is this documented somewhere? I ran into this issue when testing Flutter via Firebase Testlabs and started looking at solutions from 2018 that were not helpful.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform-android Android applications specifically tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

No branches or pull requests

4 participants