JNI 防混淆 Android proguard
程序员文章站
2022-05-09 09:51:35
先写最终解决办法-keep class com.test.DocDetect { *;}com.test.DocDetct 换成你的JNI类异常java.lang.UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoadAPK的release包崩溃,debug包正常JNI内反射加载类找不到导致反编译APK(或者看mapping文件),发现DetectResult类,被rename 成 a.b.c,包名都变了方法添加JNI...
先写最终解决办法
-keep class com.test.DocDetect {
*;
}
com.test.DocDetct 换成你的JNI类
异常
java.lang.UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoad
- APK的release包崩溃,debug包正常
- JNI内反射加载类找不到导致
- 反编译APK(或者看mapping文件),发现
DetectResult类,被rename 成 a.b.c,包名都变了
方法
添加JNI相关类的防混淆
解决尝试
1. keep class
防止类被移走、重命名
-keep class com.test.DetectResult
-keep class com.test.DocDetect
- private的属性 被混淆
- 继承自接口的方法被混淆 (接口没防混淆)
2. keepclassmembers
只防止类的成员 被移走、重命名
-keepclassmembers class com.test.DetectResult {
*;
}
-keepclassmembers class com.test.DocDetect {
*;
}
- com.sogou.image.document.DetectResult 被混淆
3. 最终解决
#Doc Detect SDK
-keep class com.test.DetectResult {
*;
}
-keep class com.test.DocDetect {
*;
}
文档总结
# Add *one* of the following rules to your Proguard configuration file.
# Alternatively, you can annotate classes and class members with @androidx.annotation.Keep
# keep the class and specified members from being removed or renamed
-keep class com.sogou.image.document.DocDetect { *; }
# keep the specified class members from being removed or renamed
# only if the class is preserved
-keepclassmembers class com.sogou.image.document.DocDetect { *; }
# keep the class and specified members from being renamed only
-keepnames class com.sogou.image.document.DocDetect { *; }
# keep the specified class members from being renamed only
-keepclassmembernames class com.sogou.image.document.DocDetect { *; }
本文地址:https://blog.csdn.net/zhjali123/article/details/107596775