Gradle项目同步失败,没有得到其他相关问题的答案 . 以下是我的情况详情 .
初始同步尝试产生以下错误消息:
Unsupported method: BaseConfig.getApplicationIdSuffix().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.
我有Android Studio 3.0 . build.gradle文件包含以下依赖项:
classpath 'com.android.tools.build:gradle-experimental:0.2.1'
The gradle-wrapper.properties file includes the following distribution URL:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip
根据https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#update_gradle我需要做一些改变 .
First ,在gradle-wrapper.properties中更新Android Studio 3.0的Gradle版本:
distributionUrl = \ https://services.gradle.org/distributions/gradle-4.1-all.zip(我相信等号后面的反斜杠是一个错误,并没有做出改变 . )
Second ,将以下buildscript存储库添加到build.gradle:
谷歌()
Third ,更改build.gradle依赖项:
classpath'com.android.tools.build:grad:3.0.1'
第二次和第三次更改将应用最新版本的Android插件 .
当我尝试在这些更改后进行同步时,它会再次失败并出现以下新错误:
没有找到id为'com.android.model.application'的插件 .
该错误指的是build.gradle的第一行:
apply plugin:'com.android.model.application'
发生了什么,为什么?我最近将NDK添加到Android Studio . 我正在尝试同步的项目包括C代码 . 我不完全确定我正确添加了NDK . 我想知道这是不是问题的一部分 .
4 回答
首先,
gradle-wrapper.properties
不正确 . 您必须在其中包含\
. 它应该是这样的:然后,将实验类路径添加到项目build.gradle . 像这样的东西:
有关详细信息,请查看Experimental Plugin User Guide .
Go to your build.gradle version or update it
确保您的Gradle版本与Android Gradle插件兼容 .
https://stackoverflow.com/questions/24795079
https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
你应该改变你
dependencies
classpath
All steps are here :
打开build.gradle并将gradle版本更改为推荐版本:
classpath 'com.android.tools.build:gradle:1.3.0'
来classpath 'com.android.tools.build:gradle:2.3.2'
点击
'Try Again'
在消息框中它会说
'Fix Gradle Wrapper and re-import project'
点击它,因为最小的gradle版本是3.3
会弹出一个新错误并说
The SDK Build Tools revision (23.0.1) is too low for project ':app'. Minimum required is 25.0.0
- 点击Update Build Tools version and sync project
可能会弹出一个窗口,显示
Android Gradle Plugin Update recommended
,只是从那里更新 .现在,项目应该可以在任何Android虚拟设备上运行 .