beeware / briefcase-android-gradle-template

A template for generating Android Gradle projects with Briefcase
MIT License
18 stars 19 forks source link

APK can still be installed on x86 emulators, but crashes #51

Closed mhsmith closed 1 year ago

mhsmith commented 2 years ago

Reported on Discord by нυηтєя.

The current Android support package no longer includes x86 libraries. However, Gradle defaults to building libnative-lib.so for all ABIs, so the APK contains the following:

    66272  1981-01-01 01:01   lib/arm64-v8a/libbz2.so
       15  1981-01-01 01:01   lib/arm64-v8a/libcrypto.so
  2374640  1981-01-01 01:01   lib/arm64-v8a/libcrypto1.1.so
    26656  1981-01-01 01:01   lib/arm64-v8a/libffi.so
   133800  1981-01-01 01:01   lib/arm64-v8a/liblzma.so
    10080  1981-01-01 01:01   lib/arm64-v8a/libnative-lib.so
  2750440  1981-01-01 01:01   lib/arm64-v8a/libpython3.8.so
    37624  1981-01-01 01:01   lib/arm64-v8a/librubicon.so
   738064  1981-01-01 01:01   lib/arm64-v8a/libsqlite3.so
       12  1981-01-01 01:01   lib/arm64-v8a/libssl.so
   507800  1981-01-01 01:01   lib/arm64-v8a/libssl1.1.so
    64676  1981-01-01 01:01   lib/armeabi-v7a/libbz2.so
       15  1981-01-01 01:01   lib/armeabi-v7a/libcrypto.so
  1788528  1981-01-01 01:01   lib/armeabi-v7a/libcrypto1.1.so
    23160  1981-01-01 01:01   lib/armeabi-v7a/libffi.so
   126580  1981-01-01 01:01   lib/armeabi-v7a/liblzma.so
    13868  1981-01-01 01:01   lib/armeabi-v7a/libnative-lib.so
  2381012  1981-01-01 01:01   lib/armeabi-v7a/libpython3.8.so
    27580  1981-01-01 01:01   lib/armeabi-v7a/librubicon.so
   700916  1981-01-01 01:01   lib/armeabi-v7a/libsqlite3.so
       12  1981-01-01 01:01   lib/armeabi-v7a/libssl.so
   415348  1981-01-01 01:01   lib/armeabi-v7a/libssl1.1.so
     5620  1981-01-01 01:01   lib/x86/libnative-lib.so
    76024  1981-01-01 01:01   lib/x86_64/libbz2.so
       15  1981-01-01 01:01   lib/x86_64/libcrypto.so
  2643584  1981-01-01 01:01   lib/x86_64/libcrypto1.1.so
    28520  1981-01-01 01:01   lib/x86_64/libffi.so
   138552  1981-01-01 01:01   lib/x86_64/liblzma.so
    10344  1981-01-01 01:01   lib/x86_64/libnative-lib.so
  2746648  1981-01-01 01:01   lib/x86_64/libpython3.8.so
    37992  1981-01-01 01:01   lib/x86_64/librubicon.so
   756888  1981-01-01 01:01   lib/x86_64/libsqlite3.so
       12  1981-01-01 01:01   lib/x86_64/libssl.so
   534872  1981-01-01 01:01   lib/x86_64/libssl1.1.so

Because there's at least one x86 library in the APK, it can still be installed on x86 emulators, but it crashes on startup with the following error:

06-26 19:28:35.377  2874  2874 E MainActivity: Failed to create Python app
06-26 19:28:35.377  2874  2874 E MainActivity: java.lang.RuntimeException: Unable to find file matching pythonhome.* and x86.zip
06-26 19:28:35.377  2874  2874 E MainActivity:  at org.beeware.android.MainActivity.unpackPython(MainActivity.java:134)
06-26 19:28:35.377  2874  2874 E MainActivity:  at org.beeware.android.MainActivity.startPython(MainActivity.java:201)
06-26 19:28:35.377  2874  2874 E MainActivity:  at org.beeware.android.MainActivity.onCreate(MainActivity.java:249)
06-26 19:28:35.377  2874  2874 E MainActivity:  at android.app.Activity.performCreate(Activity.java:7136)

This can be fixed by adding the abiFilters setting to build.gradle to explicitly list the ABIs we support. That way, Gradle won't waste time building an x86 libnative-lib.so, and if you attempt to install the APK on an x86 device, it'll fail immediately with a clear error message.

Environment:

Hunter2809 commented 2 years ago

The python version for the same is 3.10.4

mhsmith commented 1 year ago

This will be fixed by moving to Chaquopy.