混淆问题
问题描述
打包混淆的时候报错:
kotlin.time.jdk8.DurationConversionsJDK8Kt: can't find referenced method 'double getSeconds(long)' in program class kotlin.time.DurationKt
kotlin.time.jdk8.DurationConversionsJDK8Kt: can't find referenced method 'double getNanoseconds(int)' in program class kotlin.time.DurationKt
kotlin.time.jdk8.DurationConversionsJDK8Kt: can't find referenced method 'double plus-LRDsOJo(double,double)' in program class kotlin.time.Duration
kotlin.time.jdk8.DurationConversionsJDK8Kt: can't find referenced method 'double getInSeconds-impl(double)' in program class kotlin.time.Duration
kotlin.time.jdk8.DurationConversionsJDK8Kt: can't find referenced method 'int getNanosecondsComponent-impl(double)' in program class kotlin.time.Duration
Warning: there were 5 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile the code.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)
there were 5 unresolved references to program class members.
> Task :app:minifyReleaseWithProguard FAILED
查问题
全局搜索报错类:DurationConversionsJDK8Kt,搜索项目选择 Scope.
从而找到kt类:DurationConversions.kt,从标题栏可知(见下图),该类来自jar包:org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.20
在Android Studio的Project窗口选择porject视图(见下图)。
打开External Libraries选项(见下图),找到上述的类org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.20。
从下图可以看到,两个不同版本的stdlib,有可能就是找不到对应解析方法的原因。那么现在问题是让这两个版本统一
解决
使用相同版本的stdlib,解决问题。
在build.gradle(App)模块中添加引用:
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
在build.gradle(porject)中添加引用
buildscript {
ext.kotlin_version = '1.5.10'
repositories {
//...
}
dependencies {
//...
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
|