/app
/common
/customviews
/model
现在我想混淆我的代码用于生产,所以我在所有模块的所有build.gradle文件上添加以下行.
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
该文件包含以下规则:
-dontnote android.net.http.*
-dontnote org.apache.commons.codec.**
-dontnote org.apache.http.**
-dontwarn okhttp3.**
-dontwarn okio.**
-dontwarn javax.annotation.**
-dontwarn org.conscrypt.**
-dontwarn retrofit2.Platform$Java8
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
该应用程序编译正常,但运行时我得到以下异常:
b.g.b.a.ac: Incorrect resolution sequence for Java constructor public constructor a() defined in com.myexample.myapp.model.a.e.a[b@eb11a88] (b.g.b.a.a.d.a.f.a.j: class com.myexample.myapp.model.a.e.a)
at b.g.b.a.ai.a(UnkNown Source)
at b.g.b.a.o.Nown Source)
at b.g.b.a.l$a$e.b(UnkNown Source)
at b.g.b.a.l$a$e.a(UnkNown Source)
at b.g.b.a.ae$a.a(UnkNown Source)
at b.g.b.a.ae$c.a(UnkNown Source)
at b.g.b.a.l$a.e(UnkNown Source)
at b.g.b.a.l.h(UnkNown Source)
at b.g.a.c.a(UnkNown Source)
at com.b.a.r.a(UnkNown Source)
at com.b.a.v.a(UnkNown Source)
at com.b.a.d$1.a(UnkNown Source)
at com.b.a.d$1.a(UnkNown Source)
at com.b.a.v.a(UnkNown Source)
at e.b.a.a.a(UnkNown Source)
at e.n.a(UnkNown Source)
at e.n.b(UnkNown Source)
at e.o$a.c(UnkNown Source)
at e.o$a.a(UnkNown Source)
at e.n.a(UnkNown Source)
at e.n$1.invoke(UnkNown Source)
at java.lang.reflect.Proxy.invoke(Proxy.java:813)
at $Proxy1.a(UnkNown Source)
at com.myexample.myapp.model.b.a.d.a(UnkNown Source)
at com.myexample.myapp.ui.splash.Splashviewmodel.f(UnkNown Source)
at com.myexample.myapp.ui.splash.SplashActivity.k(UnkNown Source)
at com.myexample.myapp.ui.splash.SplashActivity.onCreate(UnkNown Source)
at android.app.Activity.performCreate(Activity.java:6912)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
at android.app.ActivityThread.performlaunchActivity(ActivityThread.java:2877)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2985)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1635)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6692)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
我顺便使用Kotlin.
编辑:新例外:
6-13 10:17:37.884 24129-24129/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myapp.android,PID: 24129
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.android/com.myapp.android.ui.splash.SplashActivity}: java.lang.IllegalArgumentException: Unable to create converter for class com.myapp.android.model.api.userprofile.UserProfile
for method d.a
at android.app.ActivityThread.performlaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(UnkNown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.IllegalArgumentException: Unable to create converter for class com.myapp.android.model.api.userprofile.UserProfile
for method d.a
at retrofit2.n$a.a(ServiceMethod.java:755)
at retrofit2.n$a.c(ServiceMethod.java:741)
at retrofit2.n$a.a(ServiceMethod.java:172)
at retrofit2.m.a(Retrofit.java:170)
at retrofit2.m$1.invoke(Retrofit.java:147)
at java.lang.reflect.Proxy.invoke(Proxy.java:913)
at $Proxy1.a(UnkNown Source)
at com.myapp.android.model.repository.impl.c.a(UserRepositoryImpl.kt:23)
at com.myapp.android.ui.splash.Splashviewmodel.f(Splashviewmodel.kt:20)
at com.myapp.android.ui.splash.SplashActivity.m(SplashActivity.kt:58)
at com.myapp.android.ui.splash.SplashActivity.onCreate(SplashActivity.kt:31)
at android.app.Activity.performCreate(Activity.java:7009)
at android.app.Activity.performCreate(Activity.java:7000)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performlaunchActivity(ActivityThread.java:2731)
... 9 more
Caused by: java.lang.IllegalStateException: Resource not found in classpath: kotlin/collections/collections.kotlin_builtins
at kotlin.reflect.jvm.internal.impl.builtins.BuiltInsPackageFragmentProviderKt.a(builtInsPackageFragmentProvider.kt:39)
at kotlin.reflect.jvm.internal.impl.builtins.KotlinBuiltIns.c(KotlinBuiltIns.java:138)
at kotlin.reflect.jvm.internal.impl.platform.JvmBuiltIns.arationContainerImpl$Data$moduleData$2.b(KDeclarationContainerImpl.kt:37)
at kotlin.reflect.jvm.internal.KDeclarationContainerImpl$Data$moduleData$2.a(KDeclarationContainerImpl.kt:34)
at kotlin.reflect.jvm.internal.ReflectProperties$LazySoftVal.a(ReflectProperties.java:93)
at kotlin.reflect.jvm.internal.ReflectProperties$Val.a(ReflectProperties.java:32)
at kotlin.reflect.jvm.internal.KDeclarationContainerImpl$Data.m(UnkNown Source:7)
at kotlin.reflect.jvm.internal.KClassImpl$Data$descriptor$2.b(KClassImpl.kt:42)
at kotlin.reflect.jvm.internal.KClassImpl$Data$descriptor$2.a(KClassImpl.kt:39)
at kotlin.reflect.jvm.internal.ReflectProperties$LazySoftVal.a(ReflectProperties.java:93)
at kotlin.reflect.jvm.internal.ReflectProperties$Val.a(ReflectProperties.java:32)
at kotlin.reflect.jvm.internal.KClassImpl$Data.a(UnkNown Source:7)
at kotlin.reflect.jvm.internal.KClassImpl.f(KClassImpl.kt:159)
at kotlin.reflect.jvm.internal.KClassImpl.b(KClassImpl.kt:173)
at kotlin.reflect.jvm.internal.KClassImpl$Data$constructors$2.b(KClassImpl.kt:86)
at kotlin.reflect.jvm.internal.KClassImpl$Data$constructors$2.a(KClassImpl.kt:39)
at kotlin.reflect.jvm.internal.ReflectProperties$LazySoftVal.a(ReflectProperties.java:93)
06-13 10:17:37.885 24129-24129/? E/AndroidRuntime: at kotlin.reflect.jvm.internal.ReflectProperties$Val.a(ReflectProperties.java:32)
at kotlin.reflect.jvm.internal.KClassImpl$Data.e(UnkNown Source:7)
at kotlin.reflect.jvm.internal.KClassImpl.i(KClassImpl.kt:192)
at kotlin.reflect.full.KClasses.a(KClasses.kt:40)
at com.squareup.moshi.k.a(KotlinjsonAdapter.kt:160)
at com.squareup.moshi.n.a(moshi.java:100)
at retrofit2.a.a.a.a(moshiConverterFactory.java:91)
at retrofit2.m.a(Retrofit.java:330)
at retrofit2.m.b(Retrofit.java:313)
at retrofit2.n$a.c(ServiceMethod.java:739)
... 22 more
最佳答案
Proguard仅与实际版本相关.因此,不要为每个模块添加minifyEnabled true,而只是将其添加到应用程序本身的发布配置中.
来自库的所有代码(无论是来自模块还是外部依赖)都将使用应用程序的代码进行模糊处理.
如果您有要与库共享的自定义规则,则可以将consumerProguardFiles的“proguard-rules.pro”定义为添加到AAR文件中.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。