Failed to generate APK

Asked

Viewed 158 times

0

So I’m following this tutorial:

http://www.tiagoporto.com/blog/tutorial-de-configuracao-do-ambiente-ionic-android-no-windows/

Which teaches to configure Ionic with Cordova to generate android apk’s

I did everything correctly. But, in the last step, where should generate the apk, gives the following error below and does not generate the APK.

Na verdade, nem mesmo a pasta android/"build" está gerando,

Where am I going wrong?

D:\Trabalhos\Mobile\Android\Radio>ionic cordova build android
> ionic-app-scripts build --target cordova --platform android
[16:38:21]  ionic-app-scripts 3.2.0
[16:38:21]  build dev started ...
[16:38:21]  clean started ...
[16:38:21]  clean finished in 9 ms
[16:38:21]  copy started ...
[16:38:22]  deeplinks started ...
[16:38:22]  deeplinks finished in 46 ms
[16:38:22]  transpile started ...
[16:38:31]  transpile finished in 9.52 s
[16:38:31]  preprocess started ...
[16:38:31]  preprocess finished in 1 ms
[16:38:31]  webpack started ...
[16:38:31]  copy finished in 9.95 s
[16:38:39]  webpack finished in 8.16 s
[16:38:39]  sass started ...
[16:38:42]  sass finished in 2.86 s
[16:38:42]  postprocess started ...
[16:38:42]  postprocess finished in 17 ms
[16:38:42]  lint started ...
[16:38:42]  build dev finished in 21.01 s
[16:38:48]  lint finished in 6.12 s
> cordova build android

You have been opted out of telemetry. To change this, run: cordova telemetry on.
Android Studio project detected
ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk-10.0.2
(node:2404) UnhandledPromiseRejectionWarning: CordovaError: Requirements check failed for JDK 1.8 or greater
    at D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\lib\check_reqs.js:370:19
    at _fulfilled (D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\node_modules\q\q.js:854:54)
    at D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\node_modules\q\q.js:883:30
    at Promise.promise.promiseDispatch (D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\node_modules\q\q.js:816:13)
    at D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\node_modules\q\q.js:624:44
    at runSingle (D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\node_modules\q\q.js:137:13)
    at flush (D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\node_modules\q\q.js:125:13)
    at process._tickCallback (internal/process/next_tick.js:61:11)
(node:2404) 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:2404) [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.

D:\Trabalhos\Mobile\Android\Radio>

After installed and set in environment variables to jdk 1.8 follows the new error after recompiling and running android with version 1.8:

D:\Trabalhos\Mobile\Android\Radio>ionic cordova build android
> ionic-app-scripts build --target cordova --platform android
[10:38:27]  ionic-app-scripts 3.2.0
[10:38:27]  build dev started ...
[10:38:27]  clean started ...
[10:38:27]  clean finished in 8 ms
[10:38:27]  copy started ...
[10:38:27]  deeplinks started ...
[10:38:27]  deeplinks finished in 59 ms
[10:38:27]  transpile started ...
[10:38:38]  transpile finished in 10.32 s
[10:38:38]  preprocess started ...
[10:38:38]  preprocess finished in 1 ms
[10:38:38]  webpack started ...
[10:38:38]  copy finished in 10.71 s
[10:38:46]  webpack finished in 8.50 s
[10:38:46]  sass started ...
[10:38:53]  sass finished in 6.52 s
[10:38:53]  postprocess started ...
[10:38:53]  postprocess finished in 14 ms
[10:38:53]  lint started ...
[10:38:53]  build dev finished in 25.75 s
[10:39:00]  lint finished in 7.26 s
> cordova build android
Android Studio project detected
ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_181
studio
(node:7508) UnhandledPromiseRejectionWarning: CordovaError: 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
    at Object.module.exports.check_gradle (D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\lib\check_reqs.js:150:18)
    at StudioBuilder.prepEnv (D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\lib\builders\StudioBuilder.js:216:23)
    at Api.module.exports.run (D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\lib\build.js:154:20)
    at D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\Api.js:342:43
    at _fulfilled (D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\node_modules\q\q.js:854:54)
    at D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\node_modules\q\q.js:883:30
    at Promise.promise.promiseDispatch (D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\node_modules\q\q.js:816:13)
    at D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\node_modules\q\q.js:624:44
    at runSingle (D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\node_modules\q\q.js:137:13)
    at flush (D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\node_modules\q\q.js:125:13)
(node:7508) 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:7508) [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.

D:\Trabalhos\Mobile\Android\Radio>ionic cordova run android
> ionic-app-scripts build --target cordova --platform android
[10:39:49]  ionic-app-scripts 3.2.0
[10:39:49]  build dev started ...
[10:39:49]  clean started ...
[10:39:49]  clean finished in 11 ms
[10:39:49]  copy started ...
[10:39:49]  deeplinks started ...
[10:39:49]  deeplinks finished in 41 ms
[10:39:49]  transpile started ...
[10:39:59]  transpile finished in 9.60 s
[10:39:59]  preprocess started ...
[10:39:59]  preprocess finished in 1 ms
[10:39:59]  webpack started ...
[10:39:59]  copy finished in 10.03 s
[10:40:09]  webpack finished in 9.72 s
[10:40:09]  sass started ...
[10:40:12]  sass finished in 2.87 s
[10:40:12]  postprocess started ...
[10:40:12]  postprocess finished in 14 ms
[10:40:12]  lint started ...
[10:40:12]  build dev finished in 22.94 s
[10:40:18]  lint finished in 6.50 s
> cordova run android
Android Studio project detected
ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_181
studio
(node:284) UnhandledPromiseRejectionWarning: CordovaError: 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
    at Object.module.exports.check_gradle (D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\lib\check_reqs.js:150:18)
    at StudioBuilder.prepEnv (D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\lib\builders\StudioBuilder.js:216:23)
    at Api.module.exports.run (D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\lib\build.js:154:20)
    at D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\Api.js:342:43
    at _fulfilled (D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\node_modules\q\q.js:854:54)
    at D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\node_modules\q\q.js:883:30
    at Promise.promise.promiseDispatch (D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\node_modules\q\q.js:816:13)
    at D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\node_modules\q\q.js:624:44
    at runSingle (D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\node_modules\q\q.js:137:13)
    at flush (D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\node_modules\q\q.js:125:13)
(node:284) 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:284) [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.

D:\Trabalhos\Mobile\Android\Radio>

New try, new mistake:

D:\Trabalhos\Mobile\Android\Radio>ionic cordova run android
> ionic-app-scripts build --target cordova --platform android
[12:31:19]  ionic-app-scripts 3.2.0
[12:31:19]  build dev started ...
[12:31:19]  clean started ...
[12:31:19]  clean finished in 297 ms
[12:31:19]  copy started ...
[12:31:21]  deeplinks started ...
[12:31:21]  deeplinks finished in 31 ms
[12:31:21]  transpile started ...
[12:31:54]  transpile finished in 32.65 s
[12:31:54]  preprocess started ...
[12:31:54]  preprocess finished in less than 1 ms
[12:31:54]  webpack started ...
[12:32:03]  copy finished in 44.14 s
[12:32:23]  webpack finished in 29.02 s
[12:32:23]  sass started ...
[12:32:39]  sass finished in 16.28 s
[12:32:39]  postprocess started ...
[12:32:39]  postprocess finished in 16 ms
[12:32:39]  lint started ...
[12:32:39]  build dev finished in 80.77 s
[12:32:48]  lint finished in 8.56 s
> cordova run android
Android Studio project detected
ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_181
studio
Subproject Path: CordovaLib
Subproject Path: app
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
Checking the license for package Android SDK Platform 26 in C:\Program Files (x86)\Android\android-sdk\licenses
Warning: License for package Android SDK Platform 26 not accepted.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':CordovaLib'.
> You have not accepted the license agreements of the following SDK components:
  [Android SDK Platform 26].
  Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
  Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 2m 31s
(node:6960) UnhandledPromiseRejectionWarning: Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':CordovaLib'.
> You have not accepted the license agreements of the following SDK components:
  [Android SDK Platform 26].
  Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
  Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 2m 31s
    at ChildProcess.whenDone (D:\Trabalhos\Mobile\Android\Radio\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:961:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:250:5)
(node:6960) 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:6960) [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.

D:\Trabalhos\Mobile\Android\Radio>

New complete picture:

D:\Trabalhos\Mobile\Android\Radio>ionic cordova run android
> ionic-app-scripts build --target cordova --platform android
[19:10:32]  ionic-app-scripts 3.2.0
[19:10:32]  build dev started ...
[19:10:32]  clean started ...
[19:10:33]  clean finished in 183 ms
[19:10:33]  copy started ...
[19:10:33]  deeplinks started ...
[19:10:33]  deeplinks finished in 47 ms
[19:10:33]  transpile started ...
[19:10:58]  transpile finished in 24.64 s
[19:10:58]  preprocess started ...
[19:10:58]  preprocess finished in 1 ms
[19:10:58]  webpack started ...
[19:11:02]  copy finished in 29.07 s
[19:11:16]  webpack finished in 18.66 s
[19:11:16]  sass started ...
[19:11:30]  sass finished in 13.86 s
[19:11:30]  postprocess started ...
[19:11:30]  postprocess finished in 90 ms
[19:11:30]  lint started ...
[19:11:31]  build dev finished in 58.16 s
[19:11:38]  lint finished in 7.94 s
> cordova run android
Android Studio project detected
ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_181
studio
Subproject Path: CordovaLib
Subproject Path: app
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
        at build_74uie4hd1mh3598jzv35vp9o9.run(D:\Trabalhos\Mobile\Android\Radio\platforms\android\app\build.gradle:143)
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:compileDebugAidl UP-TO-DATE
:CordovaLib:compileDebugRenderscript UP-TO-DATE
:CordovaLib:checkDebugManifest UP-TO-DATE
:CordovaLib:generateDebugBuildConfig UP-TO-DATE
:CordovaLib:prepareLintJar UP-TO-DATE
:CordovaLib:generateDebugResValues UP-TO-DATE
:CordovaLib:generateDebugResources UP-TO-DATE
:CordovaLib:packageDebugResources UP-TO-DATE
:CordovaLib:platformAttrExtractor UP-TO-DATE
:CordovaLib:processDebugManifest UP-TO-DATE
:CordovaLib:processDebugResources UP-TO-DATE
:CordovaLib:generateDebugSources UP-TO-DATE
:CordovaLib:javaPreCompileDebug UP-TO-DATE
:CordovaLib:compileDebugJavaWithJavac UP-TO-DATE
:CordovaLib:processDebugJavaRes NO-SOURCE
:CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug UP-TO-DATE
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugAidl UP-TO-DATE
:CordovaLib:packageDebugRenderscript NO-SOURCE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:prepareLintJar UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:createDebugCompatibleScreenManifests UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:splitsDiscoveryTaskDebug UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:javaPreCompileDebug UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk NO-SOURCE
:app:compileDebugSources UP-TO-DATE
:CordovaLib:mergeDebugShaders UP-TO-DATE
:CordovaLib:compileDebugShaders UP-TO-DATE
:CordovaLib:generateDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugAssets UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:transformClassesWithStackFramesFixerForDebug UP-TO-DATE
:app:transformClassesWithDesugarForDebug UP-TO-DATE
:app:transformClassesWithDexBuilderForDebug UP-TO-DATE
:app:transformDexArchiveWithExternalLibsDexMergerForDebug UP-TO-DATE
:app:transformDexArchiveWithDexMergerForDebug UP-TO-DATE
:CordovaLib:compileDebugNdk NO-SOURCE
:CordovaLib:mergeDebugJniLibFolders UP-TO-DATE
:CordovaLib:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE
:CordovaLib:transformNativeLibsWithIntermediateJniLibsForDebug UP-TO-DATE
:app:mergeDebugJniLibFolders UP-TO-DATE
:app:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE
:app:processDebugJavaRes NO-SOURCE
:app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:app:validateSigningDebug
:app:packageDebug UP-TO-DATE
:app:assembleDebug UP-TO-DATE
:app:cdvBuildDebug UP-TO-DATE

BUILD SUCCESSFUL in 2m 3s
46 actionable tasks: 1 executed, 45 up-to-date
Built the following apk(s):
        D:\Trabalhos\Mobile\Android\Radio\platforms\android\app\build\outputs\apk\debug\app-debug.apk
ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_181
No target specified and no devices found, deploying to emulator
No emulator specified, defaulting to VisualStudio_android-23_arm_phone
Waiting for emulator to start...
PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value [C:\Program Files (x86)\Android\android-sdk]!
  • I would say just from what you put that what’s wrong in your build would be the JAVA_HOME. It is important to download the specific version, i.e., 1.8.0_65.

  • javac works normal. So JAVA_HOME is correct!

  • @Marconi Just one more question: Where did this information come from that the version of JAVA should be 1.8.0_65?

  • I developed a Hybrid App too, in the documentation had a specific jdk version, while not installing the specific version did not work.

  • In the tutorial you posted has a different version than the one you have installed!

  • Got it. But this JDK is very old. Does the most current not have the oldest inside?

  • You have to be specific! In my case the version 10 did not fit, I had to use the 8!

  • I understand, but the one in the tutorial is not 8 but 1.8.But I will install it and set in the environment variables to see if it works!

  • Dear Carlos, as I said in the other comment, 1.8 is the JDK 8. Ally, your JAVA_HOME points to the 1.8 and not to the folder of the 10, so by the logic would only edit the JAVA_HOME, is not true?

  • Good, new PANIC error: Broken AVD system path. Check your ANDROID_SDK_ROOT value [C: Program Files (x86) Android-sdk]!. Actually, gave AVD missing error then seeing in a tutorial that the address would be the same as android sdk, so I just entered the same address and gave this new error. But the app-debug.apk was generated

  • @Guilherme, I had already set for version 1.8. So much is true that it is compiling normally. Now all that remains is to open the simulator. But it remains to correct the above comment error and correctly set the variable ANDROID_SDK_ROOT

  • New complete picture at the end of the question: Quaseeeeee worked! Almost...

Show 7 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.