ionic unable to create an APK [duplicate] - android

i am new to ionic, trying to get an apk for debugging i used the following commands inside the project directory:
ionic cordova platform add android
i did get "platforms/android" directory
and then i used:
ionic cordova build android
this is what i get after:
ionic-app-scripts build --target cordova --platform android
[23:57:19] ionic-app-scripts 3.1.10
[23:57:19] build dev started ...
[23:57:19] clean started ...
[23:57:19] clean finished in 10 ms
[23:57:19] copy started ...
[23:57:19] deeplinks started ...
[23:57:19] deeplinks finished in 36 ms
[23:57:19] transpile started ...
[23:57:27] transpile finished in 8.13 s
[23:57:27] preprocess started ...
[23:57:27] preprocess finished in less than 1 ms
[23:57:27] webpack started ...
[23:57:28] copy finished in 8.97 s
[23:57:35] webpack finished in 7.63 s
[23:57:35] sass started ...
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[23:57:40] sass finished in 4.83 s
[23:57:40] postprocess started ...
[23:57:40] postprocess finished in 28 ms
[23:57:40] lint started ...
[23:57:40] build dev finished in 20.79 s
[23:57:44] lint finished in 3.91 s
> cordova build android
You have been opted out of telemetry. To change this, run: cordova telemetry on.
Android Studio project detected
(node:12696) UnhandledPromiseRejectionWarning: CordovaError: 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.
at C:\Users\h2001\Desktop\myApp\platforms\android\cordova\lib\check_reqs.js:305:19
at _fulfilled (C:\Users\h2001\Desktop\myApp\platforms\android\cordova\node_modules\q\q.js:854:54)
at self.promiseDispatch.done (C:\Users\h2001\Desktop\myApp\platforms\android\cordova\node_modules\q\q.js:883:30)
at Promise.promise.promiseDispatch (C:\Users\h2001\Desktop\myApp\platforms\android\cordova\node_modules\q\q.js:816:13)
at C:\Users\h2001\Desktop\myApp\platforms\android\cordova\node_modules\q\q.js:877:14
at runSingle (C:\Users\h2001\Desktop\myApp\platforms\android\cordova\node_modules\q\q.js:137:13)
at flush (C:\Users\h2001\Desktop\myApp\platforms\android\cordova\node_modules\q\q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
(node:12696) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:12696) [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.
but i didn't get the promised \build\outputs\apk, what is the problem?
UPDATE: i installed android studio and updated it, still getting
(node:12696) UnhandledPromiseRejectionWarning
UPDATE: the problem was solved, turns out i had java10 which wont work with android, simply installing java8 solved the problem

btw, i dont have android sdk installed if that makes any difference?
You have answered your own question.
To make an Android APK
You need Java SDK 1.8.
Android SDK with latest build tools and platforms
JAVA_HOME & ANDROID_HOME environmental variables set correctly.
Also You need updated X-Code on a Mac to create an IPA.

You probably doesn't have android environment variable in your PC.
if you are running MAC try running:
sudo export ANDROID_HOME=/<installation location>/android-sdk-macosx
sudo export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
If you are running Linux then:
export ANDROID_HOME=/<installation location>/android-sdk-linux
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
And if you are running Windows then open your command prompt as Administrator and run:
set ANDROID_HOME=C:\<installation location>\android-sdk-windows
set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
It will add enviroment variable to your system.

Related

ionic 3 - UnhandledPromiseRejectionWarning when generating android build

I am using ionic 3.19 and when I try to create an android build it has the following error. With ios its fine. What is this problem and how to solve this ?
I am using node v8.9.1.
(node:49779) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: spawn EACCES
Here is the execution and the problem output
$ ionic cordova build android --release
Running app-scripts build: --platform android --target cordova
[18:01:13] build dev started ...
[18:01:13] clean started ...
[18:01:13] clean finished in 6 ms
[18:01:13] copy started ...
[18:01:13] deeplinks started ...
[18:01:13] deeplinks finished in 97 ms
[18:01:13] transpile started ...
[18:01:17] transpile finished in 4.06 s
[18:01:17] preprocess started ...
[18:01:17] preprocess finished in less than 1 ms
[18:01:17] webpack started ...
[18:01:17] copy finished in 4.30 s
[18:01:25] webpack finished in 7.47 s
[18:01:25] sass started ...
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[18:01:26] sass finished in 1.26 s
[18:01:26] postprocess started ...
[18:01:26] postprocess finished in 13 ms
[18:01:26] lint started ...
[18:01:26] build dev finished in 13.04 s
> cordova build android --release
ANDROID_HOME=/Users/megasap/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_71.jdk/Contents/Home
(node:49779) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: spawn EACCES
(node:49779) [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.
[18:01:29] tslint: src/pages/attandance-detail/attandance-detail.ts, line: 175
'marker' is declared but never used.
L174: console.log(location)
L175: let marker = new google.maps.Marker({
L176: position: location,
[18:01:29] tslint: src/pages/home/home.ts, line: 260
'marker' is declared but never used.
L259: addMarker(location, map) {
L260: let marker = new google.maps.Marker({
L261: position: location,
[18:01:29] lint finished in 3.00 s
UPDATE:
This is the execution and error with node v9.4.0. This has a bit more detail than the previous running on node v8.9.1.
https://gist.github.com/axilaris/4cc7094c7dae28477eb2f348e53fad91
this did the trick!
sudo chmod 777 /Applications/Android\ Studio.app/Contents/gradle/gradle-4.1/bin/gradle
I just had this problem and after updating Android Studio and it updated gradle from 4.1 to 4.4 then I had to update my environment variable and go to the new gradle location /opt/android-studio/gradle/gradle-4.4/bin and do chmod 777 gradle

UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: spawn EACCES Ionic 3

I 've been working on this issue for a lot of time and I can't really fix it. When I do ionic Cordova build android it works well until it gets to Cordova build android, anyone has some idea about what happened here??
I know that if a problem with permission but I can't found what is the directory I'd change
KENRYMAC:RecipeBookApp Kenry$ ionic cordova build android
Running app-scripts build: --platform android --target cordova
[23:36:09] build dev started ...
[23:36:10] clean started ...
[23:36:10] clean finished in 5 ms
[23:36:10] copy started ...
[23:36:10] deeplinks started ...
[23:36:11] deeplinks finished in 161 ms
[23:36:11] transpile started ...
[23:36:51] transpile finished in 40.73 s
[23:36:51] preprocess started ...
[23:36:51] preprocess finished in 1 ms
[23:36:51] webpack started ...
[23:36:52] copy finished in 42.36 s
[23:37:20] webpack finished in 28.48 s
[23:37:20] sass started ...
Witout `from` option PostCSS could generate wrong source map or do not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning
[23:37:23] sass finished in 2.94 s
[23:37:23] postprocess started ...
[23:37:23] postprocess finished in 17 ms
[23:37:23] lint started ...
[23:37:23] build dev finished in 73.84 s
> cordova build android
ANDROID_HOME=/Users/Kenry/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home
(node:4570) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: spawn EACCES
(node:4570) [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.
[23:37:31] tslint: src/pages/signin/signin.ts, line: 4
'FormControl' is declared but never used.
L4: import { FormControl, NgForm } from '#angular/forms';
[23:37:31] tslint: src/pages/signup/signup.ts, line: 4
'FormControl' is declared but never used.
L4: import { FormControl, NgForm } from '#angular/forms';
[23:37:31] lint finished in 8.22 s
Please, can anyone give me some clues?? Thank you
Run the following command:
cordova build android --verbose
You can get output something like this:
Running command: /usr/libexec/java_home
Command finished with error code 0: /usr/libexec/java_home
ANDROID_HOME=/Users/mj/phonegap/adt-bundle-mac-x86_64-20140321/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
Running command: "/Applications/Android Studio.app/Contents/gradle/gradle-2.2.1/bin/gradle"
-p /Users/mj/EduceMobile/app/platforms/android wrapper -b /Users/mj/EduceMobile/app/platfo
rms/android/wrapper.gradle
Error: spawn EACCES
at exports._errnoException (util.js:1018:11)
at ChildProcess.spawn (internal/child_process.js:319:11)
at Object.exports.spawn (child_process.js:378:9)
.....
.....
Note the line:
Running command: "/Applications/Android
Studio.app/Contents/gradle/gradle-2.2.1/bin/gradle"
This shows that there is permission issue with the file /Applications/Android Studio.app/Contents/gradle/gradle-2.2.1/bin/gradle.
To fix the issue, give appropriate permission to that file so that it can be executable.
You can run the following command:
sudo chmod +x /Applications/Android Studio.app/Contents/gradle/gradle-2.2.1/bin/gradle
This should solve the issue.
If apple push services certificate not displays in key chain
Quit keychain access
Right-click the .cer file (e.g. aps_production.cer)
Select Open With > Keychain access (default)

Ionic2 - Android build failed

I was trying to build an Ionic2 app with Android platform on my Win 7 (32 bt) system.
I ran the ionic build android command in the CLI and the following error occurred :
...ionic build android
> ionic-hello-world# ionic:build D:\<path>
> ionic-app-scripts build
[20:12:32] ionic-app-scripts 1.0.0
[20:12:32] build dev started ...
[20:12:32] clean started ...
[20:12:32] clean finished in 10 ms
[20:12:32] copy started ...
[20:12:32] transpile started ...
[20:12:37] transpile finished in 5.47 s
[20:12:37] webpack started ...
[20:12:38] copy finished in 5.74 s
[20:12:49] webpack finished in 11.84 s
[20:12:49] sass started ...
[20:12:52] sass finished in 2.81 s
[20:12:52] build dev finished in 20.16 s
[20:12:58] tslint: D:/../src/app/app.component.ts, line: 3
Unused import: 'OneSignal'
L2: import { Platform } from 'ionic-angular';
L3: import { StatusBar, Splashscreen, OneSignal } from 'ionic-native';
ANDROID_HOME=C:\Users\<user-name>\AppData\Local\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_60
Subproject Path: CordovaLib
Starting a new Gradle Daemon for this build (subsequent builds will be faster).
FAILURE: Build failed with an exception.
* What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html
Please read the following process output to find out more:
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
Then as suggested I read the 'https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html' and created the gradle.properties file with the following
org.gradle.daemon=true
The error still persists with the same result !!!
What is going wrong ?? Please help .
Found the solution after a hour long R&D.
Basically as per 'https://cordova.apache.org/docs/en/latest/guide/platforms/android/' - As of cordova-android#4.0.0, Cordova for Android projects are built using Gradle. Earlier it was built using Apache Ant.
Now Gradle looks for latest Android SDK. When I removed the android platform and added again with ionic platform add android command - the CLI listed that the latest Android SDK ( in my case it was SDK 24 ) was not installed.
I installed the required SDK version using Android SDK Manager and subsequent add of Android Platform along with the cordova plugin smoothly installed without any error.
The CLI printed the following -
..ionic plugin add onesignal-cordova-plugin
Fetching plugin "onesignal-cordova-plugin" via npm
Installing "onesignal-cordova-plugin" for android
ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_121
Subproject Path: CordovaLib
Incremental java compilation is an incubating feature.
:clean
:CordovaLib:clean
BUILD SUCCESSFUL
Total time: 1.611 secs
Subproject Path: CordovaLib
Try using cordova platform add https://github.com/apache/cordova-android
Ive had to start using this command ever since updating Ionic.

Phonegap Command filed with exit code 8 - Ubuntu

I'm trying to do my first android app in javascript with [phonegap][1] (cordova).
But when I put "phonegap run android" it exits with error 8, this is the code, here is the pic: http://i.stack.imgur.com/qofsZ.png (can't post screen because of reputation):
giulio#cucina:~/Documenti/web/sveglia/sveglia$ phonegap run android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
/home/giulio/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:126
throw e;
^
Error: An error occurred while listing Android targets
at /home/giulio/.cordova/lib/android/cordova/3.5.1/bin/lib/check_reqs.js:87:29
at _rejected (/home/giulio/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:808:24)
at /home/giulio/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:834:30
at Promise.when (/home/giulio/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/home/giulio/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:752:41)
at /home/giulio/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:574:44
at flush (/home/giulio/.cordova/lib/android/cordova/3.5.1/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:419:13)
{ [Error: /home/giulio/.cordova/lib/android/cordova/3.5.1/bin/create: Command failed with exit code 8] code: 8 }
[error] /home/giulio/.cordova/lib/android/cordova/3.5.1/bin/create: Command failed with exit code 8
I've tried to follow these instructions: stackoverflow.com/questions/20323787/cordova-platform-add-android-not-working-while-listing-android-targets/21142421#21142421 and stackoverflow.com/questions/24380283/phonegap-run-android-create-command-failed-with-exit-code-8-linux, but again it doesn't work.
This is the bashrc (http://i.stack.imgur.com/mdLDY.png), I've put the code at the top:
export ANDROID_HOME="/media/giulio/Secondo\ Disco/Development/android-sdk-linux/tools"
export ANDROID_PLATFORM_TOOLS="/media/giulio/Secondo\ Disco/Development/android-sdk-linux/platform-tools"
export PATH="$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS:$PATH"
export PATH="$PATH:/usr/share/ant/bin"
~/.bashrc: executed by bash(1) for non-login shells.
...etc
I've already installed android packages, ant and everything necessary.
You're my last chance! D:
Export the two variables:
ANDROID_HOME and JAVA_HOME
And, in addition, put android platform-tools on the PATH, works for me.
In my case, it was something like this:
export ANDROID_HOME=/home/YOURUSER/sw/android/adt-bundle-linux-x86-20131030/sdk/
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386/
export PATH="/home/YOURUSER/sw/android/adt-bundle-linux-x86-20131030/sdk/platform-tools/:/home/YOURUSER/sw/android/adt-bundle-linux-x86-20131030/sdk/tools:tools:$PATH"

Can't seem to generate an APK from ionic project

i am new to ionic, trying to get an apk for debugging i used the following commands inside the project directory:
ionic cordova platform add android
i did get "platforms/android" directory
and then i used:
ionic cordova build android
this is what i get after:
ionic-app-scripts build --target cordova --platform android
[23:57:19] ionic-app-scripts 3.1.10
[23:57:19] build dev started ...
[23:57:19] clean started ...
[23:57:19] clean finished in 10 ms
[23:57:19] copy started ...
[23:57:19] deeplinks started ...
[23:57:19] deeplinks finished in 36 ms
[23:57:19] transpile started ...
[23:57:27] transpile finished in 8.13 s
[23:57:27] preprocess started ...
[23:57:27] preprocess finished in less than 1 ms
[23:57:27] webpack started ...
[23:57:28] copy finished in 8.97 s
[23:57:35] webpack finished in 7.63 s
[23:57:35] sass started ...
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[23:57:40] sass finished in 4.83 s
[23:57:40] postprocess started ...
[23:57:40] postprocess finished in 28 ms
[23:57:40] lint started ...
[23:57:40] build dev finished in 20.79 s
[23:57:44] lint finished in 3.91 s
> cordova build android
You have been opted out of telemetry. To change this, run: cordova telemetry on.
Android Studio project detected
(node:12696) UnhandledPromiseRejectionWarning: CordovaError: 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.
at C:\Users\h2001\Desktop\myApp\platforms\android\cordova\lib\check_reqs.js:305:19
at _fulfilled (C:\Users\h2001\Desktop\myApp\platforms\android\cordova\node_modules\q\q.js:854:54)
at self.promiseDispatch.done (C:\Users\h2001\Desktop\myApp\platforms\android\cordova\node_modules\q\q.js:883:30)
at Promise.promise.promiseDispatch (C:\Users\h2001\Desktop\myApp\platforms\android\cordova\node_modules\q\q.js:816:13)
at C:\Users\h2001\Desktop\myApp\platforms\android\cordova\node_modules\q\q.js:877:14
at runSingle (C:\Users\h2001\Desktop\myApp\platforms\android\cordova\node_modules\q\q.js:137:13)
at flush (C:\Users\h2001\Desktop\myApp\platforms\android\cordova\node_modules\q\q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
(node:12696) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:12696) [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.
but i didn't get the promised \build\outputs\apk, what is the problem?
UPDATE: i installed android studio and updated it, still getting
(node:12696) UnhandledPromiseRejectionWarning
UPDATE: the problem was solved, turns out i had java10 which wont work with android, simply installing java8 solved the problem
btw, i dont have android sdk installed if that makes any difference?
You have answered your own question.
To make an Android APK
You need Java SDK 1.8.
Android SDK with latest build tools and platforms
JAVA_HOME & ANDROID_HOME environmental variables set correctly.
Also You need updated X-Code on a Mac to create an IPA.
You probably doesn't have android environment variable in your PC.
if you are running MAC try running:
sudo export ANDROID_HOME=/<installation location>/android-sdk-macosx
sudo export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
If you are running Linux then:
export ANDROID_HOME=/<installation location>/android-sdk-linux
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
And if you are running Windows then open your command prompt as Administrator and run:
set ANDROID_HOME=C:\<installation location>\android-sdk-windows
set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
It will add enviroment variable to your system.

Categories

Resources