gluonhq / gluon-samples

Gluon sample projects
298 stars 166 forks source link

GoNative crashes on Android 11 and later #143

Closed molbertz closed 2 years ago

molbertz commented 2 years ago

I've build the sample multiple times. I tried Java 11 Gluon GraalVM 22.0.0.2 and Java 17 Gluon GraalVM 22.0.0.3. Both of those run on Android 10 and older. On newer Android versions the app crashes with the same error each time:

2022-04-13 10:22:45.598 28622-28622/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.bscgmbh, PID: 28622 java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__android_log_print" referenced by "/data/app/~~vrzTQ9N_jgWhG_fx0Iux0Q==/com.bscgmbh-FVgmytBzS5bwQzbKH3Ud5w==/lib/arm64/libsubstrate.so"... at java.lang.Runtime.loadLibrary0(Runtime.java:1087) at java.lang.Runtime.loadLibrary0(Runtime.java:1008) at java.lang.System.loadLibrary(System.java:1664) at com.gluonhq.helloandroid.MainActivity.surfaceCreated(MainActivity.java:111)

jperedadnr commented 2 years ago

Can you try the following:

  1. run: mvn -Pandroid gluonfx:build gluonfx:package

  2. cd target/gluonfx/aarch64-android/gvm/android_project/

  3. edit the file app/build.gradle and add:

android {
...
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 30

        ndk {
            ldLibs "log"
        }
    }
...
} 

and save the file.

  1. Manually build the apk:
export ANDROID_SDK_ROOT=~/.gluon/substrate/Android
./gradlew app:assembleDebug 
  1. Resume deployment:
cd ../../../../../
mvn -Pandroid gluonfx:install gluonfx:nativerun

And see if it works now?

molbertz commented 2 years ago

I did and the build seemed successful. But I can't find the newly built apk. This one: "target/gluonfx/aarch64-android/gvm/GoNative.apk" has the same checksum as the original build. And so does this one: "target/gluonfx/aarch64-android/gvm/android_project/app/build/outputs/apk/debug/app-debug.apk"

I need the actual apk because I need to send it to our testers. The mvn -Pandroid gluonfx:install gluonfx:nativerun call runs just fine with the phone connected to my pc. But that one runs a lower Android version and had no problems with the original build.