以下の環境でCordova Androidアプリを
-
Cordova: 8.0.0
-
Android: Studio 3.1.3
-
Java: Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
cordova build android
でビルドすると…
以下のようなエラーが出る
Minimum supported Gradle version is 4.4. Current version is 4.1. If using the gradle wrapper
こちらの投稿によるとGradleのバージョンが違うということなので、
https://qiita.com/mana-bin/items/eaa0c2c2335140e3f707
[PROJECT_ROOT]/platforms/android/cordova/lib/builders/GradleBuilder.js
のL240辺りを以下のように改訂すると解消できた。
var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\\://services.gradle.org/distributions/gradle-4.4-all.zip';
まだ、以下のエラーが残っていたので、
A problem occurred evaluating project ':CordovaLib'.
> Plugin with id 'com.github.dcendents.android-maven' not found.
以下の二つのファイルを
-
[PROJECT_ROOT]\platforms\android\CordovaLib\build.gradle
-
[PROJECT_ROOT]\node_modules\cordova-android\framework\build.gradle
以下のように変更すると解消できた。
修正前
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
}
修正後
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
}
デフォルト値が間違っているのは分かりにくい。。