【发布时间】:2017-12-05 16:38:09
【问题描述】:
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,我需要进行一些更改。
首先,在 gradle-wrapper.properties 中更新 Android Studio 3.0 的 Gradle 版本:
distributionUrl=\ https://services.gradle.org/distributions/gradle-4.1-all.zip (我认为等号后面的反斜杠是错误的,并没有做出改变。)
第二,在build.gradle中添加如下buildscript仓库:
谷歌()
第三,更改build.gradle依赖:
类路径'com.android.tools.build:gradle:3.0.1'
第二个和第三个更改应用了最新版本的 Android 插件。
当我在这些更改后尝试同步时,它再次失败并出现以下新错误:
未找到 ID 为“com.android.model.application”的插件。
错误指的是build.gradle的第一行:
应用插件:'com.android.model.application'
发生了什么,为什么?我最近将 NDK 添加到 Android Studio。我尝试同步的项目包括 C 代码。我不完全确定我正确添加了 NDK。我想知道这是否是问题的一部分。
【问题讨论】:
-
新建项目同步成功了吗?
-
是的,它似乎可以正确同步,但是没有为 C 代码设置常规项目。所以我尝试了“启用 C++ 支持”。这似乎也正确同步。我再次担心这是我的 NDK 设置的问题。如何使用 C 而不是 C++ 支持开始一个新项目?