Makes CLI build play nice along with Android Studio#224
Closed
saharshtibrewal wants to merge 1 commit intoapache:masterfrom
Closed
Makes CLI build play nice along with Android Studio#224saharshtibrewal wants to merge 1 commit intoapache:masterfrom
saharshtibrewal wants to merge 1 commit intoapache:masterfrom
Conversation
Recently, I had had an issue after opening my cordova project with Android Studio whereby the cordova build android command would constantly give me this error message.
Running command: /Users/Developer/app/hooks/after_prepare/010_add_platform_class.js /Users/Developer/app
add to body class: platform-android
Running command: /Users/Developer/app/platforms/android/cordova/build
ANDROID_HOME=/usr/local/Cellar/android-sdk/24.3.4
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home
Running: /Users/Developer/app/platforms/android/gradlew cdvBuildDebug -b /Users/Developer/app/platforms/android/build.gradle -Dorg.gradle.daemon=true
:preBuild FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':preBuild'.
> failed to find Build Tools revision 23.0.1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 5.131 secs
/Users/Developer/app/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/Developer/app/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/Developer/app/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/Developer/app/platforms/android/cordova/build: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: /Users/Developer/app/platforms/android/cordova/build: Command failed with exit code 1
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:139:23)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:818:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
Even though, I had all the build tools installed and everything, this issue started happening with the latest version of Android Studio. After a lot of debugging and almost giving up.
I found that the issue was happening due to local.properties file generated by Android Studio and the sdk.dir being specified in it. This change to the build script is not a permanent fix, there is something else wrong with the build process that stops it from finding the build tools.(FYI only cordova build android had this issue, a command-line based gradlew assemble task ran perfectly well).
But, this change does ensure that you can use terminal based cordova build android and you can still run and debug your app from the Android Studio as the file "local.properties" is restored afterwards.
There may be some more investigation needed to find out why the cordova build process does not work with local.properties or if this is an isolated issue that is happening on my dev environment only. This is just a temporary and quick fix to get your cordova build android working if you are also using Android Studio.
Author
|
File Exists Check missing. Will add and resubmit. |
Author
|
Submitted a new one: #225 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Recently, I had had an issue after opening my cordova project with Android Studio whereby the cordova build android command would constantly give me this error message.
Running command: /Users/Developer/app/hooks/after_prepare/010_add_platform_class.js /Users/Developer/app
add to body class: platform-android
Running command: /Users/Developer/app/platforms/android/cordova/build
ANDROID_HOME=/usr/local/Cellar/android-sdk/24.3.4
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home
Running: /Users/Developer/app/platforms/android/gradlew cdvBuildDebug -b /Users/Developer/app/platforms/android/build.gradle -Dorg.gradle.daemon=true
:preBuild FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':preBuild'.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 5.131 secs
/Users/Developer/app/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/Developer/app/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/Developer/app/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/Developer/app/platforms/android/cordova/build: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: /Users/Developer/app/platforms/android/cordova/build: Command failed with exit code 1
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:139:23)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:818:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
Even though, I had all the build tools installed and everything, this issue started happening with the latest version of Android Studio. After a lot of debugging and almost giving up.
I found that the issue was happening due to local.properties file generated by Android Studio and the sdk.dir being specified in it. This change to the build script is not a permanent fix, there is something else wrong with the build process that stops it from finding the build tools.(FYI only cordova build android had this issue, a command-line based gradlew assemble task ran perfectly well).
But, this change does ensure that you can use terminal based cordova build android and you can still run and debug your app from the Android Studio as the file "local.properties" is restored afterwards.
There may be some more investigation needed to find out why the cordova build process does not work with local.properties or if this is an isolated issue that is happening on my dev environment only. This is just a temporary and quick fix to get your cordova build android working if you are also using Android Studio.