Open dpcunningham opened 4 years ago
$ANDROID_HOME
and javac
are MIA.After what looked to be an adequate "low-to-zero-guidance" install of Android Studio and Oracle JDK...
$ ionic cordova build android
ng run app:ionic-cordova-build --platform=android Browserslist: caniuse-lite is outdated. Please run next command
npm update
chunk {0} 0-es2015.js, 0-es2015.js.map () 13.2 kB [rendered] chunk {1} 1-es2015.js, 1-es2015.js.map () 20 kB [rendered] chunk {2} 2-es2015.js, 2-es2015.js.map () 17 kB [rendered] [...] chunk {77} 77-es2015.js, 77-es2015.js.map () 20.2 kB [rendered] chunk {common} common-es2015.js, common-es2015.js.map (common) 24.8 kB [rendered] chunk {cordova} cordova.js, cordova.js.map (cordova) 63.5 kB [entry] [rendered] chunk {core-js-js} core-js-js-es2015.js, core-js-js-es2015.js.map (core-js-js) 78.7 kB [rendered]
[...] chunk {vendor} vendor-es2015.js, vendor-es2015.js.map (vendor) 4.48 MB [initial] [rendered] Date: 2019-12-24T05:34:12.678Z - Hash: 0feb3050d41512cff93f - Time: 27691ms
chunk {0} 0-es5.js, 0-es5.js.map () 15.4 kB [rendered] chunk {1} 1-es5.js, 1-es5.js.map () 15.2 kB [rendered] chunk {2} 2-es5.js, 2-es5.js.map () 16.3 kB [rendered] [...] chunk {78} 78-es5.js, 78-es5.js.map () 23.3 kB [rendered] chunk {common} common-es5.js, common-es5.js.map (common) 14.7 kB [rendered] chunk {cordova} cordova.js, cordova.js.map (cordova) 63.5 kB [entry] [rendered] chunk {core-js-js} core-js-js-es5.js, core-js-js-es5.js.map (core-js-js) 78.7 kB [rendered] [...] lick-ca00ce7f-js) 6.32 kB [rendered] chunk {vendor} vendor-es5.js, vendor-es5.js.map (vendor) 4.59 MB [initial] [rendered] Date: 2019-12-24T05:34:44.577Z - Hash: 83fb460ffa563851227c - Time: 31416ms
cordova build android Failed to find 'ANDROID_HOME' environment variable. Try setting it manually. Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory. [ERROR] An error occurred while running subprocess cordova.
cordova build android exited with exit code 1. Re-running this command with the --verbose flag may provide more information.
$ vi ~/.profile
$ source ~/.profile
$ echo $PATH
/home/dpc/dpc.data/local.FS/lfs.00-Scratch/install.android.studio/android-studio/bin
:/home/dpc/dpc.data/local.FS/lfs.00-Scratch/install.android.studio/android-studio
:/home/dpc/.local/bin
:/home/dpc/dpc.data/local.FS/lfs.00-Scratch/install.android.studio/android-studio/bin
:/home/dpc/.local/bin:/home/dpc/.local/bin:/usr/local/sbin
:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
$ echo $ANDROID_HOME
/home/dpc/dpc.data/local.FS/lfs.00-Scratch/install.android.studio/android-studio
$ ionic cordova build android
ng run app:ionic-cordova-build --platform=android Browserslist: caniuse-lite is outdated. Please run next command
npm update
chunk {0} 0-es2015.js, 0-es2015.js.map () 13.2 kB [rendered] chunk {1} 1-es2015.js, 1-es2015.js.map () 20 kB [rendered] chunk {2} 2-es2015.js, 2-es2015.js.map () 17 kB [rendered] [...] chunk {77} 77-es2015.js, 77-es2015.js.map () 20.2 kB [rendered] chunk {common} common-es2015.js, common-es2015.js.map (common) 24.8 kB [rendered] chunk {cordova} cordova.js, cordova.js.map (cordova) 63.5 kB [entry] [rendered] chunk {core-js-js} core-js-js-es2015.js, core-js-js-es2015.js.map (core-js-js) 78.7 kB [rendered] [...] chunk {tap-click-ca00ce7f-js} tap-click-ca00ce7f-js-es2015.js, tap-click-ca00ce7f-js-es2015.js.map (tap-click-ca00ce7f-js) 6.38 kB [rendered] chunk {vendor} vendor-es2015.js, vendor-es2015.js.map (vendor) 4.48 MB [initial] [rendered] Date: 2019-12-24T05:47:43.338Z - Hash: 0feb3050d41512cff93f - Time: 28862ms
chunk {0} 0-es5.js, 0-es5.js.map () 15.4 kB [rendered] chunk {1} 1-es5.js, 1-es5.js.map () 15.2 kB [rendered] chunk {2} 2-es5.js, 2-es5.js.map () 16.3 kB [rendered] [...] chunk {78} 78-es5.js, 78-es5.js.map () 23.3 kB [rendered] chunk {common} common-es5.js, common-es5.js.map (common) 14.7 kB [rendered] chunk {cordova} cordova.js, cordova.js.map (cordova) 63.5 kB [entry] [rendered] chunk {core-js-js} core-js-js-es5.js, core-js-js-es5.js.map (core-js-js) 78.7 kB [rendered] [...] chunk {vendor} vendor-es5.js, vendor-es5.js.map (vendor) 4.59 MB [initial] [rendered] Date: 2019-12-24T05:48:11.293Z - Hash: 83fb460ffa563851227c - Time: 27426ms
cordova build android Failed to run "javac -version", make sure that you have a JDK version 8 installed. You can get it from the following location: https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html [ERROR] An error occurred while running subprocess cordova.
cordova build android exited with exit code 1. Re-running this command with the --verbose flag may provide more information.
Turns out...
The whole $ANDROID_HOME
thing is a PITA, because it doesn't really matter that it points to where you unpacked and installed the Android Studio tarball (e.g. in /var/
). But it really does matter where your first startup cycle installed a (set of) implicit directory tree(s).
After a lotta experimentation (& swearing) we've got the process captured in:
Installing Oracle's JDK V8 is a royal PITA, now covered in this issue:
...Thanks for 'splaining, Ionic. That wasted hours, if not days, of valuable time.
$ANDROID_SDK_HOME
$ ionic cordova build android
> ng run app:ionic-cordova-build --platform=android
Browserslist: caniuse-lite is outdated. Please run next command `npm update`
chunk {0} 0-es2015.js, 0-es2015.js.map () 13.2 kB [rendered]
chunk {1} 1-es2015.js, 1-es2015.js.map () 20 kB [rendered]
chunk {2} 2-es2015.js, 2-es2015.js.map () 17 kB [rendered]
[...]
chunk {77} 77-es2015.js, 77-es2015.js.map () 20.2 kB [rendered]
chunk {common} common-es2015.js, common-es2015.js.map (common) 24.8 kB [rendered]
chunk {cordova} cordova.js, cordova.js.map (cordova) 63.5 kB [entry] [rendered]
chunk {core-js-js} core-js-js-es2015.js, core-js-js-es2015.js.map (core-js-js) 78.7 kB [rendered]
[...]
chunk {vendor} vendor-es2015.js, vendor-es2015.js.map (vendor) 4.48 MB [initial] [rendered]
Date: 2019-12-24T07:26:35.269Z - Hash: 0feb3050d41512cff93f - Time: 28591ms
chunk {0} 0-es5.js, 0-es5.js.map () 15.4 kB [rendered]
chunk {1} 1-es5.js, 1-es5.js.map () 15.2 kB [rendered]
chunk {2} 2-es5.js, 2-es5.js.map () 16.3 kB [rendered]
[...]
chunk {78} 78-es5.js, 78-es5.js.map () 23.3 kB [rendered]
chunk {common} common-es5.js, common-es5.js.map (common) 14.7 kB [rendered]
chunk {cordova} cordova.js, cordova.js.map (cordova) 63.5 kB [entry] [rendered]
chunk {core-js-js} core-js-js-es5.js, core-js-js-es5.js.map (core-js-js) 78.7 kB [rendered]
[...]
chunk {vendor} vendor-es5.js, vendor-es5.js.map (vendor) 4.59 MB [initial] [rendered]
Date: 2019-12-24T07:27:05.972Z - Hash: 83fb460ffa563851227c - Time: 30246ms
> cordova build android
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=/home/dpc/dpc.data/local.FS/lfs.00-Scratch/install.android.studio/android-studio (DEPRECATED)
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
[ERROR] An error occurred while running subprocess cordova.
cordova build android exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
dpc@LT3-Insp17-2017:~/dpc.data/local.FS/lfs.00-Scratch/projects/ionic4.demos/ionicStarWarsApp$
This is similar to the previous $ANDROID_HOME
failure, except it's very poorly documented as an important dependency in the build cycle. It's really kinda ugly, because (just as with $ANDROID_HOME
) it doesn't really matter that it should point to where you unpacked and installed the Android Studio tarball (e.g. in /var/
or /opt/
). But it really does matter where your first startup cycle of Android Studio installed a (set of) implicit directory tree(s).
The process of properly defining $ANDROID_HOME
and $ANDROID_SDK_ROOT
is now captured in:
$ ionic cordova build android
ng run app:ionic-cordova-build --platform=android Browserslist: caniuse-lite is outdated. Please run next command
npm update
chunk {0} 0-es2015.js, 0-es2015.js.map () 13.2 kB [rendered] chunk {1} 1-es2015.js, 1-es2015.js.map () 20 kB [rendered] chunk {2} 2-es2015.js, 2-es2015.js.map () 17 kB [rendered] [...] chunk {77} 77-es2015.js, 77-es2015.js.map () 20.2 kB [rendered] chunk {common} common-es2015.js, common-es2015.js.map (common) 24.8 kB [rendered] chunk {cordova} cordova.js, cordova.js.map (cordova) 63.5 kB [entry] [rendered] chunk {core-js-js} core-js-js-es2015.js, core-js-js-es2015.js.map (core-js-js) 78.7 kB [rendered] [...] chunk {vendor} vendor-es2015.js, vendor-es2015.js.map (vendor) 4.48 MB [initial] [rendered] Date: 2019-12-24T07:47:20.383Z - Hash: 0feb3050d41512cff93f - Time: 26137ms
chunk {0} 0-es5.js, 0-es5.js.map () 15.4 kB [rendered] chunk {1} 1-es5.js, 1-es5.js.map () 15.2 kB [rendered] chunk {2} 2-es5.js, 2-es5.js.map () 16.3 kB [rendered] [...] chunk {78} 78-es5.js, 78-es5.js.map () 23.3 kB [rendered] chunk {common} common-es5.js, common-es5.js.map (common) 14.7 kB [rendered] chunk {cordova} cordova.js, cordova.js.map (cordova) 63.5 kB [entry] [rendered] chunk {core-js-js} core-js-js-es5.js, core-js-js-es5.js.map (core-js-js) 78.7 kB [rendered] [...] chunk {vendor} vendor-es5.js, vendor-es5.js.map (vendor) 4.59 MB [initial] [rendered] Date: 2019-12-24T07:47:49.302Z - Hash: 83fb460ffa563851227c - Time: 28447ms
cordova build android Checking Java JDK and Android SDK versions ANDROID_SDK_ROOT=/home/dpc/dpc.data/local.FS/lfs.00-Scratch/install.android.studio/android-studio (recommended setting) ANDROID_HOME=/home/dpc/dpc.data/local.FS/lfs.00-Scratch/install.android.studio/android-studio (DEPRECATED) 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 [ERROR] An error occurred while running subprocess cordova.
cordova build android exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
dpc@LT3-Insp17-2017:~/dpc.data/local.FS/lfs.00-Scratch/projects/ionic4.demos/ionicStarWarsApp$
OK, so it looks like we need gradle? Thanks for the heads-up, Ionic!
We'll fix this in issue: install: Gradle CI/CD pipeline tools (required for Ionic Android Studio builds)
$ ionic cordova build android
ng run app:ionic-cordova-build --platform=android Browserslist: caniuse-lite is outdated. Please run next command
npm update
chunk {0} 0-es2015.js, 0-es2015.js.map () 13.2 kB [rendered] chunk {1} 1-es2015.js, 1-es2015.js.map () 20 kB [rendered] chunk {2} 2-es2015.js, 2-es2015.js.map () 17 kB [rendered] [...] chunk {77} 77-es2015.js, 77-es2015.js.map () 20.2 kB [rendered] chunk {common} common-es2015.js, common-es2015.js.map (common) 24.8 kB [rendered] chunk {cordova} cordova.js, cordova.js.map (cordova) 63.5 kB [entry] [rendered] chunk {core-js-js} core-js-js-es2015.js, core-js-js-es2015.js.map (core-js-js) 78.7 kB [rendered] [...] chunk {tap-click-ca00ce7f-js} tap-click-ca00ce7f-js-es2015.js, tap-click-ca00ce7f-js-es2015.js.map (tap-click-ca00ce7f-js) 6.38 kB [rendered] chunk {vendor} vendor-es2015.js, vendor-es2015.js.map (vendor) 4.48 MB [initial] [rendered] Date: 2019-12-26T06:28:41.805Z - Hash: 0feb3050d41512cff93f - Time: 20506ms
chunk {0} 0-es5.js, 0-es5.js.map () 15.4 kB [rendered] chunk {1} 1-es5.js, 1-es5.js.map () 15.2 kB [rendered] chunk {2} 2-es5.js, 2-es5.js.map () 16.3 kB [rendered] [...] chunk {78} 78-es5.js, 78-es5.js.map () 23.3 kB [rendered] chunk {common} common-es5.js, common-es5.js.map (common) 14.7 kB [rendered] chunk {cordova} cordova.js, cordova.js.map (cordova) 63.5 kB [entry] [rendered] chunk {core-js-js} core-js-js-es5.js, core-js-js-es5.js.map (core-js-js) 78.7 kB [rendered] [...] chunk {tap-click-ca00ce7f-js} tap-click-ca00ce7f-js-es5.js, tap-click-ca00ce7f-js-es5.js.map (tap-click-ca00ce7f-js) 6.32 kB [rendered] chunk {vendor} vendor-es5.js, vendor-es5.js.map (vendor) 4.59 MB [initial] [rendered] Date: 2019-12-26T06:29:02.286Z - Hash: 83fb460ffa563851227c - Time: 20222ms
cordova build android Checking Java JDK and Android SDK versions ANDROID_SDK_ROOT=/home/dpc/dpc.data/local.FS/lfs.00-Scratch/install.android.studio/android-studio (recommended setting) ANDROID_HOME=/home/dpc/dpc.data/local.FS/lfs.00-Scratch/install.android.studio/android-studio (DEPRECATED) Subproject Path: CordovaLib Subproject Path: app Starting a Gradle Daemon (subsequent builds will be faster)
Configure project :app Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.
FAILURE: Build failed with an exception.
Where: Script '/home/dpc/dpc.data/local.FS/lfs.00-Scratch/projects/ionic4.demos/ionicStarWarsApp/platforms/android/CordovaLib/cordova.gradle' line: 68
What went wrong: A problem occurred evaluating project ':app'.
No installed build tools found. Install the Android build tools version 19.1.0 or higher.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 5s /home/dpc/dpc.data/local.FS/lfs.00-Scratch/projects/ionic4.demos/ionicStarWarsApp/platforms/android/gradlew: Command failed with exit code 1 Error output: Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.
FAILURE: Build failed with an exception.
Where: Script '/home/dpc/dpc.data/local.FS/lfs.00-Scratch/projects/ionic4.demos/ionicStarWarsApp/platforms/android/CordovaLib/cordova.gradle' line: 68
What went wrong: A problem occurred evaluating project ':app'.
No installed build tools found. Install the Android build tools version 19.1.0 or higher.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 5s [ERROR] An error occurred while running subprocess cordova.
cordova build android exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
DDG: No installed build tools found. Install the Android build tools version 19.1.0 or higher.
There were many important clues on this Ionic GitHub repo issue: No installed build tools found. Install the Android build tools version 19.1.0 or higher
Another decent approach towards configuring Android Studio to have the proper SDKs installed is outlined in Ridwan's Article: How to Install Android Studio on Linux Mint 19 notes the following very important step for Android Builds:
STEP 2: Configuring SDK Manager Launch Android Studio again if you have not already done so. Notice the 'Configure' on the last line of the screen – click on it and then click on the 'SDK Manager' item (see below). For your information, SDK stands for Software Development Kit.
The original tutorial that this exercise is based upon: Getting Started with Ionic 4 also has (some rather general) advice on this step as follows:
After installing Android Studio open it and inside the Wizard click Configure and pick SDK Manager. This will bring you to a view where you can install an Android SDK – simply pick the newest one and install what you need!
For me, because the IDE had changed (since the recommendations above were written) the workflows suggested were not there. But I used the help system, and did a search on SDK, and it actually pulled up the component configuration IDE for me. You have to carefully pick the right tab (there are several) to locate the SDK installer section. I downloaded & installed both the 19.x and the latest version of the SDK.
The solutions to these problems are now reflected in the process: Rework Android Studio into a Standard /opt/-based Installation
With the proper SDKs downloaded & installed, I could proceed with the build.
Question: Does installing multiple SDKs cause multiple build targets/results?
I don't know enough about this non-IDE build pipeline, but as I Iook over the build outputs, it seems to me like we might be generating duplicate builds...
Let's confirm our build environment is what we expect:
$ echo $ANDROID_HOME
/home/dpc/Android/Sdk
$ echo $ANDROID_SDK_ROOT
/home/dpc/Android/Sdk
$ echo $PATH
/home/dpc/.local/bin:/usr/lib/jvm/jdk1.8.0_231/bin:/opt/gradle/bin:/home/dpc/Android/Sdk/bin:/home/dpc/Android/Sdk/tools:/home/dpc/Android/Sdk/platform-tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
$ more /etc/profile.d/android.studio.sh
# export ANDROID_HOME=/opt/android-studio # This does NOT work. The docs... suck.
# You don't point to where the package is installed.
# You point to where it initially laid down some dirs.
# Seriously? What. The. Flock.
export ANDROID_HOME=/home/dpc/Android/Sdk # This DOES work.
# Noted as deprecated in current build cycle
export ANDROID_SDK_ROOT=/home/dpc/Android/Sdk # This is noted as the new standard in builds...
export PATH=$ANDROID_SDK_ROOT/platform-tools:$PATH
export PATH=$ANDROID_SDK_ROOT/tools:$PATH
export PATH=$ANDROID_SDK_ROOT/bin:$PATH
# export PATH=$ANDROID_HOME/bin:$PATH # Redundant (since ANDROID_HOME = ANDROID_SDK_ROOT).
# export PATH=$ANDROID_HOME:$PATH
$ cd ~/dpc.data/local.FS/lfs.00-Scratch/projects/ionic4.demos/ionicStarWarsApp/
$ ionic cordova build android
ng run app:ionic-cordova-build --platform=android Browserslist: caniuse-lite is outdated. Please run next command
npm update
chunk {0} 0-es2015.js, 0-es2015.js.map () 13.2 kB [rendered] chunk {1} 1-es2015.js, 1-es2015.js.map () 20 kB [rendered] chunk {2} 2-es2015.js, 2-es2015.js.map () 17 kB [rendered] [...] chunk {77} 77-es2015.js, 77-es2015.js.map () 20.2 kB [rendered] chunk {common} common-es2015.js, common-es2015.js.map (common) 24.8 kB [rendered] chunk {cordova} cordova.js, cordova.js.map (cordova) 63.5 kB [entry] [rendered] chunk {core-js-js} core-js-js-es2015.js, core-js-js-es2015.js.map (core-js-js) 78.7 kB [rendered] [...] chunk {tap-click-ca00ce7f-js} tap-click-ca00ce7f-js-es2015.js, tap-click-ca00ce7f-js-es2015.js.map (tap-click-ca00ce7f-js) 6.38 kB [rendered] chunk {vendor} vendor-es2015.js, vendor-es2015.js.map (vendor) 4.48 MB [initial] [rendered] Date: 2019-12-26T22:41:25.181Z - Hash: 0feb3050d41512cff93f - Time: 18605ms
chunk {0} 0-es5.js, 0-es5.js.map () 15.4 kB [rendered] chunk {1} 1-es5.js, 1-es5.js.map () 15.2 kB [rendered] chunk {2} 2-es5.js, 2-es5.js.map () 16.3 kB [rendered] [...] chunk {78} 78-es5.js, 78-es5.js.map () 23.3 kB [rendered] chunk {common} common-es5.js, common-es5.js.map (common) 14.7 kB [rendered] chunk {cordova} cordova.js, cordova.js.map (cordova) 63.5 kB [entry] [rendered] chunk {core-js-js} core-js-js-es5.js, core-js-js-es5.js.map (core-js-js) 78.7 kB [rendered] [...] chunk {vendor} vendor-es5.js, vendor-es5.js.map (vendor) 4.59 MB [initial] [rendered] Date: 2019-12-26T22:41:45.116Z - Hash: 83fb460ffa563851227c - Time: 19663ms
cordova build android Checking Java JDK and Android SDK versions ANDROID_SDK_ROOT=/home/dpc/Android/Sdk (recommended setting) ANDROID_HOME=/home/dpc/Android/Sdk (DEPRECATED) Subproject Path: CordovaLib Subproject Path: app Task :app:preBuild UP-TO-DATE Task :CordovaLib:preBuild UP-TO-DATE Task :CordovaLib:preDebugBuild UP-TO-DATE [...] Task :app:cdvBuildDebug UP-TO-DATE
BUILD SUCCESSFUL in 5s 42 actionable tasks: 42 up-to-date Built the following apk(s): /home/dpc/dpc.data/local.FS/lfs.00-Scratch/projects/ionic4.demos/ionicStarWarsApp/platforms/android/app/build/outputs/apk/debug/app-debug.apk
exercise 3: Build & deploy simple button event processing app onto Android device
Here, we capture & categorize various errors encountered during the build cycle, as we learn what it takes to build & deploy Ionic apps onto Android. Details below...