请选择 进入手机版 | 继续访问电脑版

默认
发表评论 6
想开发IM:买成品怕坑?租第3方怕贵?找开源自已撸?尽量别走弯路了... 找站长给点建议
[已解决] MobileIMSDK4aDemo_tcp 6.1.1版本release版本开启混淆后闪退
MobileIMSDK4aDemo_tcp6.1.1版本release版本开启混淆后闪退MobileIMSDK4aDemo_tcp 版本号:6.1.1
SDKDemo名称:直接使用demo中的没有修改。

开发环境: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)

即时通讯网 - 即时通讯开发者社区! 来源: - 即时通讯开发者社区!

上一篇:即时通讯框架MobileIMSDK的H5端开发者手册(PDF导出图片)

本帖已收录至以下技术专辑

推荐方案
评论 6
在你的  proguard-rules.pro 文件里,加入MobileIMSDK的防混淆代码了没有,具体你看一下开发者指南里的这一节:
附录3:集成到APP时,为MobileIMSDK添加的代码混淆配置
签名: 假期就在眼前,舒服!
引用:JackJiang 发表于 2021-09-03 14:20
在你的  proguard-rules.pro 文件里,加入MobileIMSDK的防混淆代码了没有,具体你看一下开发者指南里的这一 ...

站长您好!我的直接用您demo运行的,混淆配置没有修改过。

-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

# 保留Google GSON相关API:
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }
-keep class com.google.gson.** { *;}

# 保留MobileIMSDK的Protocal相关类
-keep class net.x52im.mobileimsdk.server.protocal.** { *; }
有这些混淆配置还是闪退(开启混淆打包运行就闪退,不开启混淆打包运行就正常)。
引用:JackJiang 发表于 2021-09-03 14:20
在你的  proguard-rules.pro 文件里,加入MobileIMSDK的防混淆代码了没有,具体你看一下开发者指南里的这一 ...

楼主您好!我现在用的是你的SDK的demo运行的,没有改其他代码(混淆配置的与官网上是一样的)。

proguard-rules.pro文件如下:
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

# 保留Google GSON相关API:
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }
-keep class com.google.gson.** { *;}

# 保留MobileIMSDKProtocal相关类
-keep class net.x52im.mobileimsdk.server.protocal.** { *; }


app级别的 build.gradle文件如下:

其中我添加的代码标记如下:

//--------------------------我添加的打包配置代码 开始--------------------------//
        ...... 中间是我添加的打包签名文件配置代码
//--------------------------我添加的打包配置代码 结束--------------------------//



apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    defaultConfig {
        applicationId "net.x52im.mobileimsdk.android.demo_tcp"
        minSdkVersion 14
        targetSdkVersion 29
        versionCode 104
        versionName "v6.1b210724.2"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

//--------------------------我添加的打包配置代码 开始--------------------------//
    signingConfigs {
        release {
            storeFile file("../imKeyStore.jks")
            keyAlias "imAlias"
            storePassword "123456"
            keyPassword "123456"
        }
        debug {
            storeFile file("../imKeyStore.jks")
            keyAlias "imAlias"
            storePassword "123456"
            keyPassword "123456"
            v2SigningEnabled false
        }
    }
    buildTypes {
        release {
            minifyEnabled true //是否开启代码混淆(false/true
            shrinkResources false//是否压缩资源(false/true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release//配置签名文件
            android.applicationVariants.all { variant ->
                variant.outputs.all {
                    //自定义打包的名称和日期{命名模板:app名称_版本名_版本号_打包日期}eg:JK_SeaEyes_1.2_2_202010121139
                    outputFileName = "MobileImSdkDemo.apk"
                }
            }
        }
        debug {
            minifyEnabled false //是否开启代码混淆(false/true
            shrinkResources false//是否压缩资源(false/true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.debug//配置签名文件

            android.applicationVariants.all { variant ->
                variant.outputs.all {
                    //自定义打包的名称和日期{命名模板:app名称_版本名_版本号_打包日期}eg:JK_SeaEyes_1.2_2_202010121139
                    outputFileName = "MobileImSdkDemo.apk"
                }
            }
        }
    }
//--------------------------我添加的打包配置代码 结束--------------------------//
    dependencies {
        //implementation fileTree(dir: 'libs', include: ['*.jar'])
        //implementation 'com.android.support:appcompat-v7:28.0.0'

        implementation 'androidx.appcompat:appcompat:1.2.0'
        implementation 'com.google.android.material:material:1.2.0'

        // MobileIMSDK的依赖库
        implementation 'com.google.code.gson:gson:2.8.6'
        implementation files('libs/netty-all-4.1.50.Final.jar')

        // MobileIMSDKSDK
        implementation files('libs/MobileIMSDKServer_META.jar')
        implementation files('libs/MobileIMSDK4a_tcp.jar')
    }
}
你用这个完整的proguard文件内容覆盖进去再试试:
# 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();
}

评分

1

查看评分

签名: 假期就在眼前,舒服!
搞了几天的bug,终于在站长的帮助下,成功解决了。此方一用,药到病除!
真来神药!在此拜谢楼主万恩!!!
引用:QQ粉 发表于 2021-09-03 15:52
搞了几天的bug,终于在站长的帮助下,成功解决了。此方一用,药到病除!
真来神药!在此拜谢楼主万恩!! ...

签名: 假期就在眼前,舒服!
打赏楼主 ×
使用微信打赏! 使用支付宝打赏!

返回顶部