0

这是我在尝试Gradle SyncAndroid Studio时遇到的确切错误。当新版本的Gradle对话框出现时,我所做的只是点击更新按钮。单击更新后单击Gradle同步Android Studio中的Gradle - 错误:Gradle 2.14.1需要Android Gradle插件2.1.3(或更高版本)

Error:Gradle 2.14.1 requires Android Gradle plugin 2.1.3 (or newer) but project is using version 2.1.0. <a href="fixGradleElements">Upgrade plugin to version 2.3.0 and sync project</a><br><a href="https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle">Open Documentation</a>

这是我的主分支我知道建立/与其他人同步。

项目生成文件

// This is used to improve build server performance by disable pre-dexing when building. 
// To enable this feature, use "./gradlew clean assemble -PdisablePreDex" 
// Refer: http://tools.android.com/tech-docs/new-build-system/tips 
project.ext.preDexLibs = !project.hasProperty('disablePreDex') 
subprojects { 
    project.plugins.whenPluginAdded { plugin -> 
     if ("com.android.build.gradle.AppPlugin".equals(plugin.class.name)) { 
      project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs 
     } else if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) { 
      project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs 
     } 
    } 
} 

// This is used to control Android properties of all modules from the main project. 
// Refer: http://tools.android.com/tech-docs/new-build-system/tips 
ext { 
    compileSdkVersion = 24 
    buildToolsVersion = '24' 
    gradleBuildToolClassPath = 'com.android.tools.build:gradle:2.2.2' 
} 

buildscript { 
    repositories { 
     mavenCentral() 
     jcenter() 
    } 
    dependencies { 
     classpath "io.realm:realm-gradle-plugin:1.2.0" 
     classpath "com.google.gms:google-services:3.0.0" 
    } 
} 

应用程序生成的文件

buildscript { 
    repositories { 
     jcenter() 
     maven { url 'https://maven.fabric.io/public' } 
    } 
    dependencies { 
     classpath rootProject.ext.gradleBuildToolClassPath 
     classpath 'io.fabric.tools:gradle:1.+' 
    } 
} 
apply plugin: 'com.android.application' 
apply plugin: 'io.fabric' 
apply plugin: 'realm-android' 

repositories { 
    jcenter() 
    maven { url 'https://maven.fabric.io/public' } 
    flatDir { 
     dirs 'libs' 
    } 
} 

dependencies { 
    // Projects 
    releaseCompile project(path: ':LibProjects:Android-Library', configuration: 'release') 
    debugCompile project(path: ':LibProjects:Android-Library', configuration: 'debug') 
    compile project(':LibProjects:photoview') 
    compile project(':LibProjects:viewpagerindicator') 

    // Maven libraries 
    compile 'com.google.firebase:firebase-messaging:10.0.1' 
    compile 'com.android.support:support-v4:24.0.0' 
    compile 'com.android.support:gridlayout-v7:24.0.0' 
    compile 'com.android.support:design:24.0.0' 
    compile 'com.android.support:preference-v7:24.0.0' 
    compile 'com.android.support:recyclerview-v7:24.0.0' 
    compile 'com.android.support:multidex:1.0.1' 
    compile 'com.google.android.gms:play-services-gcm:10.0.1' 
    compile 'com.google.android.gms:play-services-ads:10.0.1' 
    compile 'com.google.android.gms:play-services-location:10.0.1' 
    compile 'com.edmodo:rangebar:1.0.0' 
    compile 'com.edmodo:cropper:1.0.1' 
    compile 'com.nineoldandroids:library:2.4.0' 
    compile 'com.squareup.okhttp:okhttp-urlconnection:+' 
    compile 'com.tonicartos:stickygridheaders:1.0.1' 
    compile 'com.intellij:annotations:[email protected]' 
    compile 'com.mixpanel.android:mixpanel-android:4.5.3' 
    compile 'com.splitwise:tokenautocomplete:[email protected]' 
    compile('com.crashlytics.sdk.android:crashlytics:[email protected]') { transitive = true; } 
    compile 'com.github.clans:fab:1.6.4' 
    compile ('com.facebook.android:audience-network-sdk:4.6.0') { exclude group: 'com.google.android.gms' } 
    compile('com.mopub:mopub-sdk-base:[email protected]') 
    compile('com.mopub:mopub-sdk-native-static:[email protected]') 

    // File libraries 
    compile fileTree(dir: 'libs', include: '*.jar') 
    compile(name:'adsnative-sdk-2.5.3', ext:'aar') 

    // Testing 
    androidTestCompile 'com.android.support:support-annotations:24.0.0' 
    androidTestCompile 'com.android.support.test:runner:0.5' 
} 

android { 
    compileSdkVersion rootProject.ext.compileSdkVersion 
    buildToolsVersion rootProject.ext.buildToolsVersion 

    defaultConfig { 
     applicationId "com.fusionprojects.edmodo" 
     minSdkVersion 15 
     targetSdkVersion rootProject.ext.compileSdkVersion 
     versionCode 50111 
     versionName "6.5.2" 
     proguardFile getDefaultProguardFile('proguard-android.txt') 
     vectorDrawables.useSupportLibrary = true 
     multiDexEnabled true 
     testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner' 
    } 

    packagingOptions { 
     // These statements are required for solving a very annoying gradle build error: 
     // "Duplicate files copied in APK META-INF/DEPENDENCIES" 
     // Refer: http://blog.csdn.net/zhouzme/article/details/18923293 
     exclude 'META-INF/DEPENDENCIES' 
     exclude 'META-INF/NOTICE' 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/DEPENDENCIES.txt' 
     exclude 'META-INF/LICENSE.txt' 
     exclude 'META-INF/NOTICE.txt' 
    } 

    sourceSets { 
     main { 
      manifest.srcFile 'AndroidManifest.xml' 
      java.srcDirs = ['src'] 
      resources.srcDirs = ['src'] 
      aidl.srcDirs = ['src'] 
      res.srcDirs = ['res'] 
      assets.srcDirs = ['assets'] 
     } 

     // Move the build types to build-types/<type> 
     // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... 
     // This moves them out of them default location under src/<type>/... which would 
     // conflict with src/ being used by the main source set. 
     // Adding new build types or product flavors should be accompanied 
     // by a similar customization. 
     debug.setRoot('build-types/debug') 
     release.setRoot('build-types/release') 

     // Testing 
     androidTest.setRoot('androidTest') 
    } 

    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFile file('proguard-project.txt') 
      signingConfig signingConfigs.releaseConfig 
     } 
    } 

    dexOptions { 
     javaMaxHeapSize "4g" 
     jumboMode true 
    } 

    lintOptions { 
     abortOnError false 
    } 
} 

apply plugin: 'com.google.gms.google-services' 

摇篮包装器

#Tue Sep 06 16:30:01 PDT 2016 
distributionBase=GRADLE_USER_HOME 
distributionPath=wrapper/dists 
zipStoreBase=GRADLE_USER_HOME 
zipStorePath=wrapper/dists 
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 
+0

您是否尝试点击以下链接: “将插件升级到版本2.3.0并同步项目”? – krlos77

+0

@ krlos77是的,它给了我一个不同的错误。 '错误:org.gradle.api.internal.tasks.DefaultTaskInputs $ TaskInputUnionFileCollection无法转换为org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection'并给了我'重新下载依赖关系和同步'或'停止gradle构建过程'。两者都不能解决问题。 –

+0

尝试更改此行: classpath“io.realm:realm-gradle-plugin:1.2.0” for this: classpath'com.android.tools.build:gradle:2.3.0-rc1' – krlos77

回答

1

你可以试试这个:

进入 - >gradle.wrapper.properties

,并与该更换分配地址:

distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-all.zip 

希望这有助于!

相关问题