Search code examples
androidandroid-gradle-pluginzipalign

dlopen failed for privileged app when upgrade gradle build tools from 3.6.1 to 4.1.0


I have an app which locate in /system/priv-app/MyTestApp. The android source code environment is Android P (API 28).

At first, the MyTestApp.apk was build with gradle build tools 3.6.1. Then I upgrade it to 4.1.0 and build a new MyTestApp.apk and prebuilt it in the rom. So the crash happens.

E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "/system/priv-app/MyTestApp/MyTestApp.apk!/lib/armeabi-v7a/libmytest.so" not found
E AndroidRuntime:       at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
E AndroidRuntime:       at java.lang.System.loadLibrary(System.java:1669)

I pull the file /system/priv-app/MyTestApp/MyTestApp.apk, extract the file and found that the libmytest.so exists. It definitely caused by gradle build tools upgrade. But I can't find the reason. Could anyone give some help?


Solution

  • android.useNewApkCreator=false
    

    Add this line in gradle.properties can solve this issue.

    But since AGP 3.6+, the default value of this property is true. So it should not be the difference between AGP 4.0 and AGP 4.1.

    I'm so confused. There maybe some else conditions to make effect.