Android项目中使用javacv和javacpp的代码混淆配置
16lz
2021-01-26
最近一个项目中涉及到了视频录制,使用到了javacv和javacpp,于是在打包混淆的时候出了问题,总是报错,错误信息如下:
02-27 13:43:53.400: E/AndroidRuntime(25640): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load jniPointer: findLibrary returned null02-27 13:43:53.400: E/AndroidRuntime(25640): at java.lang.Runtime.loadLibrary(Runtime.java:365)02-27 13:43:53.400: E/AndroidRuntime(25640): at java.lang.System.loadLibrary(System.java:535)02-27 13:43:53.400: E/AndroidRuntime(25640): at com.googlecode.javacpp.Loader.loadLibrary(Unknown Source)02-27 13:43:53.400: E/AndroidRuntime(25640): at com.googlecode.javacpp.Loader.load(Unknown Source)02-27 13:43:53.400: E/AndroidRuntime(25640): at com.googlecode.javacpp.Loader.load(Unknown Source)02-27 13:43:53.400: E/AndroidRuntime(25640): at com.googlecode.javacv.cpp.avcodec$AVPacket.(Unknown Source)02-27 13:43:53.400: E/AndroidRuntime(25640): ... 12 more02-27 13:43:53.400: E/AndroidRuntime(25640): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load gnustl_static: findLibrary returned null02-27 13:43:53.400: E/AndroidRuntime(25640): ... 18 more
搞了一下午,头都大了,最后终于解决了:
相关配置如下:
-libraryjars libs/javacpp.jar
-libraryjars libs/javacv.jar
-dontwarn com.googlecode.**
-keep class com.googlecode.**{*;}
-keepattributes *Annotation*
-keepattributes Exceptions,InnerClasses,Signature
-keepattributes SourceFile,LineNumberTable
刚开始没有添加:
-keepattributes Exceptions,InnerClasses,Signature
-keepattributes SourceFile,LineNumberTable
添加之后就不报错了,至于这两行的具体作用,暂时我还没有查资料。
所有的混淆配置如下:
# To enable ProGuard in your project, edit project.properties# to define the proguard.config property as described in that file.## Add project specific ProGuard rules here.# By default, the flags in this file are appended to flags specified# in ${sdk.dir}/tools/proguard/proguard-android.txt# You can edit the include path and order by changing the ProGuard# include property in project.properties.## For more details, see# http://developer.android.com/guide/developing/tools/proguard.html# Add any project specific keep options here:# If your project uses WebView with JS, uncomment the following# and specify the fully qualified class name to the JavaScript interface# class:#-keepclassmembers class fqcn.of.javascript.interface.for.webview {# public *;#}-optimizationpasses 5-dontusemixedcaseclassnames-dontskipnonpubliclibraryclasses-dontpreverify-verbose-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*-libraryjars libs/android-async-http-1.4.4.jar-libraryjars libs/android-support-v7-recyclerview.jar-libraryjars libs/mta-sdk-1.6.2.jar-libraryjars libs/open_sdk_r4547.jar-libraryjars libs/universal-image-loader-1.9.3.jar-libraryjars libs/javacpp.jar-libraryjars libs/javacv.jar-keep public class * extends android.app.Activity-keep public class * extends android.app.Application-keep public class * extends android.app.Service-keep public class * extends android.content.BroadcastReceiver-keep public class * extends android.content.ContentProvider-keep public class com.android.vending.licensing.ILicensingService-keepclasseswithmembernames class * { native ;}-keepclasseswithmembernames class * { public (android.content.Context, android.util.AttributeSet);}-keepclasseswithmembernames class * { public (android.content.Context, android.util.AttributeSet, int);}-keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String);}-keep class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *;}-keep class com.sina.**{*;}-dontwarn com.googlecode.**-keep class com.googlecode.**{*;}-keepattributes *Annotation*-keepattributes Exceptions,InnerClasses,Signature -keepattributes SourceFile,LineNumberTable-dontwarn android-async-http-1.4.4.jar.**-keep class android-async-http-1.4.4.jar.**{*;}
更多相关文章
- Ophone倒转屏幕自适应问题
- Win10 + cygwin64 + ndk 配置ijkplayer android
- 【Gradle】Android(安卓)Gradle 高级自定义
- [Android]GreenDao(1)--项目配置
- Android(安卓)4.2 设置手机的 Airplane mode
- 添加android:screenOrientation="portrait"后警告报红
- android busybox 配置
- android wap push实现
- Android开发如何调试Service