Skip to content
This repository was archived by the owner on Oct 31, 2022. It is now read-only.
This repository was archived by the owner on Oct 31, 2022. It is now read-only.

Issue when upgrading targetSdk and compileSdk to 29  #110

Closed

Description

@dobrowins

Project Setup

build.gradle

"gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.4, 0.99.99]"
"com.onesignal:OneSignal:[3.12.1, 3.99.99]"

Full Error

OneSignalPlugin: WARNING: OneSignalPlugin: Downgraded 'com.android.support:28.0.0' -> 28 to prevent compile errors! Recommend updating your project's compileSdkVersion!

CONFIGURE SUCCESSFUL in 1m 7s
ERROR: Failed to resolve: com.android.support:support-core-utils:28
Show in Project Structure dialog
Affected Modules: app

ERROR: Failed to resolve: com.android.support:design:28
Show in Project Structure dialog
Affected Modules: app

ERROR: Failed to resolve: com.android.support:appcompat-v7:28
Show in Project Structure dialog
Affected Modules: app

ERROR: Failed to resolve: com.android.support:recyclerview-v7:28
Show in Project Structure dialog
Affected Modules: app

ERROR: Failed to resolve: com.android.support:cardview-v7:28
Show in Project Structure dialog
Affected Modules: app

ERROR: Failed to resolve: com.android.support:support-v4:28
Show in Project Structure dialog
Affected Modules: app

ERROR: Failed to resolve: com.android.support:percent:28
Show in Project Structure dialog
Affected Modules: app

ERROR: Failed to resolve: com.android.support:exifinterface:28
Show in Project Structure dialog
Affected Modules: app

ERROR: Failed to resolve: com.android.support:support-emoji:28
Show in Project Structure dialog
Affected Modules: app

ERROR: Failed to resolve: com.android.support:support-v13:28
Show in Project Structure dialog
Affected Modules: app

ERROR: Failed to resolve: com.android.support:gridlayout-v7:28
Show in Project Structure dialog
Affected Modules: app

ERROR: Failed to resolve: com.android.support:support-annotations:28
Show in Project Structure dialog
Affected Modules: app

ERROR: Failed to resolve: com.android.support:support-compat:28
Show in Project Structure dialog
Affected Modules: app

ERROR: Failed to resolve: com.android.support:customtabs:28
Show in Project Structure dialog
Affected Modules: app

Compile time error after upgrading upgrading targetSdk and compileSdk to 29. Even though Q compatibility were supposed to be implemented in 0.12.3 (#92) — it seems that it is not.

Activity

  1. keyheha commented on Nov 13, 2019

    @keyheha

    I started with CompileSdkVersion 29, also got the same issue in latest version

    OneSignalPlugin: WARNING: OneSignalPlugin: Downgraded 'com.android.support:29.0.0' -> 28 to prevent compile errors! Recommend updating your project's compileSdkVersion!

  2. jkasten2 commented on Mar 17, 2020

    @jkasten2
    Contributor

    Google's last com.android.support library is 28. AndroidX should be used if you need to use API 29 features.

    In most cases you can ignore this warning.

    However if you are using AndroidX make sure you have Jetifier enabled by following this guide:
    https://developer.android.com/jetpack/androidx

    This is required when using OneSignal-Android-SDK 3.X.X.

  3. rborn commented on May 8, 2020

    @rborn

    @jkasten2 I still get this and I updated to last react native sdk and last gradle plugin.
    I have an issue another module that seems to behave badly with sdk 28 and it needs 29.

    Any way I could enforce this? Thank you

  4. beebase commented on Aug 13, 2020

    @beebase

    This is becoming critical. Google is going to force upgrade api level 29 soon.

    OneSignalPlugin: WARNING: OneSignalPlugin: Downgraded 'com.android.support:28.0.0' -> 28 to prevent compile errors! Recommend updating your project's compileSdkVersion!

  5. chancezeus commented on Aug 17, 2020

    @chancezeus
    Contributor

    This has become critical because in the meantime Google has started requiring use of api level 29. The cause of the problem is here https://github.com/OneSignal/OneSignal-Gradle-Plugin/blob/master/src/main/groovy/com/onesignal/androidsdk/GradleProjectPlugin.groovy#L532 and here https://github.com/OneSignal/OneSignal-Gradle-Plugin/blob/master/src/main/groovy/com/onesignal/androidsdk/GradleProjectPlugin.groovy#L535. Instead of returning a valid (maven/gradle) version code, only "28" is returned (not 28.0.0 or 28.+) which in turn cascades to every android support dependency referencing the wrong version (namely version "28" exactly, not 28.0.0)...

    Please fix this, because this makes a lot of our legacy (Cordova) Android projects impossible to build and it's almost impossible to rewrite every plugin in use to use AndroidX instead.

  6. chancezeus commented on Aug 17, 2020

    @chancezeus
    Contributor

    Just to let you know, I verified locally this works by simply adding a + ".+" to both lines, will add a PR against my test repo for it...

  7. beebase commented on Aug 17, 2020

    @beebase

    In fact, there was another cordova payment plugin causing the one signal plugin to throw the 28 warning. After removing the payment plugin, everything compiled ok with API 29.

  8. rborn commented on Aug 20, 2020

    @rborn

    @chancezeus thanks for this, do you know how we can use this in an existing project (react-native) where some other module depends on this one?
    😻

  9. chancezeus commented on Aug 20, 2020

    @chancezeus
    Contributor

    Unfortunately the only solution I found is to "install" the gradle plugin to local maven repo and modify the gradle file that includes it... As long as maintainers don't release new version to maven it's probably the only solution...

  10. rborn commented on Aug 20, 2020

    @rborn

    @chancezeus thank you

    @jkasten2 can we do something about this?

  11. rborn commented on Aug 20, 2020

    @rborn

    @chancezeus could you explain how you did it ? My android-fu is non-existent 😅 😻

  12. chancezeus commented on Aug 20, 2020

    @chancezeus
    Contributor

    Basically I followed these steps: https://github.com/OneSignal/OneSignal-Gradle-Plugin/blob/master/build.gradle#L93

    For the specifics of updating it in the react-native plugin, you'd have to check with a dev that knows about that, for Cordova I can simply edit the relevant file at plugins/onesignal-cordova-plugin/build-extras-onesignal.gradle, which would become:

    android.defaultConfig {
      manifestPlaceholders = [
        onesignal_app_id: '', // Use from js code
        onesignal_google_project_number: 'REMOTE'
      ]
    }
    
    // Required for Android Support Library 26.0.0+ and Google Play services 11.+
    repositories {
      maven { url 'https://maven.google.com' }
    }
    
    // Adding Onesignal-Gradle-Plugin to align gms, android support library, and firebase
    //   dependencies between other plugins.
    // Source for Onesignal-Gradle-Plugin: https://github.com/OneSignal/OneSignal-Gradle-Plugin
    buildscript {
      repositories {
        // See line 97 of build steps
        maven { url uri('{here comes the path to the archive build when following the steps from link above}')}
      }
      dependencies {
        // See line 100 of builld steps, the default line is incompatible with local build
        classpath 'com.onesignal:onesignal-gradle-plugin:[0.12.8, 0.99.99]'
      }
    }
    apply plugin: com.onesignal.androidsdk.GradleProjectPlugin

    For React Native you could probably apply something similar...

    Note this is by far not a clean solution, it's simply a temporary workaround so Cordova/React-Native/etc projects are still able to build without having to wait for all plugin devs to move to the new "AndroidX" support libraries...

  13. rborn commented on Aug 20, 2020

    @rborn

    @chancezeus thank you so much, I'll give it a shot soon and let you know. And yes, I know is not an "ideal" solution, but till we have it fixed we do what we can :)
    Thanks again 😻

  14. Jay031 commented on Aug 20, 2020

    @Jay031

    In fact, there was another cordova payment plugin causing the one signal plugin to throw the 28 warning. After removing the payment plugin, everything compiled ok with API 29.

    Same issue here. After executing:
    ionic cordova plugin rm cc.fovea.cordova.purchase

    It works again with API lvl 29.
    But I need the In App Purchase plugin.. Any ideas?

  15. chancezeus commented on Aug 20, 2020

    @chancezeus
    Contributor

    I build my fix (and use the posted workaround) actually for a similar situation, so for now, that is your solution. The real solution would be a patch update of the plugin on Maven but that would depend on @jkasten2 and/or OneSignal.

    I understand the general opinion regarding this (people should be using AndroidX when on api 29+), however for non-native developers using react native, cordova and/or similar frameworks, that is not always a solution since then they'd have to either update the plugins they use themselves and/or wait for the original developer to do so... And even though I'm a poly-glot when it comes to programming (languages), some of the projects I manage have more than a dozen plugins, most of which are not (yet) updated to use AndroidX, meaning that just fixing all those plugins myself would probably take me a week or more...

  16. Jay031 commented on Aug 21, 2020

    @Jay031

    I build my fix (and use the posted workaround) actually for a similar situation, so for now, that is your solution. The real solution would be a patch update of the plugin on Maven but that would depend on @jkasten2 and/or OneSignal.

    I understand the general opinion regarding this (people should be using AndroidX when on api 29+), however for non-native developers using react native, cordova and/or similar frameworks, that is not always a solution since then they'd have to either update the plugins they use themselves and/or wait for the original developer to do so... And even though I'm a poly-glot when it comes to programming (languages), some of the projects I manage have more than a dozen plugins, most of which are not (yet) updated to use AndroidX, meaning that just fixing all those plugins myself would probably take me a week or more...

    Can you help me out with this line?
    maven { url 'https://plugins.gradle.org/m2/'}
    Do I have to change it to:
    maven { url uri('../../repo') }

    Or how do I solve this? I'm not really experienced in this.
    I only get this SDK 29 issue when I have the "cc.fovea.cordova.purchase" plugin added.
    If I remove that I don't get a OneSignal error anymore...

  17. chancezeus commented on Aug 21, 2020

    @chancezeus
    Contributor

    I build my fix (and use the posted workaround) actually for a similar situation, so for now, that is your solution. The real solution would be a patch update of the plugin on Maven but that would depend on @jkasten2 and/or OneSignal.
    I understand the general opinion regarding this (people should be using AndroidX when on api 29+), however for non-native developers using react native, cordova and/or similar frameworks, that is not always a solution since then they'd have to either update the plugins they use themselves and/or wait for the original developer to do so... And even though I'm a poly-glot when it comes to programming (languages), some of the projects I manage have more than a dozen plugins, most of which are not (yet) updated to use AndroidX, meaning that just fixing all those plugins myself would probably take me a week or more...

    Can you help me out with this line?
    maven { url 'https://plugins.gradle.org/m2/'}
    Do I have to change it to:
    maven { url uri('../../repo') }

    As indicated in the code segment here #110 (comment) you must change it to the path where the plugin got copied to, if it's indeed in ../../repo (relative to the installed gradle script) you can use that, otherwise you should put in the path that points to the exact folder where the compiled plugin resides (if (I assume windows here, but I'm not a windows user so I might be wrong regarding the exact paths, but it should give you an indication) for example the folder is in C:\Users\UserNameHere\My Documents\repo and your project is in C:\Projects\ProjectNameHere you should either enter C:/User/UserNameHere/My Documents/repo or ../../Users/UserNameHere/My Documents/repo).

    Or how do I solve this? I'm not really experienced in this.
    I only get this SDK 29 issue when I have the "cc.fovea.cordova.purchase" plugin added.
    If I remove that I don't get a OneSignal error anymore...

  18. chancezeus commented on Aug 21, 2020

    @chancezeus
    Contributor

    Or how do I solve this? I'm not really experienced in this.
    I only get this SDK 29 issue when I have the "cc.fovea.cordova.purchase" plugin added.
    If I remove that I don't get a OneSignal error anymore...

    The plugin needs to be updated to use AndroidX instead of "android.support", so if you have limited to no experience programming java and/or Android, all you can do is send put an issue on their Github asking the dev to update the plugin to use AndroidX instead of "android.support"...

  19. beebase commented on Aug 21, 2020

    @beebase

    @chancezeus I replaced "cc.fovea.cordova.purchase" with "cordova-plugin-purchase".
    It's a replacement for fovea and works ok. I didn't have to change any code.

    j3k0/cordova-plugin-purchase#1086

  20. exneval commented on Aug 27, 2020

    @exneval

    any updates of #135 ?

  21. Topiya commented on Aug 29, 2020

    @Topiya

    @chancezeus I am using one-signal plugin in ionic 5 project and facing same issue. Currently build-extras-onesignal.gradle file (path: plugins\onesignal-cordova-plugin) is same like you have described. But still getting same error. Is there any solution for this ?

  22. dariocarbone commented on Sep 14, 2020

    @dariocarbone

    I build my fix (and use the posted workaround) actually for a similar situation, so for now, that is your solution. The real solution would be a patch update of the plugin on Maven but that would depend on @jkasten2 and/or OneSignal.
    I understand the general opinion regarding this (people should be using AndroidX when on api 29+), however for non-native developers using react native, cordova and/or similar frameworks, that is not always a solution since then they'd have to either update the plugins they use themselves and/or wait for the original developer to do so... And even though I'm a poly-glot when it comes to programming (languages), some of the projects I manage have more than a dozen plugins, most of which are not (yet) updated to use AndroidX, meaning that just fixing all those plugins myself would probably take me a week or more...

    Can you help me out with this line?
    maven { url 'https://plugins.gradle.org/m2/'}
    Do I have to change it to:
    maven { url uri('../../repo') }

    As indicated in the code segment here #110 (comment) you must change it to the path where the plugin got copied to, if it's indeed in ../../repo (relative to the installed gradle script) you can use that, otherwise you should put in the path that points to the exact folder where the compiled plugin resides (if (I assume windows here, but I'm not a windows user so I might be wrong regarding the exact paths, but it should give you an indication) for example the folder is in C:\Users\UserNameHere\My Documents\repo and your project is in C:\Projects\ProjectNameHere you should either enter C:/User/UserNameHere/My Documents/repo or ../../Users/UserNameHere/My Documents/repo).

    Or how do I solve this? I'm not really experienced in this.
    I only get this SDK 29 issue when I have the "cc.fovea.cordova.purchase" plugin added.
    If I remove that I don't get a OneSignal error anymore...

    any chanche someone could indicate a correct path in windows cordova environment? i was unable to find the repo directory anywhere .... thank you

  23. gauravpitaliya commented on Sep 29, 2020

    @gauravpitaliya

    I think changes to be needed that are fixed in #92 . In the file - src/main/groovy/com/onesignal/androidsdk/GradleProjectPlugin.groovy and line no - 532 and 535 should not return directly the variable (LAST_MAJOR_ANDROID_SUPPORT_VERSION). It should be - maxSupportVersionObj[LAST_MAJOR_ANDROID_SUPPORT_VERSION].

    Can anyone fix this and pushed on latest version ? It will be very helpful.

    UPDATE: - @jkasten2 Please do the needful or let me know if it has been fixed in any latest release. Its very critical at my end.

  24. jkasten2 commented on Oct 12, 2020

    @jkasten2
    Contributor

    This is now fixed in the latest 0.12.9 release!
    Thanks for the reports and thanks to @chancezeus PR #135 to fix this
    https://github.com/OneSignal/OneSignal-Gradle-Plugin/releases/tag/0.12.9

  25. rborn commented on Oct 14, 2020

    @rborn

    @jkasten2 sorry to continue with this, but I still seem to have the issue.
    I'm using the react-native module 3.9.1.

    I there anything I need to do to make use of the last version?

  26. jkasten2 commented on Oct 29, 2020

    @jkasten2
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions