开发环境:AndroidStudio 4.1
测试手机:VivoZ3 Android 9.0手机
混淆方式:官方混淆没有修改
问题:直接使用MobileIMSDK4aDemo_tcp6.1.1版本打release包,开启混淆后闪退,如果不开启混淆就不闪退。 错误日志(文本):
2021-09-03 10:57:43.535 20237-20353/? E/AndroidRuntime: FATAL EXCEPTION: MBThreadPool #1
Process: net.x52im.mobileimsdk.android.demo_tcp, PID: 20237 java.lang.NoClassDefFoundError: d.a.b.j
at d.a.c.d0.<init>(Unknown Source:3)
at d.a.c.d0.<init>(Unknown Source:5)
at d.a.a.f.<init>(Unknown Source:6)
at d.a.a.a.o(Unknown Source:71)
at d.a.a.c.F(Unknown Source:0)
at d.a.a.c.D(Unknown Source:14)
at d.a.a.c.C(Unknown Source:4)
at e.a.a.a.c.t.k(Unknown Source:18)
at e.a.a.a.c.t.i(Unknown Source:6)
at e.a.a.a.c.s.h(Unknown Source:44)
at e.a.a.a.c.s$b.a(Unknown Source:6)
at e.a.a.a.f.e.c(Unknown Source:0)
at e.a.a.a.f.b.run(Unknown Source:4)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764) Caused by: java.lang.ExceptionInInitializerError
at d.a.b.l.<clinit>(Unknown Source:61)
at d.a.b.j.<clinit>(Unknown Source:0)
at d.a.c.d0.<init>(Unknown Source:3)
at d.a.c.d0.<init>(Unknown Source:5)
at d.a.c.d1.e.<init>(Unknown Source:0)
at d.a.c.d1.h.c$b.<init>(Unknown Source:2)
at d.a.c.d1.h.c$b.<init>(Unknown Source:0)
at d.a.c.d1.h.c.<init>(Unknown Source:10)
at d.a.c.d1.h.c.<init>(Unknown Source:1)
at d.a.c.d1.h.c.<init>(Unknown Source:4)
at d.a.c.d1.h.c.<init>(Unknown Source:2)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at d.a.c.u0.a(Unknown Source:5)
at d.a.a.a.o(Unknown Source:3)
at d.a.a.c.F(Unknown Source:0)
at d.a.a.c.D(Unknown Source:14)
at d.a.a.c.C(Unknown Source:4)
at e.a.a.a.c.t.k(Unknown Source:18)
at e.a.a.a.c.t.i(Unknown Source:6)
at e.a.a.a.c.s.h(Unknown Source:44)
at e.a.a.a.c.s$b.a(Unknown Source:6)
at e.a.a.a.f.e.c(Unknown Source:0)
at e.a.a.a.f.b.run(Unknown Source:4)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764) Caused by: java.lang.IllegalArgumentException: Can't find '[toLeakAwareBuffer]' in d.a.b.b
at d.a.f.q.d(Unknown Source:130)
at d.a.b.b.<clinit>(Unknown Source:10)
at d.a.b.l.<clinit>(Unknown Source:61)
at d.a.b.j.<clinit>(Unknown Source:0)
at d.a.c.d0.<init>(Unknown Source:3)
at d.a.c.d0.<init>(Unknown Source:5)
at d.a.c.d1.e.<init>(Unknown Source:0)
at d.a.c.d1.h.c$b.<init>(Unknown Source:2)
at d.a.c.d1.h.c$b.<init>(Unknown Source:0)
at d.a.c.d1.h.c.<init>(Unknown Source:10)
at d.a.c.d1.h.c.<init>(Unknown Source:1)
at d.a.c.d1.h.c.<init>(Unknown Source:4)
at d.a.c.d1.h.c.<init>(Unknown Source:2)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at d.a.c.u0.a(Unknown Source:5)
at d.a.a.a.o(Unknown Source:3)
at d.a.a.c.F(Unknown Source:0)
at d.a.a.c.D(Unknown Source:14)
at d.a.a.c.C(Unknown Source:4)
at e.a.a.a.c.t.k(Unknown Source:18)
at e.a.a.a.c.t.i(Unknown Source:6)
at e.a.a.a.c.s.h(Unknown Source:44)
at e.a.a.a.c.s$b.a(Unknown Source:6)
at e.a.a.a.f.e.c(Unknown Source:0)
at e.a.a.a.f.b.run(Unknown Source:4)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# [url=http://developer.android.com/guide/developing/tools/proguard.html]http://developer.android.com/guide/developing/tools/proguard.html[/url]
# 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 *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
# 忽略警告
-dontwarn android.support.v4.**
-dontwarn android.support.v7.**
# 忽略警告(针对Android X)
-dontwarn com.google.android.material.**
-dontnote com.google.android.material.**
-dontwarn androidx.**
# 忽略google相关的混淆警告(比如google分析的包等)
-dontwarn com.google.**
-dontwarn org.apache.http.**
-dontwarn android.net.http.**
-dontwarn okio.**
-dontwarn okhttp3.**
-dontwarn javax.annotation.**
-dontwarn javax.inject.**
-dontwarn sun.misc.Unsafe
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
# 排除netty的混淆
-keepattributes Signature,InnerClasses
-keepclasseswithmembers class io.netty.** { *;}
-keepnames class io.netty.** { *;}
# 排除google相关的混淆(比如google分析的包等)
-keep class com.google.**
# 保留Google GSON相关API:
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }
-keep class com.google.gson.** { *;}
# 保留fastjson相关API:
-keep class com.alibaba.fastjson.** { *;}
# 保留Apache http相关API:
-keep class org.apache.http.** { *; }
-keep class android.net.http.** { *; }
# 保留okhttp3相关API:
-keep class okio.** { *;}
-keep class okhttp3.** { *;}
-keep interface okhttp3.** { *; }
# 【重要】以下3行可排除R资源文件及其及类的混淆,否则运行时将报找不到资源
-keepattributes InnerClasses
-keep class **.R
-keep class **.R$* {
<fields>;
}
# 保留MobileIMSDK的Protocal相关类
-keep class net.x52im.mobileimsdk.server.protocal.** { *; }
# 保留Android的一些默认API
-keep class android.support.v4.** { *; }
-keep class android.support.v7.** { *; }
-keep class android.support.annotation.** { *; }
-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 * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keepattributes *Annotation*
# 避免使用泛型的位置混淆后出现类型转换错误:
-keepattributes Signature
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
# 保留Android的一些默认API(针对Android x)
-keep class com.google.android.material.** {*;}
-keep class androidx.** {*;}
-keep public class * extends androidx.**
-keep interface androidx.** {*;}
# 保留JNI的native接口方法
-keepclasseswithmembernames class * {
native <methods>;
}
# 保留所有自定义View的相关API(这些View可能用于了layout的xml文件里了)
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
# 保留所有Acvitity子类
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
# 保留所有枚举
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
# 保留JSON、Parcelable、Serailizable等对象(否则代码中序列化、反序列化会失败):
-keepclassmembers class * {
public <init>(org.json.JSONObject);
}
-keepnames class * implements java.io.Serializable
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
!static !transient <fields>;
!private <fields>;
!private <methods>;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}