12
8

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.

ビルド時にCould not find an installed version of Gradle either in Android Studio...が出る場合の対処法

Last updated at Posted at 2018-04-03

はじめに

Cordova 8.0.0
Android Studio 3.2 Preview
cordova-android 7.0.0

cordova build androidを実行した時にエラーが発生した。

cordova build android
Android Studio project detected
ANDROID_HOME=/Users/bin/android-sdk/
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home
studio
(node:55883) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle 
in your path, or install Android Studio
(node:55883) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

cordova emulate androidでもcordova run androidでも同じエラーが出る。
なんかわからんけど、Android Studioのgradleが発見できないみたい。以下で解決した。

以下を.profileに追加してgradleのパスを通す

export PATH="/Applications/Android Studio 3.2 Preview.app/Contents/gradle/gradle-4.5/bin":$PATH

設定を反映する

source ~/.profle
gradle -v
------------------------------------------------------------
Gradle 4.5
------------------------------------------------------------

Build time:   2018-01-24 17:04:52 UTC
Revision:     77d0ec90636f43669dc794ca17ef80dd65457bec

Groovy:       2.4.12
Ant:          Apache Ant(TM) version 1.9.9 compiled on February 2 2017
JVM:          1.8.0_101 (Oracle Corporation 25.101-b13)
OS:           Mac OS X 10.13.3 x86_64

gradleのパスが通ったら再ビルドしてみる。

cordova build android

...(中略)...

BUILD SUCCESSFUL in 10s
47 actionable tasks: 47 executed
Built the following apk(s): 
	/Users/work/test/platforms/android/app/build/outputs/apk/debug/app-debug.apk

正常にビルドできた。

まとめ

cordova platform add androidで追加されるのがcordova-android@7.0.0の場合にこのエラーが出る。

cordova create test com.bathtimefish.test Test
cd test
cordova platform add android@6.2.3
cordova build

とした場合はエラーは出ない。7.0.0からgradleの扱いが変わってるのか?

12
8
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
12
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?