Hello, I noticed the Android app was crashing when building in release mode for production.
Apparently Android NDK lib failed to load when minify is enabled (default for release).
To reproduce change "minifyEnabled false" to "minifyEnabled true" or just remove it in Android/NDK/app/build.gradle
https://github.com/Azure/azure-spatial-anchors-samples/blob/master/Android/NDK/app/build.gradle
I don't know enough about that minify option to say whether it's a bug or not. But it did take a lot of time to figure out just before the release.
As a result I had to disable minify for entire app which is not ideal.
Stack trace
2022-07-20 13:50:39.872 4221-4221/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.microsoft.samplenativeandroid, PID: 4221
java.lang.UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoad in "/data/app/~~CxvJgphZ1hj94zORN567XA==/com.microsoft.samplenativeandroid-_PyNcM0eTlb3amOcba7qPA==/base.apk!/lib/arm64-v8a/libazurespatialanchorsapplication.so"
at java.lang.Runtime.loadLibrary0(Runtime.java:1077)
at java.lang.Runtime.loadLibrary0(Runtime.java:998)
at java.lang.System.loadLibrary(System.java:1656)
at com.microsoft.samplenativeandroid.JniInterface.<clinit>(Unknown Source:2)
at com.microsoft.samplenativeandroid.JniInterface.onCreate(Native Method)
at com.microsoft.samplenativeandroid.MainActivity.onCreate(Unknown Source:19)
Same with the latest version.
------------------------------------------------
My environment (Android Studio -> Help -> About)
Android Studio Chipmunk | 2021.2.1 Patch 1
Build #AI-212.5712.43.2112.8609683, built on May 18, 2022
Runtime version: 11.0.12+7-b1504.28-7817840 amd64
VM: OpenJDK 64-Bit Server VM by Oracle Corporation
Windows 10 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 1280M
Cores: 4
Registry: external.system.auto.import.disabled=true
Non-Bundled Plugins: org.jetbrains.kotlin (212-1.6.21-release-334-AS5457.46)
------------------------------------------------
Android SDK Build-Tools 33.0.0-rc4
NDK 24.0.8215888
cmake 3,18,1
------------------------------------------------
Android device:
Samsung Galaxy S20+ 5G
Android version 12
------------------------------------------------
Here is the minimal change I needed to get the project compiled.
https://github.com/Azure/azure-spatial-anchors-samples/compare/master...sergeiromanov:azure-spatial-anchors-samples:minify-test
------------------------------------------------
In Android Studio select build variant release, configure signing. Then build and run on your device.
@Sergii Romanov
- Can you add the following to the proguard-rules.pro
-keep class com.microsoft.spatialservices.internal.AzureSpatialAnchorsCloudClientHelpers {
-keep class com.microsoft.mixedreality.**
-keep class com.xbox.httpclient.**