在Android Studio中单击update Gradle后无法进行Gradle同步-错误:Gradle 2.14.1需要Android Gradle插件2.1.3(或更新版本)
这正是我在在Android Studio中单击update Gradle后无法进行Gradle同步-错误:Gradle 2.14.1需要Android Gradle插件2.1.3(或更新版本),android,gradle,android-gradle-plugin,gradle-plugin,android-studio-2.3,Android,Gradle,Android Gradle Plugin,Gradle Plugin,Android Studio 2.3,这正是我在Android Studio中尝试Gradle Sync时遇到的错误。我所做的只是在出现较新版本的Gradle对话框时单击更新按钮 错误:Gradle2.14.1需要Android Gradle插件2.1.3(或更新版本),但project使用的是2.1.0版。 这是我的主分支,我知道它与其他人构建/同步 项目生成文件 // This is used to improve build server performance by disable pre-dexing when bu
Android Studio
中尝试Gradle Sync
时遇到的错误。我所做的只是在出现较新版本的Gradle对话框时单击更新按钮
错误:Gradle2.14.1需要Android Gradle插件2.1.3(或更新版本),但project使用的是2.1.0版。
这是我的主分支,我知道它与其他人构建/同步
项目生成文件
// 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:+@jar'
compile 'com.mixpanel.android:mixpanel-android:4.5.3'
compile 'com.splitwise:tokenautocomplete:2.0.7@aar'
compile('com.crashlytics.sdk.android:crashlytics:2.5.7@aar') { 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:4.11.0@aar')
compile('com.mopub:mopub-sdk-native-static:4.11.0@aar')
// 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'
应用程序生成文件
// 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:+@jar'
compile 'com.mixpanel.android:mixpanel-android:4.5.3'
compile 'com.splitwise:tokenautocomplete:2.0.7@aar'
compile('com.crashlytics.sdk.android:crashlytics:2.5.7@aar') { 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:4.11.0@aar')
compile('com.mopub:mopub-sdk-native-static:4.11.0@aar')
// 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'
你可以试试这个:
转到-->gradle.wrapper.properties
并将分发Url替换为以下内容:
distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-all.zip
希望这有帮助 你有没有试过点击“将插件升级到2.3.0版并同步项目”的链接?@krlos77是的,它给了我一个不同的错误<代码>错误:org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection无法强制转换为org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection,并提供了
重新下载依赖项和同步
或停止gradle构建过程
的选项。两者都不能解决问题。请尝试更改这一行:classpath“io.realm:realm gradle plugin:1.2.0”,改为:classpath'com.android.tools.build:gradle:2.3.0-rc1'我也遇到了同样的问题检查我的所有需要做的就是下载最新的gradle版本!