Ionic cordova build android issue not working in cordova in browser working fine

#1

Pleas Help me if

MY Logs are

> ionic-app-scripts build --target cordova --platform android
[00:21:26]  ionic-app-scripts 3.1.11
[00:21:26]  build dev started ...
[00:21:26]  clean started ...
[00:21:26]  clean finished in 26 ms
[00:21:26]  copy started ...
[00:21:27]  deeplinks started ...
[00:21:27]  deeplinks finished in 124 ms
[00:21:27]  transpile started ...
[00:21:32]  transpile finished in 5.62 s
[00:21:32]  preprocess started ...
[00:21:32]  preprocess finished in 2 ms
[00:21:32]  webpack started ...
[00:21:33]  copy finished in 6.05 s
[00:21:38]  webpack finished in 5.72 s
[00:21:38]  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.
[00:21:40]  sass finished in 1.83 s
[00:21:40]  postprocess started ...
[00:21:40]  postprocess finished in 14 ms
[00:21:40]  lint started ...
[00:21:40]  build dev finished in 13.60 s
[00:21:44]  tslint: F:/Ionic Project/APP/Direct Home/DirectHome/src/providers/Utils.ts, line: 1
            'NgZone' is declared but its value is never read.

       L1:  import { Injectable, NgZone } from '@angular/core';
[00:21:44]  tslint: F:/Ionic Project/APP/Direct Home/DirectHome/src/app/app.component.ts, line: 19
       L2:  import { NativeStorage } from '@ionic-native/native-storage';

            Property 'firebase' is declared but its value is never
read.

      L18:    SplashScreen,
      L19:    private firebase: Firebase,
      L20:  public util:Utils) {

[00:21:44]  tslint: F:/Ionic Project/APP/Direct Home/DirectHome/src/app/app.component.ts, line: 6
            All imports on this line are unused.

       L6:  import { HomePage } from '../pages/home/home';
       L7:  import { LoginPage } from '../pages/login/login';

[00:21:44]  lint finished in 4.35 s
> cordova build android
cordova-android-play-services-gradle-release: Android platform: cordova-android@7
cordova-android-play-services-gradle-release: Wrote custom version
'15.+' to F:\Ionic Project\APP\Direct Home\DirectHome\platforms\android\app\build.gradle
cordova-android-play-services-gradle-release: Wrote custom version
'15.+' to F:\Ionic Project\APP\Direct Home\DirectHome\platforms\android\app\cordova-android-play-services-gradle-release\properties.gradle
Android Studio project detected
cordova-android-play-services-gradle-release: Android platform: cordova-android@7
cordova-android-play-services-gradle-release: Wrote custom version
'15.+' to F:\Ionic Project\APP\Direct Home\DirectHome\platforms\android\app\build.gradle
cordova-android-play-services-gradle-release: Wrote custom version
'15.+' to F:\Ionic Project\APP\Direct Home\DirectHome\platforms\android\app\cordova-android-play-services-gradle-release\properties.gradle
Preparing Firebase on Android
ANDROID_HOME=F:\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_171
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.
+-----------------------------------------------------------------
| cordova-android-play-services-gradle-release: 15.+
+-----------------------------------------------------------------
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_84ex3ohmohh4mxdcxncyer28k.run(F:\Ionic Project\APP\Direct Home\DirectHome\platforms\android\app\build.gradle:146)
: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 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

* 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

37 actionable tasks: 1 executed, 36 up-to-date
BUILD FAILED in 10s
(node:4736) UnhandledPromiseRejectionWarning: Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

* 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 10s
    at ChildProcess.whenDone (F:\Ionic Project\APP\Direct Home\DirectHome\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:4736) 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:4736) [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.

Package.json

{
  "name": "DirectHome",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "start": "ionic-app-scripts serve",
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint"
  },
  "dependencies": {
    "@angular/animations": "5.2.11",
    "@angular/common": "5.2.11",
    "@angular/compiler": "5.2.11",
    "@angular/compiler-cli": "5.2.11",
    "@angular/core": "5.2.11",
    "@angular/forms": "5.2.11",
    "@angular/http": "5.2.11",
    "@angular/platform-browser": "5.2.11",
    "@angular/platform-browser-dynamic": "5.2.11",
    "@ionic-native/background-geolocation": "^4.11.0",
    "@ionic-native/core": "~4.11.0",
    "@ionic-native/firebase": "^4.11.0",
    "@ionic-native/geolocation": "^4.11.0",
    "@ionic-native/native-storage": "^4.11.0",
    "@ionic-native/splash-screen": "~4.11.0",
    "@ionic-native/status-bar": "~4.11.0",
    "@ionic/storage": "2.1.3",
    "cordova-android": "7.0.0",
    "cordova-android-play-services-gradle-release": "^1.4.3",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-firebase": "^1.0.5",
    "cordova-plugin-geolocation": "^4.0.1",
    "cordova-plugin-ionic-keyboard": "^2.1.2",
    "cordova-plugin-ionic-webview": "^2.0.3",
    "cordova-plugin-mauron85-background-geolocation": "^2.3.5",
    "cordova-plugin-nativestorage": "^2.3.2",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "ionic-angular": "3.9.2",
    "ionicons": "3.0.0",
    "rxjs": "5.5.11",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "3.1.11",
    "typescript": "~2.6.2"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-geolocation": {
        "GEOLOCATION_USAGE_DESCRIPTION": "To locate you"
      },
      "cordova-plugin-nativestorage": {},
      "cordova-plugin-mauron85-background-geolocation": {},
      "cordova-plugin-firebase": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {},
      "cordova-plugin-ionic-keyboard": {},
      "cordova-android-play-services-gradle-release": {
        "PLAY_SERVICES_VERSION": "15.+"
      }
    },
    "platforms": [
      "android"
    ]
  }
}
#2

What is your ionic info output?

#3

i am new in ionic please let me know how to get this?

#4

Run ionic info in your projects folder on the command line.

#5

Ionic:

ionic (Ionic CLI) : 4.1.0 (C:\Users\GeeksEra\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.1.11

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 2.0.3, (and 7 other plugins)

System:

Android SDK Tools : 26.1.1
NodeJS : v8.11.1 (C:\Program Files\nodejs\node.exe)
npm : 6.3.0
OS : Windows 10

Environment:

ANDROID_HOME : F:\sdk

#6

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

Also: What does ionic cordova plugin list return?

#7

cordova-plugin-device 2.0.2 “Device”
cordova-plugin-firebase 1.0.5 “Google Firebase Plugin”
cordova-plugin-geolocation 4.0.1 “Geolocation”
cordova-plugin-ionic-keyboard 2.1.2 "cordova-plugin-ionic-keyboard"cordova-plugin-ionic-webview 2.0.3 “cordova-plugin-ionic-webview”
cordova-plugin-mauron85-background-geolocation 2.3.5 “CDVBackgroundGeolocation”
cordova-plugin-nativestorage 2.3.2 “NativeStorage”
cordova-plugin-splashscreen 5.0.2 “Splashscreen”
cordova-plugin-whitelist 1.3.3 “Whitelist”
net.js:714
throw new TypeError(
^

TypeError: Invalid data, chunk must be a string or buffer, not object
at WriteStream.Socket.write (net.js:714:11)
at process. (C:\Users\GeeksEra\AppData\Roaming\npm\node_modules\ionic\bin\ionic:9:63)
at emitTwo (events.js:126:13)
at process.emit (events.js:214:7)
at emitPendingUnhandledRejections (internal/process/promises.js:108:22)
at process._tickCallback (internal/process/next_tick.js:189:7)

#8

Does it work with a new project created with ionic start?

#9

yes now i created a new project and copy paste code
but i have never added plugin firebase for fcm token and location tracker service

i know it will stop working after adding these to for single location tracker it will work but
after adding firebase lol .

#10

So does it work for a newly created project on your system?
If so, just add stuff one by one and don’t copy paste - where does it break?