【问题标题】:Configuration 'compile' is obsolete and has been replaced with 'implementation'. It will be removed at the end of 2018 [duplicate]配置“编译”已过时,已替换为“实现”。它将在2018年底被删除[重复]
【发布时间】:2018-09-17 08:32:22
【问题描述】:

在 Android Studio 3.1 版本中,依赖项编译字被替换为实现。 android studio 3.1 中带有警告的依赖项:

dependencies { 
compile fileTree(dir: 'libs', include: ['*.jar']) 
compile 'com.android.support:appcompat-v7:27.1.0' 
compile 'com.android.support.constraint:constraint-layout:1.0.2'

【问题讨论】:

    标签: android android-studio


    【解决方案1】:
     buildTypes {
            release {
    //            shrinkResources true
    //            minifyEnabled true
                proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
            }
        }
    

    评论 shrinkResources trueminifyEnabled true 它对我有用

    【讨论】:

      【解决方案2】:

      由于错误状态,您必须在依赖项中将 compile 替换为 implementation,因为 compile 已过时。

      例如请检查here

      【讨论】:

        【解决方案3】:

        警告是因为 Gradle 3.4(Android Studio 3.1 使用 Gradle >= 4.6)是introducing new configurations

        Gradle 3.4 引入了新的 Java 库插件配置, 允许您控制是否将依赖项发布到编译 以及使用该库的项目的运行时类路径。这 Android 插件正在采用这些新的依赖配置,并且 迁移大型项目以使用它们可以大大减少构建 次。下表可帮助您了解哪些配置 你应该使用。

        正如警告所说,compile 配置将在 2018 年底从 gradle 中删除。

        【讨论】:

          【解决方案4】:

          将 (Module:app) 中的所有 'compile' 替换为 'implementation' (在你的代码中它看起来像这样):

          implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:27.1.0' implementation 'com.android.support.constraint:constraint-layout:1.0.2'

          【讨论】:

            猜你喜欢
            • 2018-10-28
            • 1970-01-01
            • 1970-01-01
            • 2019-12-06
            • 2018-11-24
            • 1970-01-01
            • 2019-08-19
            • 2018-11-30
            • 2018-07-15
            相关资源
            最近更新 更多