OneSignal / OneSignal-Cordova-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your Ionic, PhoneGap CLI, PhoneGap Build, Cordova, or Sencha Touch app with OneSignal. Supports Android, iOS, and Amazon's Fire OS platforms. https://onesignal.com
Other
250 stars 197 forks source link

BUILD FAILED - Could not determine the dependencies of task ':app:lintVitalRelease'. #654

Closed misog closed 3 years ago

misog commented 4 years ago

Description: Hi, my cordova app can not be build with OneSignal plugin. It works with cordova@8.1.0 (Android target: android-28) but it does not work with cordova@9.0.0 (Android target: android-29).

This is concerning because Google does not permit to release apps with target 28.

Environment OneSignal: 2.11.0 Cordova: 9.0.0 Android target: android-29

Steps to Reproduce Issue:

  1. Add the onesignal-cordova-plugin to your project
  2. Build the project

Console output:

Using cordova-fetch for cordova-android@^9.0.0
Adding android project...
Creating Cordova project for the Android platform:
        Path: platforms\android
        Package: xx.xxxxxxxxxx.xxxxxxxxxx
        Name: XXXXXX
        Activity: MainActivity
        Android target: android-29
Subproject Path: CordovaLib
Subproject Path: app
Android project created with cordova-android@9.0.0
Installing "cordova-plugin-app-version" for android
Installing "cordova-plugin-badge" for android
Subproject Path: CordovaLib
Subproject Path: app
Installing "cordova-plugin-camera" for android
Subproject Path: CordovaLib
Subproject Path: app
Installing "cordova-plugin-device" for android
Installing "cordova-plugin-file" for android

The Android Persistent storage location now defaults to "Internal". Please check this plugin's README to see if your application needs any changes in its config.xml.

If this is a new application no changes are required.

If this is an update to an existing application that did not specify an "AndroidPersistentFileLocation" you may need to add:

      "<preference name="AndroidPersistentFileLocation" value="Compatibility" />"

to config.xml in order for the application to find previously stored files.

Installing "cordova-plugin-geolocation" for android
Installing "cordova-plugin-inappbrowser" for android
Installing "cordova-plugin-ionic-keyboard" for android
Installing "cordova-plugin-ionic-webview" for android
Subproject Path: CordovaLib
Subproject Path: app
Installing "cordova-plugin-local-notification" for android
Plugin dependency "cordova-plugin-device@2.0.2" already fetched, using that version.
Dependent plugin "cordova-plugin-device" already installed on android.
Plugin dependency "cordova-plugin-badge@0.8.7" already fetched, using that version.
Dependent plugin "cordova-plugin-badge" already installed on android.
Subproject Path: CordovaLib
Subproject Path: app
Installing "cordova-plugin-nativestorage" for android
Installing "cordova-plugin-screen-orientation" for android
Plugin dependency "es6-promise-plugin@4.2.2" already fetched, using that version.
Installing "es6-promise-plugin" for android
Installing "cordova-plugin-splashscreen" for android
Installing "cordova-plugin-transport-security" 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.

Installing "cordova.plugins.diagnostic" for android
Subproject Path: CordovaLib
Subproject Path: app
Dependent plugin "es6-promise-plugin" already installed on android.
Installing "onesignal-cordova-plugin" for android
Subproject Path: CordovaLib
Subproject Path: app
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\AndroidSDK (DEPRECATED)
Using Android SDK: C:\AndroidSDK
> Task :wrapper

BUILD SUCCESSFUL in 3s
1 actionable task: 1 executed
Subproject Path: CordovaLib
Subproject Path: app

> Configure project :app
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed in version 5.0 of the Android Gradle plugin.
For more information, see http://d.android.com/r/tools/update-dependency-configurations.html.
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!
OneSignalPlugin: WARNING: OneSignalPlugin: Downgraded 'com.android.support:28.+' -> 28 to prevent compile errors! Recommend updating your project's compileSdkVersion!

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':app:debugCompileClasspath'.
   > Could not find com.android.support:support-v4:28.
     Required by:
         project :app
   > Could not find com.android.support:support-annotations:28.
     Required by:
         project :app
   > Could not find com.android.support:support-v4:28.
     Required by:
         project :app
   > Could not find com.android.support:support-v4:28.
     Required by:
         project :app
   > Could not find com.android.support:appcompat-v7:28.
     Required by:
         project :app
   > Could not find com.android.support:cardview-v7:28.
     Required by:
         project :app > com.onesignal:OneSignal:3.15.1
   > Could not find com.android.support:support-fragment:28.
     Required by:
         project :app > com.onesignal:OneSignal:3.15.1
   > Could not find com.android.support:customtabs:28.
     Required by:
         project :app > com.onesignal:OneSignal:3.15.1
   > Could not find com.android.support:support-v4:28.
     Required by:
         project :app > com.google.android.gms:play-services-basement:16.0.1

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

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

BUILD FAILED in 12s
Command failed with exit code 1: C:\xxxxxx\xxxxxx\platforms\android\gradlew cdvBuildRelease -b C:\xxxxxx\xxxxxx\android\build.gradle
Topiya commented 4 years ago

@misog I am facing the same problem. Did you find any solution?

misog commented 4 years ago

@misog I am facing the same problem. Did you find any solution?

The support replied to me:

Thanks for reaching out, our team is aware of this and a fix will be released in the next update, for now, you can add the following to the top of your app/build.gradle apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin' to solve the error WARNING: The onesignal-gradle-plugin MUST be before com.android.application! Let us know if that helps.

I did not try it yet. But I found a workaround:

Add <preference name="android-targetSdkVersion" value="29" /> to config.xml and then Google Play will accept the build even if you are using cordova@8.1.0 with target 28

Topiya commented 4 years ago

@misog Thank you. I will try with your suggestion.

candidoalbertosilva commented 3 years ago

I'm getting the same issue

rgomezp commented 3 years ago

Howdy,

You can add the following to the top of your app/build.gradle apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin' to solve the error WARNING: The onesignal-gradle-plugin MUST be before com.android.application!

Did folks try this? Please let us know if this worked for you.

If not, can anyone report back on the workaround proposed by misog @Topiya?

Thank you

Topiya commented 3 years ago

I have not tried to submit an app using cordova@8.1.0 since Google is asking for target 29.

dariocarbone commented 3 years ago

You can try to force android cordova version and stick with 8.1.0 (cordova platform add android@8.1.0) on android-targetSdkVersion=29: everything builds just fine and deployment on google console will be successful.

The only downside is that you should be really careful with plugins like cordova-plugin-camera: the new version 5.0.0 is no more compatible with cordova-android below 9.0.0.

In short words: the "workaround" here is fine, but I'm really looking forward an update, newer is (almost) ever better!

Topiya commented 3 years ago

@dariocarbone Thank you for the reply. I tried to put <preference name="android-targetSdkVersion" value="29" /> to config.xml. But it is not generating defaultTargetSdkVersion as 29 in build.gradle with cordova@8.1.0

project.ext {
      defaultBuildToolsVersion="28.0.3" //String
      defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
      defaultTargetSdkVersion=28 //Integer - We ALWAYS target the latest by default
      defaultCompileSdkVersion=28 //Integer - We ALWAYS compile with the latest by default
    }

Can you please let me know how to force android cordova version and stick with 8.1.0 ?

dariocarbone commented 3 years ago

you can launch from terminal: cordova platform remove android (then) cordova platform add android@8.1.0

Topiya commented 3 years ago

So you are telling to reinstall cordova-android@8.1.0 ? because currently I am doing build with cordova-android@8.1.0 only and it is showing defaultTargetSdkVersion=28 in build.gradle.

remove and adding cordova-android@8.1.0 again will generate defaultTargetSdkVersion=29 ?

dariocarbone commented 3 years ago

when i look into build.gradle the defaultTargetSdkVersion=28 but after deploying on google console the sdk target is 29...

Topiya commented 3 years ago

@misog @dariocarbone Thank you for providing this solution. It worked for me.

jkasten2 commented 3 years ago

Closing this issue to merge with #657

singkarak165 commented 3 years ago

anyone have this solution?

Peony007 commented 1 year ago

FAILURE: Build failed with an exception.

I want to know the way how to solve

Talha-Jawed commented 1 year ago

@CodingWarm any luck?

nan-li commented 1 year ago

Hi @CodingWarm, Your error mentions react native and this is the OneSignal Cordova SDK. I also don't see any reference to OneSignal in your error.