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

Support APKs with 32-bit and 64-bit binaries within them #18494

Closed
peace2knowledge opened this issue Jun 15, 2018 · 286 comments
Closed

Support APKs with 32-bit and 64-bit binaries within them #18494

peace2knowledge opened this issue Jun 15, 2018 · 286 comments
Assignees
Labels
c: new feature Nothing broken; request for a new capability customer: crowd Affects or could affect many people, though not necessarily a specific customer. platform-android Android applications specifically t: gradle "flutter build" and "flutter run" on Android tool Affects the "flutter" command-line tool. See also t: labels. waiting for PR to land (fixed) A fix is in flight
Milestone

Comments

@peace2knowledge
Copy link

peace2knowledge commented Jun 15, 2018

using flutter build apk --release --flavor pro make apk file , but arm64-v8a do not include libflutter.so file.so app launch fail.
when I add --target-platform=android-arm64 : flutter build apk --release --flavor pro --target-platform=android-arm64,apk file include so flie. But app launch fail on 32 bit cpu.
what can i do, apk file can run on 64 and 32 cpu @mravn-google

/System.err(15263): java.lang.UnsatisfiedLinkError: Couldn't load flutter from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.jianzhibao.ka.enterprise-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.jianzhibao.ka.enterprise-1, /vendor/lib, /system/lib]]]: findLibrary returned null

I create new project, debug or releas, work well. diffrece from new project from my project is that i add thrid party so file

image

where is the problem ?

@swavkulinski
Copy link

AFAIK, currently, Flutter will only add libflutter.so to one selected platform folder in the release APK. The workaround which worked for me was to force build.gradle to do 32bit only (excluding all 64bit libraries + Intel)

release {
        
    ...
            ndk{
                abiFilters "armeabi-v7a"
            }
}

@zoechi
Copy link
Contributor

zoechi commented Jun 22, 2018

cc @Hixie

@jeanpaulcozzatti
Copy link

@swavkulinski how would you release the to apks to the playstore?

danielfoehrKn added a commit to danielfoehrKn/MediathekViewMobile that referenced this issue Jul 4, 2018
…ter recognized x64 ABIS and build the whole project trageting that CPU Architecture. However that caused startup failure on non-x64 CPUS

--> only included the armeabi-v7 instead of all types

- Also APK size shrinked to 50%
See:
flutter/flutter#18494
@kevinvandenbreemen
Copy link

kevinvandenbreemen commented Jul 24, 2018

Similar to #18939

@qbsho
Copy link

qbsho commented Jul 26, 2018

Have the same problem - but flutter.so not included in "armeabi-v7a folder.
Has only third party libraries for x86 and armeabi-v7a - but no arm64.
Would like to build flutter only for "armeabi-v7a with
ndk{
abiFilters "armeabi-v7a" // also not work"armeabi", "x86",
}
and set as target-platform as @mravn-google suggest to android-arm.

APK without specify arch and not include libraries
screen shot 2018-07-26 at 21 06 53

APK with libraries and no arm spec
screen shot 2018-07-26 at 21 10 30

APK with specify arch and include libraries
screen shot 2018-07-26 at 21 12 58

Any suggestion how to debug further steps?

@peasfarmer

This comment has been minimized.

@gurleensethi
Copy link

I have the same problem, building for 32-bit will exclude 64-bit devices, it runs on them though. Building for 64 by specifying --target-platform android-arm64 works on 64-bit devices, but crashes on 32-bit devices. Also Google will be restricting upload of apks to be 64-bit in 2019.

Flutter Team, please resolve this basic issue!

@dieegov

This comment has been minimized.

@zoechi zoechi added tool Affects the "flutter" command-line tool. See also t: labels. t: gradle "flutter build" and "flutter run" on Android labels Aug 15, 2018
@bdytx5
Copy link

bdytx5 commented Aug 30, 2018

So am I wrong by saying that flutter can only support release apk’s for either 32 or 64 bit, but not both?

@jeanpaulcozzatti

This comment has been minimized.

@bdytx5

This comment has been minimized.

@lance-blo
Copy link

I am also having the same issue.

In all of my dependencies, I isolated at least one package causing the issue, I filled a bug report accordingly: azihsoyn/flutter_mlkit#36

To isolate the problem, for each of my dependency / plugin:

  1. Create an empty flutter project

  2. Replace main.dart with

the package example code (ex: https://pub.dartlang.org/packages/flutter_html_view#-example-tab-)

  1. Update pubspec.yaml accordingly

  2. run

$ flutter build apk

It turned out that the one creating was flutter_mlkit.

I want to be able to target both 32 & 64 architectures.

@cortexuvula

This comment has been minimized.

@OnlyMyRailgun

This comment has been minimized.

@lianjianjie
Copy link

lots of third SDK not working, i think it's urgent

@philipgiuliani
Copy link

I can reproduce this when adding Mapbox to the android application.

@John-jin
Copy link

I have the same problem too.I use baiduMap in my Project,bebug model is ok,release crash.
user flutter build apk --release --target-platform=android-arm64 in my phone is ok,but 32 bit phone will crash.Flutter Team,please resolve this issue as soon as possible.

@JackJonson
Copy link

Similar to https://github.com/azihsoyn/flutter_mlkit/issues/36 , it works for me , the apk can run in both 32bit and 64bit phone. @peace2knowledge

@krmao
Copy link

krmao commented Nov 2, 2018

this should be very important problem for release apk

@jeffreyyoung
Copy link

is there a work around for this issue?

@zephyrluo
Copy link

zephyrluo commented Nov 5, 2018

  1. extract lib/armeabi-v7a/libflutter.so from $<FLUTTER>/bin/cache/artifacts/engine/android-arm-release/flutter.jar
  2. copy file armeabi-v7a/libflutter.so into $<project>/android/jniLibs/armeabi-v7a/
  3. modify $<project>/android/app/build.gradle as below:
android {
...
    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
            ndk {
                abiFilters "arm"
            }
        }
        debug {
            ndk {
                abiFilters "arm"
            }
        }
}
    }

@INRIX-joel-winarske
Copy link

INRIX-joel-winarske commented Nov 28, 2018

For NDK, the 64-bit toolchain requires minSdkVersion >= 21.

This unblocked me (with proper minSdkVersion set):

minSdkVersion=16

flutter build apk --release --target-platform=android-arm
flutter run --release --target-platform=android-arm

minSdkVersion=21

flutter build apk --release --target-platform=android-arm64
flutter run --release --target-platform=android-arm64

@RockCoder7
Copy link

Delete all abiFilters, it works for me.

@nohli
Copy link
Contributor

nohli commented Jul 10, 2019

Anyone else got a mail from Google today, saying

"Action required: Update your apps to be 64-bit compliant by August 1, 2019"

although already publishing both 32bit and 64bit versions?

It says

By August 1, 2019, all apps that use native code must provide a 64-bit version in order to publish an update. As of the sending of this email, at least one of your apps* does not yet meet the requirement

*Note: This list of apps reflects Google’s best estimate as of the sending of this email. (...)

I guess, Google's "best estimate" is not correct?

@JaeyoungChu
Copy link

Thanks for Flutter team. I upgrade Flutter and build on stable channel and the warning is gone.
hope to not have a bug with testers but so far I did not find any bugs yet with real device!

@rsin46
Copy link

rsin46 commented Jul 11, 2019

Thanks Team Flutter, upgrading Flutter with the hotfix fixes this issue when building .aab

@christiangarciareyes
Copy link

Thanks to the flutter team for this achievement. Now to continue programmed!

@abdullayev007
Copy link

@angel1st I am also having issues on some Samsung devices.

#36128

@angel1st
Copy link

@abdullayev007 - thanks! I would suggest you to take a look at #35838, it might be somehow related.

@surveshoeb
Copy link

I did everything as in the instructions but it does not install on 32 bit

Any screenshot/log showing that the installation of 32-bit apk on the 32-bit device was not successful, and what device model is that?
IMG-20190710-WA0000

The device is Samsung M10

@ghost
Copy link

ghost commented Jul 15, 2019

@tvolkert Please give me any solution for fixing following issue:
#36063

Thanks

@muthufmass
Copy link

I tried the latest version of flutter from dev channel - v1.8.4. I created a fresh project too - vanilla flutter project and tried building a release signed version out of it. It builds and app size is just 10.4 mb. But tried all above steps in this trail, nothing helping out. Can some one give a clear set of sequence of steps to take a build that we can push to playstore with aab or apk with emulator and local device from flutter. Its been more than a week, we have project built on flutter not moving to prod on android, but we are able to publish to appstore on ios. Some help will be great.

`[✓] Flutter (Channel dev, v1.8.4, on Mac OS X 10.14.5, locale en-US)
• Flutter version 1.8.4 at /Users/muthu/muthu/devapps/flutter
• Framework revision 954714c (7 days ago), 2019-08-02 10:10:39 -0700
• Engine revision 2636822
• Dart version 2.5.0 (build 2.5.0-dev.1.0 bd049f5b53)

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
• Android SDK at ../Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.1
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
✗ Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit https://flutter.dev/setup/#android-setup
for detailed instructions.

[✓] 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)`

@tvolkert
Copy link
Contributor

tvolkert commented Aug 9, 2019

@muthufmass, please file a new issue with details of what's not working and how to reproduce the failure. Thanks!

@truongsinh
Copy link
Contributor

Can some one give a clear set of sequence of steps to take a build that we can push to playstore

https://flutter.dev/docs/deployment/android

@muthufmass
Copy link

Can some one give a clear set of sequence of steps to take a build that we can push to playstore

https://flutter.dev/docs/deployment/android

These steps are already followed, its not working on the prod release build. debug build works! I clearly find a difference, in debug build, the .so files of flutter are present, but not with the release version. Those are ones, creating problem to install the apk to emulator or to devices with signed apk.

@muthufmass
Copy link

@muthufmass, please file a new issue with details of what's not working and how to reproduce the failure. Thanks!

I hope I have shared cleared steps above. Fresh app creation using flutter create - vanilla code with latest flutter sdk. Unable to build a release version, while debug versions runs smooth. Significant difference between prod and dev version of apk on size. Tried all the above steps, 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.

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

@blasten
Copy link

blasten commented Aug 9, 2019

@muthufmass when you file the new issue, please include the Android SDK version, device model, the doctor output, and steps starting from flutter create.

@tvolkert
Copy link
Contributor

tvolkert commented Aug 9, 2019

@muthufmass as well as adb logcat output.

This issue is closed - please file a new issue so we can track it properly.

@muthufmass
Copy link

raised a separate ticket now #37935

@solid-dimakoniaiev
Copy link

If u had flavors in your project, and want to support both x64 and x32, just add jniLibs folder to your flavor folder and it's work great, like this
image

@jeuxdaily
Copy link

jeuxdaily commented Aug 23, 2019

how can I do this in adobe animate cc
need more info

@newapproach
Copy link

Google play console recently has started disabling the rollout button because of various warnings. And one of those warnings is using apk instead of .aab file. There are solutions to make .aab file if the project has been created in Android Studio or Unity. But what if apk has been created by Animate CC or Haxe/Flash Develop? Is there any way to convert?

@eseidelGoogle
Copy link
Contributor

@newapproach it's not clear to me if your comment has anything to do with Flutter? Would you be willing to file a new issue with more details? Thanks!

@kecson
Copy link

kecson commented Nov 22, 2019

Have the same problem - but flutter.so not included in "armeabi-v7a folder.
Has only third party libraries for x86 and armeabi-v7a - but no arm64.
Would like to build flutter only for "armeabi-v7a with
ndk{
abiFilters "armeabi-v7a" // also not work"armeabi", "x86",
}
and set as target-platform as @mravn-google suggest to android-arm.

APK without specify arch and not include libraries
screen shot 2018-07-26 at 21 06 53

APK with libraries and no arm spec
screen shot 2018-07-26 at 21 10 30

APK with specify arch and include libraries
screen shot 2018-07-26 at 21 12 58

Any suggestion how to debug further steps?

I has find this error too, it is fixed?? Could help me?

@eseidelGoogle
Copy link
Contributor

I recommend asking on Stack Overflow, or opening a new bug. I doubt this closed bug will be the right place for folks to help you resolve the above issue. Thanks!

@aldwnesx
Copy link

This was my solution:

  1. in app gradle
splits {
        // Configures multiple APKs based on ABI.
        abi {
            // Enables building multiple APKs per ABI.
            enable true
            // By default all ABIs are included, so use reset() and include to specify that we only
            // want APKs for armeabi-v7a and arm64-v8a.

            // Resets the list of ABIs that Gradle should create APKs for to none.
            reset()

            // Specifies a list of ABIs that Gradle should create APKs for.
            include "armeabi-v7a", "arm64-v8a"

            // Specifies that we do not want to also generate a universal APK that includes all ABIs.
            universalApk false
        }
    }
  1. run flutter build apk --release --target-platform=android-arm
  2. upload app-armeabi-v7a-release.apk to the play store
  3. increment versionCode
  4. run flutter build apk --release --target-platform=android-arm64
  5. upload app-arm64-v8a-release.apk to the play store

Google play store will serve App according to device architecture. 32bit devices are happy, 64bit devices are happy and I'm happy knowing that my APK size remains relatively small while still serving both architectures.

If we include support for both architectures in the same APK, expect the size of your app to be 10MB+

doesn't work.. when I view it on playstore on pixel 2 it says not supported for this device

@jbg
Copy link

jbg commented Mar 28, 2020

It does work, many well-known apps have been deploying multiple APKs this way and letting the Play Store serve the appropriate one to the appropriate device for a long time.

App bundles are the modern way to do this, though.

@aldwnesx
Copy link

It does work, many well-known apps have been deploying multiple APKs this way and letting the Play Store serve the appropriate one to the appropriate device for a long time.

App bundles are the modern way to do this, though.

I don’t know why it’s not showing up on pixel 2 playstore for me then... I folllowr exactly , twice, just incase..
I used app bundle and my app is crashing hence I’m looking for alternatives

@lock
Copy link

lock bot commented Apr 15, 2020

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.

@lock lock bot locked and limited conversation to collaborators Apr 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: new feature Nothing broken; request for a new capability customer: crowd Affects or could affect many people, though not necessarily a specific customer. platform-android Android applications specifically t: gradle "flutter build" and "flutter run" on Android tool Affects the "flutter" command-line tool. See also t: labels. waiting for PR to land (fixed) A fix is in flight
Projects
None yet
Development

No branches or pull requests