apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.65k stars 1.54k forks source link

Android build failed with cordova-android@9.0.0 #1050

Closed devsgtech closed 4 years ago

devsgtech commented 4 years ago

Bug Report

Problem

What is expected to happen?

It is working fine when h build android application with cordova-android@8.0.0 but when i try cordova-android9 it throws error. Please help me solving out this build errors

What does actually happen?

WARNING: The onesignal-gradle-plugin MUST be before com.android.application! Please put onesignal-gradle-plugin first OR update to com.android.tools.build:gradle:3.0.0 or newer!

Task :app:mergeDebugResources

Task :app:mergeDebugResources FAILED :app:mergeDebugResources > Resolve dependencies of :app:debugRuntimeClasspath > appcompat-v7-28.pom FAILURE: Build failed with an exception.

BUILD FAILED in 48s 7 actionable tasks: 1 executed, 6 up-to-date Command failed with exit code 1: /Users/apple/Desktop/IonicProjects/JustoDelivery/platforms/android/gradlew cdvBuildDebug -b /Users/apple/Desktop/IonicProjects/JustoDelivery/platforms/android/build.gradle [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.

Information

I have tried with all ionic versions.. but problem is with cordova-android plugin

Command or Code

ionic cordova build android

Environment, Platform, Device

I am building android apk with api level 29 and it throws errors. I am able to build with api level 28 without any error.

Version information

Everything is up to date. Below is package file code

{
  "name": "ABC",
  "version": "0.0.8",
  "author": "Ionic Framework",
  "homepage": "https://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^8.2.14",
    "@angular/common": "~8.2.14",
    "@angular/core": "~8.2.14",
    "@angular/forms": "~8.2.14",
    "@angular/platform-browser": "~8.2.14",
    "@angular/platform-browser-dynamic": "~8.2.14",
    "@angular/router": "~8.2.14",
    "@ionic-native/android-permissions": "^5.22.0",
    "@ionic-native/app-version": "^5.23.0",
    "@ionic-native/barcode-scanner": "^5.27.0",
    "@ionic-native/camera": "^5.27.0",
    "@ionic-native/chooser": "^5.22.0",
    "@ionic-native/core": "^5.0.0",
    "@ionic-native/date-picker": "^5.22.0",
    "@ionic-native/file": "^5.22.0",
    "@ionic-native/file-opener": "^5.27.0",
    "@ionic-native/file-transfer": "^5.22.0",
    "@ionic-native/image-picker": "^5.22.0",
    "@ionic-native/keyboard": "^5.22.0",
    "@ionic-native/network": "^5.22.0",
    "@ionic-native/onesignal": "^5.27.0",
    "@ionic-native/printer": "^5.27.0",
    "@ionic-native/splash-screen": "^5.22.0",
    "@ionic-native/status-bar": "^5.22.0",
    "@ionic-native/toast": "^5.22.0",
    "@ionic/angular": "^4.11.10",
    "@ionic/cli": "^6.11.0",
    "@ionic/storage": "^2.2.0",
    "@stencil/core": "^1.10.3",
    "angular-cc-library": "^1.2.5",
    "cordova-ios": "5.1.1",
    "cordova-plugin-add-swift-support": "^2.0.2",
    "cordova-plugin-android-permissions": "^1.0.2",
    "cordova-plugin-app-version": "^0.1.9",
    "cordova-plugin-camera": "^4.1.0",
    "cordova-plugin-chooser": "^1.2.6",
    "cordova-plugin-datepicker": "^0.9.3",
    "cordova-plugin-file": "^6.0.2",
    "cordova-plugin-file-opener2": "^3.0.0",
    "cordova-plugin-file-transfer": "^1.7.1",
    "cordova-plugin-ionic-keyboard": "^2.2.0",
    "cordova-plugin-network-information": "^2.0.2",
    "cordova-plugin-printer": "^0.8.0",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-telerik-imagepicker": "^2.3.3",
    "cordova-plugin-x-toast": "^2.7.2",
    "core-js": "^2.5.4",
    "crypto-js": "^4.0.0",
    "firebase": "^7.17.1",
    "hammerjs": "^2.0.8",
    "moment": "^2.24.0",
    "moment-timezone": "^0.5.28",
    "ng-lazyload-image": "^7.1.0",
    "ng2-file-upload": "^1.4.0",
    "phonegap-plugin-barcodescanner": "^8.1.0",
    "rxjs": "~6.5.1",
    "tslib": "^1.9.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.803.20",
    "@angular/cli": "~8.3.23",
    "@angular/compiler": "~8.2.14",
    "@angular/compiler-cli": "~8.2.14",
    "@angular/language-service": "~8.2.14",
    "@ionic/angular-toolkit": "^2.1.1",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "^5.0.0",
    "cordova-android": "^9.0.0",
    "cordova-android-support-gradle-release": "~3.0.1",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-ionic-webview": "^5.0.0",
    "cordova-plugin-whitelist": "^1.3.3",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "onesignal-cordova-plugin": "^2.11.0",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~3.4.3"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "phonegap-plugin-barcodescanner": {
        "ANDROID_SUPPORT_V4_VERSION": "27.+"
      },
      "cordova-plugin-camera": {
        "ANDROID_SUPPORT_V4_VERSION": "27.+"
      },
      "cordova-plugin-file": {},
      "cordova-plugin-telerik-imagepicker": {},
      "cordova-plugin-ionic-keyboard": {},
      "cordova-plugin-network-information": {},
      "cordova-plugin-printer": {
        "ANDROID_SUPPORT_V4_VERSION": "28.+"
      },
      "cordova-plugin-x-toast": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-datepicker": {},
      "cordova-plugin-file-opener2": {
        "ANDROID_SUPPORT_V4_VERSION": "27.+"
      },
      "cordova-plugin-file-transfer": {},
      "cordova-plugin-android-permissions": {},
      "cordova-plugin-chooser": {},
      "cordova-plugin-app-version": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {},
      "cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "28.+"
      },
      "cordova-android-support-gradle-release": {},
      "onesignal-cordova-plugin": {}
    },
    "platforms": [
      "ios",
      "android"
    ]
  }
}

Checklist

breautek commented 4 years ago

You have plugins that are incompatible together.

onesignal-cordova-plugin is incompatible with cordova-plugin-printer

Both will build independently, but when used together they will not build. This is because onesignal-cordova-plugin doesn't appear to be compatible with version 28 of android support libraries, but cordova-plugin-printer requires them.

debugRuntimeClasspath - Resolved configuration for runtime for variant: debug
+--- project :CordovaLib
+--- com.onesignal:OneSignal:3.15.1
|    +--- com.google.firebase:firebase-messaging:[10.2.1, 17.3.99] -> 17.3.3
|    |    +--- com.google.android.gms:play-services-basement:16.0.1
|    |    |    \--- com.android.support:support-v4:26.1.0 -> 28 FAILED
|    |    +--- com.google.android.gms:play-services-tasks:16.0.1
|    |    |    \--- com.google.android.gms:play-services-basement:16.0.1 (*)
|    |    +--- com.google.firebase:firebase-common:16.0.3
|    |    |    +--- com.google.android.gms:play-services-basement:16.0.1 (*)
|    |    |    \--- com.google.android.gms:play-services-tasks:16.0.1 (*)
|    |    +--- com.google.firebase:firebase-iid:17.0.3
|    |    |    +--- com.google.android.gms:play-services-basement:16.0.1 (*)
|    |    |    +--- com.google.android.gms:play-services-stats:16.0.1
|    |    |    |    \--- com.google.android.gms:play-services-basement:16.0.1 (*)
|    |    |    +--- com.google.android.gms:play-services-tasks:16.0.1 (*)
|    |    |    +--- com.google.firebase:firebase-common:16.0.3 (*)
|    |    |    \--- com.google.firebase:firebase-iid-interop:16.0.1
|    |    |         +--- com.google.android.gms:play-services-base:16.0.1
|    |    |         |    +--- com.google.android.gms:play-services-basement:16.0.1 (*)
|    |    |         |    \--- com.google.android.gms:play-services-tasks:16.0.1 (*)
|    |    |         \--- com.google.android.gms:play-services-basement:16.0.1 (*)
|    |    \--- com.google.firebase:firebase-measurement-connector:17.0.1
|    |         \--- com.google.android.gms:play-services-basement:16.0.1 (*)
|    +--- com.android.support:cardview-v7:[26.0.0, 27.99.99] -> 28 FAILED
|    +--- com.android.support:support-fragment:[26.0.0, 27.99.99] -> 28 FAILED
|    +--- com.android.support:customtabs:[26.0.0, 27.99.99] -> 28 FAILED
|    +--- com.google.android.gms:play-services-location:[10.2.1, 16.0.99] -> 15.0.1
|    |    +--- com.google.android.gms:play-services-base:[15.0.1,16.0.0) -> 16.0.1 (*)
|    |    +--- com.google.android.gms:play-services-basement:[15.0.1,16.0.0) -> 16.0.1 (*)
|    |    +--- com.google.android.gms:play-services-places-placereport:[15.0.1,16.0.0) -> 15.0.1
|    |    |    \--- com.google.android.gms:play-services-basement:[15.0.1,16.0.0) -> 16.0.1 (*)
|    |    \--- com.google.android.gms:play-services-tasks:[15.0.1,16.0.0) -> 16.0.1 (*)
|    +--- com.google.android.gms:play-services-ads-identifier:[15.0.0, 16.0.99] -> 16.0.0
|    |    \--- com.google.android.gms:play-services-basement:16.0.1 (*)
|    \--- com.google.android.gms:play-services-base:[10.2.1, 16.1.99] -> 16.0.1 (*)
\--- com.android.support:support-v4:28.+ -> 28 FAILED

I am able to build with api level 28 without any error.

For me, targeting API 28 didn't change anything.

Your options are to:

You can do this by running the following commands:

cordova plugin remove cordova-plugin-printer
cordova plugin add cordova-plugin-printer --variable ANDROID_SUPPORT_V4_VERSION="27.+"

The above does allow me to build successfully, however I assume the default was set to 28 for a reason, and I don't know if this will cause runtime errors. If you take this approach, make sure you test your app thoroughly.

Because this isn't a bug with cordova-android I'll be closing this issue. If you need further assistance, I do invite you to our slack

devsgtech commented 4 years ago

I have removed printer plugin but still issue is same. I have removed onesignal plugin but issue is still same. Now what to do?