不混淆 android jni,JNI 防混淆 Android proguard

先写最终解决办法

-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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值