不推荐使用的Gradle功能使其与Gradle 5.0不兼容。 Android Studio 3.2

时间:2019-01-15 04:01:06

标签: android android-studio gradle

由于我将android studio更新为3.2,因此我的android应用Gradle版本无法同步。我已经更新了依赖项中的所有内容,但仍然收到相同的错误。这是我使用的依赖文件(包括第三方库)

    apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "myappid"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 32
        versionName "3.2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                    'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.11"
    implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
    implementation 'com.android.support:design:28.0.0-alpha1'
    implementation 'com.android.support:recyclerview-v7:28.0.0-alpha1'
    implementation 'com.android.support:cardview-v7:28.0.0-alpha1'
    implementation 'com.android.support:support-v4:28.0.0-alpha1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.firebase:firebase-crash:28.0.0-alpha1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation "org.jetbrains.anko:anko:$anko_version"
    implementation 'com.github.GrenderG:Toasty:1.2.5'
    implementation 'com.github.scottyab:showhidepasswordedittext:0.8'
    implementation 'com.daimajia.easing:library:2.1@aar'
    implementation 'com.daimajia.androidanimations:library:2.3@aar'
    implementation 'com.google.android.gms:play-services-ads:17.1.2'
    implementation 'com.google.gms:google-services:4.2.0'
    implementation 'com.github.sd6352051:NiftyDialogEffects:v1.0.3'
    implementation 'net.steamcrafted:load-toast:1.0.12'
    implementation 'com.android.support:animated-vector-drawable:28.0.0-alpha1';

}


//apply plugin: 'com.google.gms.google-services'
//classpath 'com.google.gms:google-services:4.2.0'

但是,出现以下错误 在此版本中使用了不推荐使用的Gradle功能,使其与Gradle 5.0不兼容。 使用“ --warning-mode all”来显示各个弃用警告。

我已经尝试了大多数可通过Google / Youtube搜索获得的功能。也实现了StackOverflow中给出的一些答案。但归根结底,这是同样的错误。我所缺少的。

请咨询,如何解决此问题。谢谢

5 个答案:

答案 0 :(得分:3)

因此问题不一定存在于您的应用程序级别的build.gradle脚本(您发布的脚本)中。它也可以在项目一级,甚至在maven-publish-aar.gradle一级(如果有)。这意味着,您可以在任何Gradle脚本上使用不推荐使用的Gradle功能。

  

我已经更新了依赖项中的所有内容,并且仍然遇到相同的错误。

最有可能的是,一旦您识别并替换了所有引起您麻烦的Gradle功能,该警告就会消失。为此,它将帮助您将提到的 ArrayList<Bill> result = new ArrayList<>(); for(Bill bill: listBill) { for(Detail detail : listDetail) { if(bill.getCode() == detail.getBillId().getCode() { result.add(bill); } } } 标志添加到Gradle命令行选项中(在Android Studio编译器设置中):

enter image description here 这样会打印出适当的警告,以提醒您您的应用正在使用的特定不推荐使用的功能。

例如,我只是在settings.gradle文件中添加了--warning-mode=all设置,这很神奇(我正在使用enableFeaturePreview('STABLE_PUBLISHING'))。

此外,我知道您在一个月前问过这个问题,但是,这对于面临相同问题的其他人可能很有用。

答案 1 :(得分:2)

问题是由于外部依赖项的不一致。 通过迁移到Yarn Package Manager,可以轻松解决该问题

  1. 删除节点模块

  2. 删除Package.json.lock

  3. yarn install

尝试删除android / app / build文件夹

通过react-native run-android

运行项目

答案 2 :(得分:0)

昨天有同样的问题扩展到了@Hugo Allexis Cardona的答案,即使在替换具有相同问题的不推荐使用的Gradle功能后,也仍然存在,因为旧版本文件夹仍然存在,所以我要做的是删除应用程序/版本文件夹并同步再次摇晃,它为我工作感谢@Hugo Allexis Cardona

  

删除应用程序/构建文件夹

答案 3 :(得分:0)

我找到了解决此问题的最简单方法。转到projectName / android目录,然后在终端中输入以下命令

./gradlew clean

然后,通过输入以下命令进入主项目目录

cd ..

然后启动项目

react-native run-android

答案 4 :(得分:0)

就我而言

  1. 我关注了Hugo's answer

  2. 更改了项目的位置。

  3. 尝试了另一个Android设备[构建并成功安装]

  4. 在我的Android设备上尝试[构建并成功安装]