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

Force the native libraries compression for NativeActivity-based applications targeting an Android 6.0 device #134

Closed
ghost opened this issue Nov 28, 2019 · 8 comments

Comments

@ghost
Copy link

ghost commented Nov 28, 2019

Description
Installing an application that has the installLocation manifest attribute set to internalOnly using splits APKs extracted from an Android App Bundle highlights an issue. The bundletool command line tool decides to leave the native libraries uncompressed and set the extractNativeLibs manifest attribute to false based on the fact of the connected device is running Android 6.0 and the application has the installLocation manifest attribute set to internalOnly. Please the result is that the application crashes at startup on an Android 6.0 device.

Please this bug report is about considering to change the bundletool command line tool in order to detect that the application is based on the NativeActivity class (for example, detecting if the launcher activity has similar declaration to <meta-data android:name="android.app.lib_name" android:value="native-activity" />) and force the native libraries compression if the target device is running Android 6.0.

Bundletool version affected
Version: 0.10.3

Stacktrace

11-28 11:27:48.377 31847-31847/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.native_activity, PID: 31847
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.native_activity/android.app.NativeActivity}: java.lang.IllegalArgumentException: Unable to find native library: native-activity
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2426)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
        at android.app.ActivityThread.-wrap11(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5443)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
     Caused by: java.lang.IllegalArgumentException: Unable to find native library: native-activity
        at android.app.NativeActivity.onCreate(NativeActivity.java:170)
        at android.app.Activity.performCreate(Activity.java:6245)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490) 
        at android.app.ActivityThread.-wrap11(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5443) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 

To Reproduce

  • Download the native-activity sample application from the ndk-samples repository.
  • Launch the Android Studio.
  • Open the native-activity project.
  • Open the AndroidManifest.xml file.
  • Set the extractNativeLibs manifest attribute to false.

Expected behavior
The application succeeds to launch.

Actual behavior
The application fails to launch due to:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.native_activity/android.app.NativeActivity}: java.lang.IllegalArgumentException: Unable to find native library: native-activity

Known workaround
Setting the installLocation manifest attribute to auto or preferExternal causes the bundletool command line tool to compress the native libraries and the reported issue is no longer reproducible.

Environment:

  • Android Studio 4.0 Canary 4 / Windows 10 May 2019 Update
  • Motorola G2 / Android 6.0
@ghost ghost changed the title Disable native libraries compression for NativeActivity-based applications targeting an Android 6.0 device Force native libraries compression for NativeActivity-based applications targeting an Android 6.0 device Nov 28, 2019
@ghost ghost changed the title Force native libraries compression for NativeActivity-based applications targeting an Android 6.0 device Force the native libraries compression for NativeActivity-based applications targeting an Android 6.0 device Nov 28, 2019
@ghost
Copy link
Author

ghost commented Nov 28, 2019

I created a similar bug report in the ndk-samples respository:
android/ndk-samples#668

@ghost
Copy link
Author

ghost commented Nov 30, 2019

Hello @plecesne,

I apologize for pinging you. I also reported this issue in https://issuetracker.google.com/issues/145315585. Please that can help you to decide how to address better this bug report.

Thankfully,
Horácio Filho

@plecesne
Copy link
Contributor

plecesne commented Dec 2, 2019

While this is being investigated, consider adding android.bundle.enableUncompressedNativeLibs=false to the gradle properties of your project which will force bundletool to compress the native libraries in the generated APKs.

@ghost
Copy link
Author

ghost commented Dec 6, 2019

Hello @plecesne

Thank you for the suggestion. I didn't mention the fact that I use a custom build system, in this case, setting the uncompressNativeLibraries config to false in the specified BundleConfig.json file addresses the reported issue. Unfortunately, this has the negative effect of affecting all Android versions.

Thankfully,
Horácio Filho

@plecesne
Copy link
Contributor

plecesne commented Dec 6, 2019

Thanks, yes, we're discussing this issue internally to find the best solution.

@ghost
Copy link
Author

ghost commented Dec 6, 2019

Hello @plecesne,

That is pretty lovely to hear. Thank you very much and sorry for any inconvenience.

Thankfully,
Horácio Filho

@ymakhno
Copy link

ymakhno commented Mar 11, 2020

Should be fixed in 0.13.3

@ymakhno ymakhno closed this as completed Mar 11, 2020
@ghost
Copy link
Author

ghost commented Mar 12, 2020

Thank you very much for addressing this issue.

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

2 participants