Bad JNI version returned from JNI_OnLoad, Android 11 crash

Viewed 1417

So I'm using dexprotector 9.0.19 in my project and it runs perfectly in all Android versions except Android 11. My team is working with another app that uses dexprotector too and their setup is identical, only crashing in my project.

When trying to run the app it instantly crashs, all the logs I'm able to get are these:

2021-01-25 17:30:33.025 11812-11812/com.interfacom.toolkit E/AndroidRuntime: FATAL EXCEPTION: main Process: com.interfacom.toolkit, PID: 11812 java.lang.RuntimeException: Unable to instantiate application com.interfacom.toolkit.ProtectedAndroidApplication: com.interfacom.toolkit.MessageGuardException_QmFkIEpOSSB2ZXJzaW9uIHJldHVybmVkIGZyb20gSk5JX09uTG9hZCBpbiAiL2RhdGEvdXNlci8wL2NvbS5pbnRlcmZhY29tLnRvb2xraXQvYXBwX291dGRleC9saWJkZXhwcm90ZWN0b3IudWo2b3V0LjExODEyLnNvIjogLTEzMTk: Bad JNI version returned from JNI_OnLoad in "/data/user/0/com.interfacom.toolkit/app_outdex/libdexprotector.uj6out.11812.so": -1319 (RmluZ2VycHJpbnQgMjAxODA5MjQgWysuLisuLl0geDg2Ong4NiAyOS8yLjEuMC8tIGdvb2dsZS9zZGtfZ3Bob25lX3g4Ni9nZW5lcmljX3g4Nl9hcm06MTAvUlBQNC4yMDA0MDkuMDE1LzY0NTUzMTE6dXNlci9yZWxlYXNlLWtleXM=) at android.app.LoadedApk.makeApplication(LoadedApk.java:1216) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6533) at android.app.ActivityThread.access$1300(ActivityThread.java:231) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7478) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941) Caused by: com.interfacom.toolkit.MessageGuardException_QmFkIEpOSSB2ZXJzaW9uIHJldHVybmVkIGZyb20gSk5JX09uTG9hZCBpbiAiL2RhdGEvdXNlci8wL2NvbS5pbnRlcmZhY29tLnRvb2xraXQvYXBwX291dGRleC9saWJkZXhwcm90ZWN0b3IudWo2b3V0LjExODEyLnNvIjogLTEzMTk: Bad JNI version returned from JNI_OnLoad in "/data/user/0/com.interfacom.toolkit/app_outdex/libdexprotector.uj6out.11812.so": -1319 (RmluZ2VycHJpbnQgMjAxODA5MjQgWysuLisuLl0geDg2Ong4NiAyOS8yLjEuMC8tIGdvb2dsZS9zZGtfZ3Bob25lX3g4Ni9nZW5lcmljX3g4Nl9hcm06MTAvUlBQNC4yMDA0MDkuMDE1LzY0NTUzMTE6dXNlci9yZWxlYXNlLWtleXM=) at com.interfacom.toolkit.ProtectedAndroidApplication.attachBaseContext(Unknown Source:53) at android.app.Application.attach(Application.java:351) at android.app.Instrumentation.newApplication(Instrumentation.java:1159) at android.app.LoadedApk.makeApplication(LoadedApk.java:1208) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6533)  at android.app.ActivityThread.access$1300(ActivityThread.java:231)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loop(Looper.java:223)  at android.app.ActivityThread.main(ActivityThread.java:7478)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)  Caused by: java.lang.UnsatisfiedLinkError: Bad JNI version returned from JNI_OnLoad in "/data/user/0/com.interfacom.toolkit/app_outdex/libdexprotector.uj6out.11812.so": -1319 at java.lang.Runtime.load0(Runtime.java:939) at java.lang.System.load(System.java:1625) at com.interfacom.toolkit.ProtectedAndroidApplication.xwmukuyhw(Unknown Source:105) at com.interfacom.toolkit.ProtectedAndroidApplication.e(Unknown Source:182) at com.interfacom.toolkit.ProtectedAndroidApplication.attachBaseContext(Unknown Source:3) at android.app.Application.attach(Application.java:351)  at android.app.Instrumentation.newApplication(Instrumentation.java:1159)  at android.app.LoadedApk.makeApplication(LoadedApk.java:1208)  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6533)  at android.app.ActivityThread.access$1300(ActivityThread.java:231)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loop(Looper.java:223)  at android.app.ActivityThread.main(ActivityThread.java:7478)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941) 

Any help will be much appreciated!

2 Answers

Go to edit configuratitons -> debugger -> debug type -> java only -> Apply

First, we will enable shrinking in the build file. Find build.gradle file which sits inside /android/app/ folder and add lines in bold `android {

...

buildTypes {

release {
    
    signingConfig signingConfigs.debug     
    //add everything below
    useProguard true

    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 

}

} }

Next create /android/app/proguard-rules.pro file and insert inside:

-keep class com.arthenica.mobileffmpeg.Config {
native ;
void log(long, int, byte[]);
void statistics(long, int, float, float, long , int, double, double);
}

-keep class com.arthenica.mobileffmpeg.AbiDetect {
native ;
}
Related