问题
Hi i am developing an app with Javacv. The app works fine until i proguard the build. After proguarding, the app crashes at the place of jni function call.
-dontshrink
-dontoptimize
-dontpreverify
-dontwarn android.support.**
-keep class com.googlecode.javacv.**
-dontwarn com.googlecode.javacv.**
-keep class com.googlecode.javacpp.**
-dontwarn com.googlecode.javacpp.**
-keepclasseswithmembernames class * {
native <methods>;
}
-keepattributes *Annotation*
I can't find any answer that solves my problem. I am getting NoSuchMethodError. Anybody help me. I am using the latest version of Javacv library.
回答1:
You have to keep your native methods (which you're already doing), as well as the Java methods called from native code.
You can keep all javacv and javacpp methods like so:
-keep class com.googlecode.javacv.**{ *; }
-keepclassmembers class com.googlecode.javacv.** {
<methods>;
}
-keep class com.googlecode.javacpp.**{ *; }
-keepclassmembers class com.googlecode.javacpp.** {
<methods>;
}
Also, if you want to cut down on warnings in the build output:
-dontwarn com.googlecode.javacv.**, com.googlecode.javacpp.**
-dontnote com.googlecode.javacv.**, com.googlecode.javacpp.**
来源:https://stackoverflow.com/questions/21478125/prograurding-android-project-using-javacv-gives-exception