android-rs-glue
android-rs-glue copied to clipboard
application not starting on Android 5.1
I was using a Fairphone 2 running Android 5.1, Rust (installed using multirust) v1.8.0.
Commands (used in android-rs-glue/examples/basic (5a8e33fd4d53a186e97dfd0fb8f6cabfcaf5b1d5)):
export PATH=$PATH:~/Downloads/apache-ant-1.9.7/bin:~/Downloads/icedtea-bin-3.0.0/bin:~/Downloads/android-sdk/platform-tools/
export ANDROID_SDK_HOME=~/Downloads/android-sdk/
export NDK_HOME=~/Downloads/android-ndk-r11c/
cargo apk
Which succeeded in creating an APK.
Library:
target/android-artifacts/build/libs/armeabi/libmain.so: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /system/bin/linker, not stripped
When then deployed to the phone using adb install -r target/android-artifacts/build/bin/rstest-debug.apk, I get this in logcat:
Relevant part:
E/AndroidRuntime(18235): FATAL EXCEPTION: main
E/AndroidRuntime(18235): Process: rust.rstest, PID: 18235
E/AndroidRuntime(18235): java.lang.RuntimeException: Unable to start activity ComponentInfo{rust.rstest/rust.rstest.MainActivity}: java.lang.IllegalArgumentException: Unable to load native library: /data/app/rust.rstest-2/lib/arm/libmain.so
E/AndroidRuntime(18235): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
E/AndroidRuntime(18235): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
E/AndroidRuntime(18235): at android.app.ActivityThread.access$800(ActivityThread.java:151)
E/AndroidRuntime(18235): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
E/AndroidRuntime(18235): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(18235): at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(18235): at android.app.ActivityThread.main(ActivityThread.java:5254)
E/AndroidRuntime(18235): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(18235): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(18235): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
E/AndroidRuntime(18235): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
E/AndroidRuntime(18235): Caused by: java.lang.IllegalArgumentException: Unable to load native library: /data/app/rust.rstest-2/lib/arm/libmain.so
E/AndroidRuntime(18235): at android.app.NativeActivity.onCreate(NativeActivity.java:182)
E/AndroidRuntime(18235): at android.app.Activity.performCreate(Activity.java:5991)
E/AndroidRuntime(18235): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
E/AndroidRuntime(18235): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
E/AndroidRuntime(18235): ... 10 more
W/ActivityManager( 2962): Force finishing activity 1 rust.rstest/.MainActivity
I'm getting the same error on android 6.0.
One thing I've noticed is that the path of the library is lib/armeabi/libmain.so inside the apk, but the error say it cannot load the library from lib/arm/libmain.so
Is this expected or the root cause of the bug? Is the path different in different versions of Android?
Notice: I haven't had access to the phone on which I could reproduce this so anyone being able to reproduce this is very welcome to take over this issue.