在发布版本中找不到androidx.annotation.ContentView

问题描述 投票:2回答:1

我正试图在发布模式下测试我的应用程序,我在我的proguard配置中有这个:

-keep class androidx.annotation.**

然而应用程序总是崩溃:

java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/annotation/ContentView;
    at androidx.activity.ComponentActivity.onCreate(ComponentActivity.java:123)
    at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:275)
    at androidx.appcompat.app.AppCompatActivity.onCreate(AppCompatActivity.java:85)

怎么了?

android android-proguard
1个回答
0
投票

我疯了,试图找出为什么我突然得到了这个错误。在深入了解我的模块的build.gradle后,我注意到了这一点,我甚至不记得我必须强制执行这些解决策略的原因。

configurations.all {
    resolutionStrategy {
        force deps.kotlin.stdlib
        force deps.androidx.annotation <-- REMOVE THIS LINE
    }
}

删除force deps.androidx.annotation解决了这个问题!

作为参考,这些是值

kotlin.stdlib = "org.jetbrains.kotlin:kotlin-stdlib:$versions.kotlin"
androidx.annotation = "androidx.annotation:annotation:$versions.annotation"

这是某种与androidx不兼容的bug。

希望这可以帮助!


0
投票

ContenView刚刚添加到androidx.annotation:annotation library。并将成为1.1.x版本的一部分

所以解决方案是使用最新的注释库,这是在编写1.1.0-rc1时

implementation 'androidx.annotation:annotation:1.1.0-rc01'

请参阅相关提交了解详情。 Android Open Source Project - Add a @ContentView annotation to ComponentActivity, Fragment

© www.soinside.com 2019 - 2024. All rights reserved.