0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CordovaでAndroidをビルドするときにはまったこと

Posted at

以下の環境で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'
    }

デフォルト値が間違っているのは分かりにくい。。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?