Azure Spatial Anchors Android NDK lib fails to load when minify enabled

Sergii Romanov 46 Reputation points
2022-07-20T13:46:13.943+00:00

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)
...

Azure Spatial Anchors
Azure Spatial Anchors
An Azure service that is used to build immersive three-dimensional applications and experiences that map, persist, and restore content or points of interest at real-world scale.
86 questions
{count} votes

Accepted answer
  1. Rob Van Schooneveld 196 Reputation points Microsoft Employee
    2022-07-27T03:09:51.337+00:00

    @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.**  
    {  
    *;  
    }  
    
    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful