Prograurding android project using Javacv gives exception

懵懂的女人 提交于 2019-12-20 03:15:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!