【问题标题】:exifinterface Build error about androidX but i don't migrate to androidXexifinterface 构建有关 androidX 的错误,但我没有迁移到 androidX
【发布时间】:2019-01-26 12:30:46
【问题描述】:

当我尝试构建应用程序时,它在构建选项卡上给了我这个错误

找到多个文件,其独立于操作系统的路径为“META-INF/androidx.exifinterface_exifinterface.version”

而且我没有在我的任何模块中使用 AndroidX

我也将此添加到我的build.gradle

packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/proguard/androidx-annotations.pro'
    }

dependencies

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')

    implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
    implementation "com.android.support:design:$supportLibraryVersion"
    implementation "com.android.support:cardview-v7:$supportLibraryVersion"
    implementation "com.android.support:exifinterface:$supportLibraryVersion"
    implementation "com.android.support:support-media-compat:$supportLibraryVersion"
    implementation "com.android.support:support-v4:$supportLibraryVersion"

}

【问题讨论】:

  • Build error when migrate to androidX 你没有。您仍然使用旧的支持库依赖项。首先转到菜单 Refactor > Migrate to AndroidX。完成后,如果您仍有问题,请返回此处并更新您的问题。

标签: android gradle android-gradle-plugin build.gradle androidx


【解决方案1】:

必须将此行添加到我的packagingOptions

exclude 'META-INF/androidx.exifinterface_exifinterface.version'

所以我的packagingOptions改成这样

packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'
    exclude 'META-INF/proguard/androidx-annotations.pro'
    exclude 'META-INF/androidx.exifinterface_exifinterface.version'
}

【讨论】:

  • 我在我的项目中使用 exif 接口,不需要排除任何东西。解决你的问题,而不是隐藏它。这意味着 exif 接口多次捆绑在您的应用程序中,可能一次来自 AndroidX,一次来自旧支持库。我不确定。您可以分析您的 APK。
【解决方案2】:

但您没有将 gradles 更改为 Android X 库。只需将整个项目迁移到 Android X。

【讨论】:

  • Just migrate whole project to Android X. 避免使用 justsimply。如果一切都那么简单,这个网站就不会存在。解释如何去做。举例说明它最终的样子。
  • @TakeInfo,你写我根本不用androidX!但为什么给我 AndroidX 错误我不知道
  • 然后检查你的 gradle.properties 文件是否存在“android.enableJetifier=true android.useAndroidX=true”这两个标志。
猜你喜欢
  • 2019-11-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-12-10
  • 1970-01-01
  • 1970-01-01
  • 2020-02-03
相关资源
最近更新 更多