為一個Gradle版本相關的錯誤點解決方法作記錄
近日在Android Studio 3.0.1開啟一個幾年前的Android App Project出現以下error
:
Error: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.
Buildscript 內的dependencies是:
classpath 'com.android.tools.build:gradle:1.2.2'
我先嘗試在Project Structure 把Gradle Version改成 4.1
接着出現這訊息:
Error:(1, 0) Gradle version 2.2 is required. Current version is 4.1.
Please fix the project's Gradle settings.
Fix Gradle wrapper and re-import project Gradle settings
要我降回2.2 ?!
a
Error:Could not find com.android.tools.build:gradle:4.1.
Searched in the following locations:
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/4.1/gradle-4.1.pom
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/4.1/gradle-4.1.jar
https://jcenter.bintray.com/com/android/tools/build/gradle/4.1/gradle-4.1.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/4.1/gradle-4.1.jar
Required by:
project :
Add Google Maven repository and sync project Open File
然後我把dependencies改成:
classpath 'com.android.tools.build:gradle:3.0.1'
有關Gradle 的錯誤總算告一段落了。