Reputation: 1080
I am getting the following error when I enable proguard.
java.lang.UnsatisfiedLinkError: No implementation found for java.lang.String com.osolutions.otv.utilities.al.b() (tried Java_com_osolutions_otv_utilities_al_b and Java_com_osolutions_otv_utilities_al_b__)
at com.osolutions.otv.utilities.al.b(Native Method)
at com.osolutions.otv.utilities.al.<clinit>(Unknown Source)
at com.osolutions.otv.activity.SplashScreenActivity.a(Unknown Source)
at com.osolutions.otv.activity.y.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7331)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
I have initialized the Cpp class also using
static {
System.loadLibrary("baseUrl");
}
If I disable proguard it works fine. This is the case when proguard is enabled.
Upvotes: 7
Views: 7626
Reputation: 6583
As @Botje suggests, it looks like the problem in your case is that the native name and the definition of your method in Java side get out of sync, so to speak.
Your public native String myMethod();
gets changed to public native String b();
by ProGuard, but your native implementation keeps the original name. That's why the Java runtime cannot find it.
You need to add the following to your ProGuard file:
-keepclasseswithmembernames,includedescriptorclasses class * {
native <methods>;
}
Please, do NOT mark this answer as the solution, as it was @Botje who came with it (I just developed the explanation a little further).
@Botje please add your own answer so he can mark it as the solution.
Upvotes: 11