What are the correct steps to do before generate an APK?

Dears,

Every time that a will execute “ionic cordova emulate android” I got a bunch of errors.

I have two Android smartphones to install my APK, one 4.4.2 and other 8.0.0. First time that I built an APK file, I managed to execute it into my Android 8.0.0, and I had problems to execute into 4.4.2.

After googled a lot I’ve found that we need to add platform android@6.0.0 to run the APK in Android 4.4.2 (I suppose it’s correct). Then, what I did? I’ve removed platforms and plugins directory. I ran
“ionic cordova platform add android@6.0.0” and after “ionic cordova emulate android”. Again a bunch of errors!

I’m using Ubuntu 18.10 and Android Studio, both in latest version.

What combination of “SDK Platforms” and “Android SDK Build-Tools” I need to avoid errors during compilation/build/emulate? Only this combinations is enough? What are the correct steps to compile my Ionic Project to Android 4.4.2 or later?

Thanks.

$ ionic info
✔ Gathering environment info - done!

Ionic:

   ionic (Ionic CLI)  : 4.1.1 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.1.9

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.0.0
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 1.2.1, (and 5 other plugins)

System:

   NodeJS : v8.10.0 (/usr/bin/node)
   npm    : 6.1.0
   OS     : Linux 4.15

Here my problems:

$ ionic cordova emulate android
> ionic-app-scripts build --target cordova --platform android
[14:10:56]  ionic-app-scripts 3.1.9 
[14:10:56]  build dev started ... 
[14:10:56]  clean started ... 
[14:10:56]  clean finished in 4 ms 
[14:10:56]  copy started ... 
[14:10:56]  copy finished in 129 ms 
[14:10:56]  deeplinks started ... 
[14:10:57]  deeplinks finished in 438 ms 
[14:10:57]  transpile started ... 
[14:11:03]  transpile finished in 5.82 s 
[14:11:03]  preprocess started ... 
[14:11:03]  preprocess finished in 1 ms 
[14:11:03]  webpack started ... 
[14:11:13]  webpack finished in 10.95 s 
[14:11:13]  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.
[14:11:14]  sass finished in 1.04 s 
[14:11:14]  postprocess started ... 
[14:11:15]  postprocess finished in 8 ms 
[14:11:15]  lint started ... 
[14:11:15]  build dev finished in 18.47 s 
[14:11:18]  lint finished in 3.94 s 
> cordova emulate android
Android Studio project detected
Preparing Firebase on Android
ANDROID_HOME=/opt/android-studio
JAVA_HOME=/opt/jdk
studio
Subproject Path: CordovaLib
Subproject Path: app
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
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_780u3077cn02lc80rzxvnren2.run(/home/rodrigo/projects/myApp/platforms/android/app/build.gradle:144)
: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
Exception in thread "main" java.lang.IllegalArgumentException
	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:108)
	at com.google.devtools.build.android.desugar.DefaultMethodClassFixer$DefaultMethodFinder.visit(DefaultMethodClassFixer.java:471)
	at org.objectweb.asm.ClassReader.accept(Unknown Source)
	at org.objectweb.asm.ClassReader.accept(Unknown Source)
	at com.google.devtools.build.android.desugar.DefaultMethodClassFixer.defaultMethodsDefined(DefaultMethodClassFixer.java:319)
	at com.google.devtools.build.android.desugar.DefaultMethodClassFixer.visitEnd(DefaultMethodClassFixer.java:88)
	at org.objectweb.asm.ClassVisitor.visitEnd(Unknown Source)
	at com.google.devtools.build.android.desugar.InterfaceDesugaring.visitEnd(InterfaceDesugaring.java:85)
	at org.objectweb.asm.ClassVisitor.visitEnd(Unknown Source)
	at com.google.devtools.build.android.desugar.LambdaDesugaring.visitEnd(LambdaDesugaring.java:150)
	at org.objectweb.asm.ClassReader.accept(Unknown Source)
	at org.objectweb.asm.ClassReader.accept(Unknown Source)
	at com.google.devtools.build.android.desugar.Desugar.desugarClassesInInput(Desugar.java:401)
	at com.google.devtools.build.android.desugar.Desugar.desugarOneInput(Desugar.java:326)
	at com.google.devtools.build.android.desugar.Desugar.desugar(Desugar.java:280)
	at com.google.devtools.build.android.desugar.Desugar.main(Desugar.java:584)

:app:transformClassesWithDesugarForDebug FAILED
35 actionable tasks: 1 executed, 34 up-to-date

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithDesugarForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.google.devtools.build.android.desugar.Desugar with arguments {--input /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/21.jar --output /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/desugar/debug/23.jar --input /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/45.jar --output /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/desugar/debug/47.jar --input /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/39.jar --output /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/desugar/debug/41.jar --input /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/40.jar --output /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/desugar/debug/42.jar --input /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/classes/debug --output /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/desugar/debug/1 --input /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/5.jar --output /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/desugar/debug/7.jar --input /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/35.jar --output /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/desugar/debug/37.jar --input /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/27.jar --output /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/desugar/debug/29.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/CordovaLib/build/intermediates/intermediate-jars/debug/classes.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/classes/debug --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/0.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/1.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/2.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/3.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/4.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/5.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/6.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/7.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/8.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/9.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/10.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/11.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/12.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/13.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/14.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/15.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/16.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/17.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/18.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/19.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/20.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/21.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/22.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/23.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/24.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/25.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/26.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/27.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/28.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/29.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/30.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/31.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/32.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/33.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/34.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/35.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/36.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/37.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/38.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/39.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/40.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/41.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/42.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/43.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/44.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/45.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/46.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/47.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/48.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/49.jar --bootclasspath_entry /opt/android-studio/platforms/android-26/android.jar --bootclasspath_entry /opt/android-studio/platforms/android-26/optional/org.apache.http.legacy.jar --bootclasspath_entry /usr/local/jdk1.8.0_171/jre/lib/resources.jar --bootclasspath_entry /usr/local/jdk1.8.0_171/jre/lib/rt.jar --bootclasspath_entry /usr/local/jdk1.8.0_171/jre/lib/jsse.jar --bootclasspath_entry /usr/local/jdk1.8.0_171/jre/lib/jce.jar --bootclasspath_entry /usr/local/jdk1.8.0_171/jre/lib/charsets.jar --bootclasspath_entry /usr/local/jdk1.8.0_171/jre/lib/jfr.jar --min_sdk_version 19 --nodesugar_try_with_resources_if_needed --desugar_try_with_resources_omit_runtime_classes}

* 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 9s
(node:8709) UnhandledPromiseRejectionWarning: Error: /home/rodrigo/projects/myApp/platforms/android/gradlew: Command failed with exit code 1 Error output:
Exception in thread "main" java.lang.IllegalArgumentException
	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:108)
	at com.google.devtools.build.android.desugar.DefaultMethodClassFixer$DefaultMethodFinder.visit(DefaultMethodClassFixer.java:471)
	at org.objectweb.asm.ClassReader.accept(Unknown Source)
	at org.objectweb.asm.ClassReader.accept(Unknown Source)
	at com.google.devtools.build.android.desugar.DefaultMethodClassFixer.defaultMethodsDefined(DefaultMethodClassFixer.java:319)
	at com.google.devtools.build.android.desugar.DefaultMethodClassFixer.visitEnd(DefaultMethodClassFixer.java:88)
	at org.objectweb.asm.ClassVisitor.visitEnd(Unknown Source)
	at com.google.devtools.build.android.desugar.InterfaceDesugaring.visitEnd(InterfaceDesugaring.java:85)
	at org.objectweb.asm.ClassVisitor.visitEnd(Unknown Source)
	at com.google.devtools.build.android.desugar.LambdaDesugaring.visitEnd(LambdaDesugaring.java:150)
	at org.objectweb.asm.ClassReader.accept(Unknown Source)
	at org.objectweb.asm.ClassReader.accept(Unknown Source)
	at com.google.devtools.build.android.desugar.Desugar.desugarClassesInInput(Desugar.java:401)
	at com.google.devtools.build.android.desugar.Desugar.desugarOneInput(Desugar.java:326)
	at com.google.devtools.build.android.desugar.Desugar.desugar(Desugar.java:280)
	at com.google.devtools.build.android.desugar.Desugar.main(Desugar.java:584)


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithDesugarForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.google.devtools.build.android.desugar.Desugar with arguments {--input /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/21.jar --output /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/desugar/debug/23.jar --input /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/45.jar --output /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/desugar/debug/47.jar --input /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/39.jar --output /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/desugar/debug/41.jar --input /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/40.jar --output /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/desugar/debug/42.jar --input /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/classes/debug --output /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/desugar/debug/1 --input /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/5.jar --output /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/desugar/debug/7.jar --input /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/35.jar --output /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/desugar/debug/37.jar --input /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/27.jar --output /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/desugar/debug/29.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/CordovaLib/build/intermediates/intermediate-jars/debug/classes.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/classes/debug --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/0.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/1.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/2.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/3.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/4.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/5.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/6.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/7.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/8.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/9.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/10.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/11.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/12.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/13.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/14.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/15.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/16.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/17.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/18.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/19.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/20.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/21.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/22.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/23.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/24.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/25.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/26.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/27.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/28.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/29.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/30.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/31.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/32.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/33.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/34.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/35.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/36.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/37.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/38.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/39.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/40.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/41.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/42.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/43.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/44.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/45.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/46.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/47.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/48.jar --classpath_entry /home/rodrigo/projects/myApp/platforms/android/app/build/intermediates/transforms/stackFramesFixer/debug/49.jar --bootclasspath_entry /opt/android-studio/platforms/android-26/android.jar --bootclasspath_entry /opt/android-studio/platforms/android-26/optional/org.apache.http.legacy.jar --bootclasspath_entry /usr/local/jdk1.8.0_171/jre/lib/resources.jar --bootclasspath_entry /usr/local/jdk1.8.0_171/jre/lib/rt.jar --bootclasspath_entry /usr/local/jdk1.8.0_171/jre/lib/jsse.jar --bootclasspath_entry /usr/local/jdk1.8.0_171/jre/lib/jce.jar --bootclasspath_entry /usr/local/jdk1.8.0_171/jre/lib/charsets.jar --bootclasspath_entry /usr/local/jdk1.8.0_171/jre/lib/jfr.jar --min_sdk_version 19 --nodesugar_try_with_resources_if_needed --desugar_try_with_resources_omit_runtime_classes}

* 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 9s
    at ChildProcess.whenDone (/home/rodrigo/projects/myApp/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
(node:8709) 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:8709) [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.

No, that is absolutely not necessary. cordova-android 7.1.1 (the current version) also supports Android 4.4.x: https://cordova.apache.org/docs/en/8.x/guide/platforms/android/index.html#requirements-and-support

Your Cordova tooling seems to be out of date, which might be causing all kinds of problems.
You can read about how to figure out the current Cordova versions and how to update CLI, platforms and plugins here: https://ionic.zone/cordova/update

Thank you very much!

First I ran “npm update -g cordova ionic”.

$ ionic info
✔ Gathering environment info - done!

Ionic:

   ionic (Ionic CLI)  : 4.1.1 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.1.9

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 6.0.0
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 1.2.1, (and 5 other plugins)

System:

   NodeJS : v8.10.0 (/usr/bin/node)
   npm    : 6.1.0
   OS     : Linux 4.15

Then I removed “platforms” directory and I ran again “ionic cordova platform add android@latest”. No errors were found now.

$ ionic cordova platform add android@latest
> cordova platform add android@latest --save
Using cordova-fetch for cordova-android@latest
Adding android project...
Creating Cordova project for the Android platform:
	Path: platforms/android
	Package: studiopilates.guari.com.br
	Name: Studio_Pilates
	Activity: MainActivity
	Android target: android-27
Android project created with cordova-android@7.1.1
Android Studio project detected
Android Studio project detected
Installing "com-badrit-base64" for android
Installing "cordova-plugin-device" for android
Installing "cordova-plugin-firebase" for android
Subproject Path: CordovaLib
Subproject Path: app
Installing "cordova-plugin-ionic-keyboard" for android
Installing "cordova-plugin-ionic-webview" for android
Installing "cordova-plugin-network-information" for android
Installing "cordova-plugin-splashscreen" for android
Installing "cordova-plugin-whitelist" for android

               This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in.
          
Preparing Firebase on Android
--save flag or autosave detected
Saving android@latest into config.xml file ...

But to not say that all was bed of roses, after I ran “ionic serve -c” I’ve found the following errors:

$ ionic serve -c
> ionic-app-scripts serve --address 0.0.0.0 --port 8100 --livereload-port 35729 --dev-logger-port 53703 --consolelogs --nobrowser
[app-scripts] [15:53:52]  ionic-app-scripts 3.1.9 
[app-scripts] [15:53:52]  watch started ... 
[app-scripts] [15:53:52]  build dev started ... 
[app-scripts] [15:53:53]  clean started ... 
[app-scripts] [15:53:53]  clean finished in 5 ms 
[app-scripts] [15:53:53]  copy started ... 
[app-scripts] [15:53:53]  copy finished in 158 ms 
[app-scripts] [15:53:53]  deeplinks started ... 
[app-scripts] [15:53:53]  deeplinks finished in 361 ms 
[app-scripts] [15:53:53]  transpile started ... 
[app-scripts] [15:53:58]  typescript: src/app/app.component.ts, line: 5 
[app-scripts]             Cannot find module 'angularfire2/auth'. 
[app-scripts]        L4:  import { SplashScreen } from '@ionic-native/splash-screen';
[app-scripts]        L5:  import { AngularFireAuth } from 'angularfire2/auth';
[app-scripts]        L6:  import { DesktopPage } from '../pages/desktop/desktop';

That I’ve solved with “npm install angularfire2 firebase --save”. Finally I ran: “ionic cordova emulate android”:

(...)

BUILD SUCCESSFUL in 4m 19s
46 actionable tasks: 46 executed
Built the following apk(s): 
	/home/rodrigo/projects/myApp/platforms/android/app/build/outputs/apk/debug/app-debug.apk
ANDROID_HOME=/opt/android-studio
JAVA_HOME=/opt/jdk
(node:14591) UnhandledPromiseRejectionWarning: CordovaError: No emulator images (avds) found.
1. Download desired System Image by running: /home/rodrigo/Android/Sdk/tools/android sdk
2. Create an AVD by running: /home/rodrigo/Android/Sdk/tools/android avd
HINT: For a faster emulator, use an Intel System Image and install the HAXM device driver

    at /home/rodrigo/projects/myApp/platforms/android/cordova/lib/emulator.js:290:29
    at _fulfilled (/home/rodrigo/projects/myApp/platforms/android/cordova/node_modules/q/q.js:834:54)
    at self.promiseDispatch.done (/home/rodrigo/projects/myApp/platforms/android/cordova/node_modules/q/q.js:863:30)
    at Promise.promise.promiseDispatch (/home/rodrigo/projects/myApp/platforms/android/cordova/node_modules/q/q.js:796:13)
    at /home/rodrigo/projects/myApp/platforms/android/cordova/node_modules/q/q.js:604:44
    at runSingle (/home/rodrigo/projects/myApp/platforms/android/cordova/node_modules/q/q.js:137:13)
    at flush (/home/rodrigo/projects/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:14591) 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:14591) [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.

I got the APK and I installed it into Android 4.4.2 and 8.0.0 typing “./adb install -r myApp.apk”. Now all is working fine! Thanks again!

1 Like