OneSignal / OneSignal-Unity-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your Unity app with OneSignal. https://onesignal.com
Other
222 stars 61 forks source link

Unity: OneSignal + Admob build error - AndroidX Conflict #192

Closed Tonieh closed 5 years ago

Tonieh commented 5 years ago

Description: Hi I can't build a proyect using the last version of OneSignal and Admob.

Environment I'm using Unity 2019.1.7 , OneSignal 2.7.9, GoogleMobileAds 3.17.0, OpenJDK 1.8.0_152 When I build I get this error:

Execution failed for task ':checkDebugDuplicateClasses'.

java.lang.RuntimeException: java.lang.RuntimeException: Duplicate class android.support.customtabs.ICustomTabsCallback found in modules classes.jar (:androidx.browser.browser-1.0.0:) and classes.jar (:com.android.support.customtabs-27.1.1:)

Steps to Reproduce Issue:

Crear a new proyect. Switch platform to Android Install Admob and OneSignal Go to Assets->Play Services Resolver->Android resolver->ForceResolve Build Anything else: I tried diferent versions of Unity and OneSignal. Can't fix it

Log link: https://gist.github.com/Tonieh/ea834d1416db5551be218158d0833aeb


Additions by @jkasten2

Solution

Please follow the OneSignal AndroidX Unity guide to enable Jetifier and update Gradle settings.

ceceomer commented 5 years ago

which cpu type do you use? only arm7 or both of them (arm7 and arm64). also i get error when try to use arm64.

Tonieh commented 5 years ago

which cpu type do you use? only arm7 or both of them (arm7 and arm64). also i get error when try to use arm64.

Tested in mono with ARMv7 and IL2CPP with ARMv7, ARM64 and ARMv7/ARM64

SamiUllah42 commented 5 years ago

Struggling with same issue . using unity 2018.3.0 . tried many combinations of admob and onsignal sdks but no success

pandey623 commented 5 years ago

I am also facing this issue. I thought it was specific to me only. But here i found it being an open issue. Which is very recent. I request one signal team to look into this issue and resolve this issue ASAP.

rpassareti commented 5 years ago

having same problem using Unity 2018.2.9

rgomezp commented 5 years ago

Hi everyone, Thanks for your patience. We haven't updated the SDK since May, however, so something must have changed in another dependency. We are looking into this issue.

smartyGirlz commented 5 years ago

yes, i am also facing the same issue, however when i deleted the files causing conflicting dependencies , my game completely lagged in unity, (using aadmob V3.15 and tried with many combo. of one signal sdk)

rgomezp commented 5 years ago

@smartyGirlz , You tried with the previous version of Admob?

EDIT: I went ahead and tested with the latest GoogleMobileAds version and while the conflicting dependencies were found (see below), they were resolved at the Force Resolve step. I now see that you encountered the problem in version 3.17 (was this a typo?) Try updating to the newest version of GoogleMobileAds and return here if you are still running into the issue.

Follow up: what order did you import the plugins in?

Some conflicting dependencies were found.
The following dependency versions were modified:
com.android.support:customtabs:[26.0.0, 27.2.0[ --> com.android.support:customtabs:27.1.1@aar
com.android.support:support-v4:[26.0.0, 27.2.0[ --> com.android.support:support-v4:27.1.1@aar
com.google.android.gms:play-services-base:[10.2.1, 12.1.0[ --> com.google.android.gms:play-services-base:12.0.1@aar
com.google.android.gms:play-services-location:[10.2.1, 12.1.0[ --> com.google.android.gms:play-services-location:12.0.1@aar
com.google.firebase:firebase-messaging:[10.2.1, 12.1.0[ --> com.google.firebase:firebase-messaging:12.0.1@aar
mubshar1 commented 5 years ago

@rgomezp I did. The issue is not limited to any specific version of Admob, It's happing with all versions.

SamiUllah42 commented 5 years ago

@rgomezp Tested with all versions of admob . in different version of unity, with different jdks and android sdks versions . problem still there .

Zeeshananwar077 commented 5 years ago

I have also tried many different versions of GoogleMobileAds with a different version of play services, I also change my androidx libraries with conflicting and duplicated libraries but the issue stays as usual secondly, if I delete 3 or 4 libraries of com.android.support, everything works like playservices+admob except ONESIGNAL, below are the attached screen shots for more elaboration ss2 ss1

rgomezp commented 5 years ago

Hello all, What order are you importing the plugins in?

SamiUllah42 commented 5 years ago

@rgomezp tried both first admob then onesignal second first onsignal then admob .

rshamborovskyy commented 5 years ago

Same problem

rgomezp commented 5 years ago

I took a look at the unity-jar-resolver changelog and it contains the following info:

Android Resolver: Added initial Jetifier integration which simplifies migration to Jetpack (AndroidX) libraries in cases where all dependencies are managed by the Android Resolver. This can be enabled via the Use Jetifier option in the Assets > Play Services Resolver > Android Resolver > Settings menu. Caveats:

  1. If your project contains legacy Android Support Library .jar and .aar files, these files will need to be removed and replaced with references to artifacts on Maven via Dependencies.xml files so that the Jetifier can map them to Jetpack (AndroidX) libraries. For example, remove the file support-v4-27.0.2.jar and replace it with in a Dependencies.xml file.
  2. If your project contains .jar or .aar files that use the legacy Android Support Libraries, these will need to be moved into a local Maven repo See this guide and then these files should be removed from your Unity project and instead referenced via *Dependencies.xml files so that the Jetifier can patch them to reference the Jetpack libraries.

It seems this was around the time folks started reporting this issue (June 18th) so it may be related. Alternatively, it could have something to do with the multidex settings due to the error matching this exactly as reported in this stack overflow post

UPDATE: We have a valid workaround:

  1. Go to OneSignalDependencies.xml, you should see:

    <androidPackage spec="com.google.android.gms:play-services-base:[10.2.1, 12.1.0[" />
    <androidPackage spec="com.google.firebase:firebase-messaging:[10.2.1, 12.1.0["/>
    <androidPackage spec="com.google.android.gms:play-services-location:[10.2.1, 12.1.0[" />
    <androidPackage spec="com.android.support:support-v4:[26.0.0, 27.2.0[" />
    <androidPackage spec="com.android.support:customtabs:[26.0.0, 27.2.0[" />
  2. Have it ask for the following versions instead

    com.google.android.gms:play-services-base:16.0.0
    com.google.firebase:firebase-messaging:18.0.0
    com.google.android.gms:play-services-location:16.0.0
  3. Rebuild

Hopefully this works for folks!

smartyGirlz commented 5 years ago

Hello all, What order are you importing the plugins in?

first admob sdk, then imported one signal sdk ,(excluding the editor plugins to prevent duplication)

Zeeshananwar077 commented 5 years ago

could

I took a look at the unity-jar-resolver changelog and it contains the following info:

Android Resolver: Added initial Jetifier integration which simplifies migration to Jetpack (AndroidX) libraries in cases where all dependencies are managed by the Android Resolver. This can be enabled via the Use Jetifier option in the Assets > Play Services Resolver > Android Resolver > Settings menu. Caveats:

  1. If your project contains legacy Android Support Library .jar and .aar files, these files will need to be removed and replaced with references to artifacts on Maven via Dependencies.xml files so that the Jetifier can map them to Jetpack (AndroidX) libraries. For example, remove the file support-v4-27.0.2.jar and replace it with in a Dependencies.xml file.
  2. If your project contains .jar or .aar files that use the legacy Android Support Libraries, these will need to be moved into a local Maven repo See this guide and then these files should be removed from your Unity project and instead referenced via *Dependencies.xml files so that the Jetifier can patch them to reference the Jetpack libraries.

It seems this was around the time folks started reporting this issue (June 18th) so it may be related. Alternatively, it could have something to do with the multidex settings due to the error matching this exactly as reported in this stack overflow post

UPDATE: We have a valid workaround:

  1. Go to OneSignalDependencies.xml, you should see:
<androidPackage spec="com.google.android.gms:play-services-base:[10.2.1, 12.1.0[" />
<androidPackage spec="com.google.firebase:firebase-messaging:[10.2.1, 12.1.0["/>
<androidPackage spec="com.google.android.gms:play-services-location:[10.2.1, 12.1.0[" />
<androidPackage spec="com.android.support:support-v4:[26.0.0, 27.2.0[" />
<androidPackage spec="com.android.support:customtabs:[26.0.0, 27.2.0[" />
  1. Have it ask for the following versions instead
com.google.android.gms:play-services-base:16.0.0
com.google.firebase:firebase-messaging:18.0.0
com.google.android.gms:play-services-location:16.0.0
  1. Rebuild

Hopefully this works for folks!

Could you please what android resolver we should go with for resolving libraries?

Zeeshananwar077 commented 5 years ago

okay so i have tried this work around solution, no doubt it is a work around solution where everything works but ONE SIGNAL :p so kindly ONESIGNAL team should take it seriously otherwise i will surely going to use something else instead of ONE Signal as i have a huge retention and one signal was always my first priority...but its a shame that one signal dont care about dere customers....

rshamborovskyy commented 5 years ago

So I've changed my dependencies to this.

<dependencies>
  <androidPackages>
    <androidPackage spec="com.google.android.gms:play-services-base:16.0.0" />
    <androidPackage spec="com.google.firebase:firebase-messaging:18.0.0"/>
    <androidPackage spec="com.google.android.gms:play-services-location:16.0.0" />
    <androidPackage spec="com.android.support:support-v4:[26.0.0, 27.2.0[" />
    <androidPackage spec="com.android.support:customtabs:[26.0.0, 27.2.0[" />
  </androidPackages>
</dependencies>

Force resolved. Resolution succeeded. But still same message: D8: Program type already present: android.support.customtabs.ICustomTabsCallback

About whole Jetifier thing I think I'm too noob to understand what has to be done.

UPDATE: Ok it worked out after I checked Jetifier in settings to ON. Many thanks. But I agree with Zeeshananwar077 though, it has to be easier.

Zeeshananwar077 commented 5 years ago

So I've changed my dependencies to this.

<dependencies>
  <androidPackages>
    <androidPackage spec="com.google.android.gms:play-services-base:16.0.0" />
    <androidPackage spec="com.google.firebase:firebase-messaging:18.0.0"/>
    <androidPackage spec="com.google.android.gms:play-services-location:16.0.0" />
    <androidPackage spec="com.android.support:support-v4:[26.0.0, 27.2.0[" />
    <androidPackage spec="com.android.support:customtabs:[26.0.0, 27.2.0[" />
  </androidPackages>
</dependencies>

Force resolved. Resolution succeeded. But still same message: D8: Program type already present: android.support.customtabs.ICustomTabsCallback

About whole Jetifier thing I think I'm too noob to understand what has to be done.

UPDATE: Ok it worked out after I checked Jetifier in settings to ON. Many thanks. But I agree with Zeeshananwar077 though, it has to be easier.

Hi dere, "Ok it worked out after I checked Jetifier in settings to ON." would you please explain this because for one signal didnt worked at all, in sample scene i tried to Get TEST NOTIFCATIOn but it logged NOTIFICATION FAILED something like that, also if you have successful result than kindly share details about one signal version admob version and playservices version and more especially the PLAYSERVICERESOLVER version for all of this and also the sequence in which you import these diferent plugin in your Unity project...

rshamborovskyy commented 5 years ago

Admob this version (and it was imported first, don't know if that matters): Google Mobile Ads Unity Plugin v3.18 https://github.com/googleads/googleads-mobile-unity/releases/tag/3.18.0

OneSignal imported as second one: 2.7.9 Release (latest) https://github.com/OneSignal/OneSignal-Unity-SDK/releases

Resolver v1.2.119.0

After that I:

Build successfull, run on Xiaomi MiPad 2. Press TestNotification. It says notification successfully sent. Delay 30 seconds. Notification also appears on OneSignal website in "ALL MESSAGES".

But... At the moment when it has to be displayed on device, my app crashes (no matter if app is on foreground or background) :( Website says its delivered. But maybe it's my device problem. Will test on something better soon.

This is what I get in logcat when that happens.

W/dalvikvm( 8673): Unable to resolve superclass of Lcom/onesignal/GcmBroadcastReceiver; (472)
W/dalvikvm( 8673): Link of class 'Lcom/onesignal/GcmBroadcastReceiver;' failed
W/dalvikvm( 8673): threadid=1: thread exiting with uncaught exception (group=0x41740ba8)
W/ActivityManager(  890):   Force finishing activity com.uaplay.scrabbleua/com.unity3d.player.UnityPlayerActivity
SamiUllah42 commented 5 years ago

I took a look at the unity-jar-resolver changelog and it contains the following info:

Android Resolver: Added initial Jetifier integration which simplifies migration to Jetpack (AndroidX) libraries in cases where all dependencies are managed by the Android Resolver. This can be enabled via the Use Jetifier option in the Assets > Play Services Resolver > Android Resolver > Settings menu. Caveats:

  1. If your project contains legacy Android Support Library .jar and .aar files, these files will need to be removed and replaced with references to artifacts on Maven via Dependencies.xml files so that the Jetifier can map them to Jetpack (AndroidX) libraries. For example, remove the file support-v4-27.0.2.jar and replace it with in a Dependencies.xml file.
  2. If your project contains .jar or .aar files that use the legacy Android Support Libraries, these will need to be moved into a local Maven repo See this guide and then these files should be removed from your Unity project and instead referenced via *Dependencies.xml files so that the Jetifier can patch them to reference the Jetpack libraries.

It seems this was around the time folks started reporting this issue (June 18th) so it may be related. Alternatively, it could have something to do with the multidex settings due to the error matching this exactly as reported in this stack overflow post

UPDATE: We have a valid workaround:

  1. Go to OneSignalDependencies.xml, you should see:
<androidPackage spec="com.google.android.gms:play-services-base:[10.2.1, 12.1.0[" />
<androidPackage spec="com.google.firebase:firebase-messaging:[10.2.1, 12.1.0["/>
<androidPackage spec="com.google.android.gms:play-services-location:[10.2.1, 12.1.0[" />
<androidPackage spec="com.android.support:support-v4:[26.0.0, 27.2.0[" />
<androidPackage spec="com.android.support:customtabs:[26.0.0, 27.2.0[" />
  1. Have it ask for the following versions instead
com.google.android.gms:play-services-base:16.0.0
com.google.firebase:firebase-messaging:18.0.0
com.google.android.gms:play-services-location:16.0.0
  1. Rebuild

Hopefully this works for folks!

Does not work for me either . kindly update sdk ASAP.

rgomezp commented 5 years ago

UPDATE: The unity-jar-resolver released a new version that includes a setting for turning on Jetifier

Here is the new changelog (notice the 3rd bullet):

To fix, do the following...

  1. Go to OneSignalDependencies.xml, you should see:

    <androidPackage spec="com.google.android.gms:play-services-base:[10.2.1, 12.1.0[" />
    <androidPackage spec="com.google.firebase:firebase-messaging:[10.2.1, 12.1.0["/>
    <androidPackage spec="com.google.android.gms:play-services-location:[10.2.1, 12.1.0[" />
    <androidPackage spec="com.android.support:support-v4:[26.0.0, 27.2.0[" />
    <androidPackage spec="com.android.support:customtabs:[26.0.0, 27.2.0[" />
  2. Have it ask for the following versions instead

    com.google.android.gms:play-services-base:16.0.0
    com.google.firebase:firebase-messaging:17.3.3
    com.google.android.gms:play-services-location:16.0.0

    * The versions should match for all the gms dependencies so open Assets > Play Services Resolver > Display Libraries and make sure you are changing any gms dependency to match your other existing gms dependencies (e.g: instead of 16.0.0). Same applies for any firebase dependencies.

  3. Download and unzip the latest PlayServicesResolver

  4. With Unity open, double click the play-services-resolver-1.2.121.0.unitypackage file

  5. Import the package and click "Ok" in the following prompt

  6. Go to Assets > Play Service Resolver > Android Resolver > Settings and check the Use Jetifier checkbox

  7. Go to File > Build Settings... then click on the "Player Settings..." button.

  8. From here go to Publishing Settings and check "Custom Gradle Template"

  9. Go to Assets > Play Services Resolver > Android Resolver > Settings and check "patch mainTemplate.gradle" and press OK.

  10. Restart Unity

  11. Build your project

We will be updating the PlayServicesResolver in the OneSignal-Unity-Plugin soon so you don't need to manually do this extra import. We are also seeing what can be done to not require having to manually enable Jetifier and the "Custom Gradle Template" settings noted above.

Enjoy!

NilokiloxD commented 5 years ago

@rgomezp using the new androidx libraries OneSignal does build but it's not working. After Initialization i can see an error in the logs telling me that no Android support library was found. This may be because the libs are now called something like "androidx.legacy.legacy-support-core-utils-1.0.0".

Manually deleting these androidx libraries and replacing them with the latest "old" version (28.0.0) leads to a different error like that the included Android support library is too old. please update to 26.0.0 or newer. Obviously 28 is newer than 26 and no 26.0.0 doesn't workt either.

What is the solution for for this error?

rgomezp commented 5 years ago

Did you try force-resolving? @NilokiloxD

NilokiloxD commented 5 years ago

Yes I did several time force resolve, this only helps for resolving conflicts between libraries but the sdk itself refuses to detect them when starting up as described above.

rgomezp commented 5 years ago

@NilokiloxD , I would try again, but I wouldn't delete the androidx libraries. Perhaps you didn't properly migrate to AndroidX

NilokiloxD commented 5 years ago

What else can I do but enabling jetifier in the play services resolver? I'm using firebase and admob as well and they work with the androidx libs but oneSignal doesn't. The runtime error is always the same, no android support library found. Maybe I missed something?

Edit: it's working now with custom gradle file, oneSignal was incompatible with the newest Google play services libraries pulled by admob (18.0.0). Forcing admob to use 16 as well solved the error.

Tonieh commented 5 years ago

UPDATE: The unity-jar-resolver released a new version that includes a setting for turning on Jetifier

Here is the new changelog (notice the 3rd bullet):

  • Android Resolver: Fixed warning about missing Packages folder when loading XML dependencies files in versions of Unity without the package manager.
  • Android Resolver: Fixed resolution window progress bar exceeding 100%.
  • Android Resolver: If AndroidX is detected in the set of resolved libraries, the user will be prompted to enable the Jetifier.
  • Android Resolver: Improved text splitting in text area windows.
  • iOS Resolver: Added support for Unity's breaking changes to the Xcode API in 2019.3.+. Cocoapods are now added to build targets, Unity-iPhone and UnityFramework in Unity 2019.3+.

To fix, do the following...

  1. Go to OneSignalDependencies.xml, you should see:
<androidPackage spec="com.google.android.gms:play-services-base:[10.2.1, 12.1.0[" />
<androidPackage spec="com.google.firebase:firebase-messaging:[10.2.1, 12.1.0["/>
<androidPackage spec="com.google.android.gms:play-services-location:[10.2.1, 12.1.0[" />
<androidPackage spec="com.android.support:support-v4:[26.0.0, 27.2.0[" />
<androidPackage spec="com.android.support:customtabs:[26.0.0, 27.2.0[" />
  1. Have it ask for the following versions instead
com.google.android.gms:play-services-base:16.0.0
com.google.firebase:firebase-messaging:18.0.0
com.google.android.gms:play-services-location:16.0.0
  1. Download and unzip the latest PlayServicesResolver
  2. With Unity open, double click the play-services-resolver-1.2.121.0.unitypackage file
  3. Import the package and click "Ok" in the following prompt
  4. Go to Assets > Play Service Resolver > Android Resolver > Settings and check the Use Jetifier checkbox
  5. Restart Unity
  6. Build your project

Enjoy!

Doesn't worked for me :( It compile but in the onesignal page the phone has this error: "Missing Android Support Library"

NilokiloxD commented 5 years ago

This is exactly what I wrote Tonieh, just read my comment there is the solution.

It should be enough to set the package dependencies of Google libs to 16 but in case this does not help, turn on custom gradle build, check patch gradle file in play services resolver settings and then edit this file after force resolve by changing all appearing Google play (also ads) libs down to 16.0.0.

The reason why it doesn't work with no custom gradle file is that play services resolver in case of conflicting library versions (in this case 18 and 16 of Google play) fallbacks to the latest version for both, but oneSignal fails with versions greater than 16. The error message with no support lib found is just incorrect and misleading for developers!

Hope that helps.

rshamborovskyy commented 5 years ago

@NilokiloxD. Thnx a lot buddy. I did it with editing dependencies manually in gradle like you said. Finally I am receiving notifications from their demo scene.

NilokiloxD commented 5 years ago

@rgomezp Any plans to update dependencies to 18.X+? Other plugins like admob request 18+ by default.

shefich commented 5 years ago

I have the same problem. When I'm trying to make build in unity 2018.4.2f1, it fails with error like this: "D8: Program type already present: android.support.customtabs.ICustomTabsCallback" I have Google Mobile Ads Unity Plugin v3.17 installed and OneSignal 2.7.9

So I tried to use the latest PlayServicesResolver alongside with changing dependecies of OneSignal and Admob to 16.0.0 but this gives me post build errors, like there are no such classes defined in dex path, because now they have "androidx.legacy" names. After that I downgarded to previous PlayServicesResolver 1.2.111.0 and tried to make build with dependencies changed to 16.0.0, but this also gives me "Program type already present" build errors.

Admob dependencies were changed in "GoogleMobileAdsDependencies" OneSignal in "OneSignalDependencies.xml"

What I am making wrong? Any help? @NilokiloxD @rgomezp

NilokiloxD commented 5 years ago

Delete customTabs library, it moved to androidx.browser. If you have old custom tabs lib and browser lib in your project you get this conflict. It should be removed automaticly normally if you enable jetifier in the Android resolver settings (v 1.22+)

shefich commented 5 years ago

@NilokiloxD as I can see, I don't have androidx.browser library in plugins/android folder

After deleting customtabs I get following error: "D8: Program type already present: android.support.v4.os.ResultReceiver$1"

Tested with old and new (1.2.122) Play Services Resolver.

NilokiloxD commented 5 years ago

Just delete all Android libraries, then enable jetifier, then force resolve and you will have no errors.

jkasten2 commented 5 years ago

@shefich @SamiUllah42 @Zeeshananwar077 In addition to @rgomezp https://github.com/OneSignal/OneSignal-Unity-SDK/issues/192#issuecomment-507457383 steps above you may need to do the following if you project isn't set this way already.

  1. Go to File > Build Settings... then click on the "Player Settings..." button.
  2. From here go to Publishing Settings and check "Custom Gradle Template"
  3. Go to Assets > Play Services Resolver > Android Resolver > Settings and check "patch mainTemplate.gradle" and press OK.

We will be updating the PlayServicesResolver in the OneSignal-Unity-Plugin soon so you don't need to manually do this extra import. We are also seeing what can be done to not require having to manually enable Jetifier and the "Custom Gradle Template" settings noted above.

mubshar1 commented 5 years ago

UPDATE: The unity-jar-resolver released a new version that includes a setting for turning on Jetifier

Here is the new changelog (notice the 3rd bullet):

  • Android Resolver: Fixed warning about missing Packages folder when loading XML dependencies files in versions of Unity without the package manager.
  • Android Resolver: Fixed resolution window progress bar exceeding 100%.
  • Android Resolver: If AndroidX is detected in the set of resolved libraries, the user will be prompted to enable the Jetifier.
  • Android Resolver: Improved text splitting in text area windows.
  • iOS Resolver: Added support for Unity's breaking changes to the Xcode API in 2019.3.+. Cocoapods are now added to build targets, Unity-iPhone and UnityFramework in Unity 2019.3+.

To fix, do the following...

  1. Go to OneSignalDependencies.xml, you should see:
<androidPackage spec="com.google.android.gms:play-services-base:[10.2.1, 12.1.0[" />
<androidPackage spec="com.google.firebase:firebase-messaging:[10.2.1, 12.1.0["/>
<androidPackage spec="com.google.android.gms:play-services-location:[10.2.1, 12.1.0[" />
<androidPackage spec="com.android.support:support-v4:[26.0.0, 27.2.0[" />
<androidPackage spec="com.android.support:customtabs:[26.0.0, 27.2.0[" />
  1. Have it ask for the following versions instead
com.google.android.gms:play-services-base:16.0.0
com.google.firebase:firebase-messaging:17.3.3
com.google.android.gms:play-services-location:16.0.0
  • The versions should match for all the gms dependencies so open Assets > Play Services Resolver > Display Libraries and make sure you are changing any gms dependency to match your other existing gms dependencies (e.g: instead of 16.0.0). Same applies for any firebase dependencies.
  1. Download and unzip the latest PlayServicesResolver
  2. With Unity open, double click the play-services-resolver-1.2.121.0.unitypackage file
  3. Import the package and click "Ok" in the following prompt
  4. Go to Assets > Play Service Resolver > Android Resolver > Settings and check the Use Jetifier checkbox
  5. Restart Unity
  6. Build your project

Enjoy!

It's not working for me. See SS attached onesignal

rgomezp commented 5 years ago

@mubshar1 , Please double check that Jetifier is checked. I have seen it uncheck itself for some reason.

NilokiloxD commented 5 years ago

It's not the jetifier @rgomezp as mentioned above, it's the fact that one signal does not support Google play services libraries 18.X, it hard requires 16.0 and since admob resolves to 18 the support library is not detected by the framework. Please provide support for 18.1 to avoid such errors.

pandey623 commented 5 years ago

When we will be getting updated package of One Signal to download? Which will Fix AndroidX library Issue.

bektasesref commented 5 years ago

Still waiting for new release. Commit by jkasten2 that updated to GoogleJarResolver 1.2.122.0 is capable to build the project but at the logcat we still get "Could not find the Android Support Library. Please make sure it has been correctly added to your project.".

andryint commented 5 years ago

@rgomezp Do you have estimated time of the update to fix the AndroidX issue?

rpassareti commented 5 years ago

Did everything on what rgomezp said and for me OneSignal is crashing the app on the first time is opened. the second time works normally. Didn't test to send a notification and see the result of it.

when disabled the class where I call onesignal, the app works without any crash

rgomezp commented 5 years ago

Howdy everyone, Please make sure you did this step (it sounds like you may have missed it):

@shefich @SamiUllah42 @Zeeshananwar077 In addition to @rgomezp #192 (comment) steps above you may need to do the following if you project isn't set this way already.

  1. Go to File > Build Settings... then click on the "Player Settings..." button.
  2. From here go to Publishing Settings and check "Custom Gradle Template"
  3. Go to Assets > Play Services Resolver > Android Resolver > Settings and check "patch mainTemplate.gradle" and press OK.

We will be updating the PlayServicesResolver in the OneSignal-Unity-Plugin soon so you don't need to manually do this extra import. We are also seeing what can be done to not require having to manually enable Jetifier and the "Custom Gradle Template" settings noted above.

We're working very hard to fix the AndroidX issue. Thanks, everybody for your patience

epsmarkh commented 5 years ago

Not working for us either with any of the above suggestions. We just see the following in logcat and notifications do not work:

07-19 14:46:58.707: I/zygote(1609): Rejecting re-init on previously-failed class java.lang.Class<com.onesignal.OneSignalChromeTab$OneSignalCustomTabsServiceConnection>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/customtabs/CustomTabsServiceConnection; 07-19 14:46:58.707: I/zygote(1609): at void com.onesignal.OneSignalChromeTab.setup(android.content.Context, java.lang.String, java.lang.String, java.lang.String) (OneSignalChromeTab.java:46) 07-19 14:46:58.707: I/zygote(1609): at void com.onesignal.OneSignal$7.run() (OneSignal.java:1181) 07-19 14:46:58.707: I/zygote(1609): at void java.lang.Thread.run() (Thread.java:764) 07-19 14:46:58.707: I/zygote(1609): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.customtabs.CustomTabsServiceConnection" on path: DexPathList[[zip file "/data/app/com.mgs.sniper1-uhMTC8-x1-gV6SDQcUewvg==/base.apk"],nativeLibraryDirectories=[/data/app/com.mgs.sniper1-uhMTC8-x1-gV6SDQcUewvg==/lib/arm, /data/app/com.mgs.sniper1-uhMTC8-x1-gV6SDQcUewvg==/base.apk!/lib/armeabi-v7a, /system/lib, /system/vendor/lib]] 07-19 14:46:58.707: I/zygote(1609): at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:93) 07-19 14:46:58.707: I/zygote(1609): at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379) 07-19 14:46:58.707: I/zygote(1609): at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312) 07-19 14:46:58.707: I/zygote(1609): at void com.onesignal.OneSignalChromeTab.setup(android.content.Context, java.lang.String, java.lang.String, java.lang.String) (OneSignalChromeTab.java:46) 07-19 14:46:58.707: I/zygote(1609): at void com.onesignal.OneSignal$7.run() (OneSignal.java:1181) 07-19 14:46:58.707: I/zygote(1609): at void java.lang.Thread.run() (Thread.java:764)

NilokiloxD commented 5 years ago

Still broken in 2.8.0,still no support for Google play lib 18.X thus still needing a custom gradle file. Dependencies xml pulls legacy libs as well. Why is it so difficult to support up to date libraries?

edumlauer commented 5 years ago

Just to add some more information. I followed the exact steps described on https://github.com/OneSignal/OneSignal-Unity-SDK/issues/192#issuecomment-507457383 and the first time the app launches it crashes with the following error:

Error AndroidRuntime: FATAL EXCEPTION: main
Error AndroidRuntime: Process: com.dupyx.cbfiller, PID: 10975
Error AndroidRuntime: java.lang.Error: FATAL EXCEPTION [main]
Error AndroidRuntime: Unity version     : 2019.1.11f1
Error AndroidRuntime: Device model      : samsung SM-G920F
Error AndroidRuntime: Device fingerprint: *removed*
Error AndroidRuntime: Caused by: java.lang.IllegalAccessError: Class com.google.firebase.iid.zzb extended by class com.google.firebase.messaging.FirebaseMessagingService is inaccessible (declaration of 'com.google.firebase.messaging.FirebaseMessagingService' appears in /data/app/com.dupyx.cbfiller-1/base.apk)
Error AndroidRuntime: at java.lang.VMClassLoader.findLoadedClass(Native Method)
Error AndroidRuntime: at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:742)
Error AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:362)
Error AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
Error AndroidRuntime: at android.app.ActivityThread.handleCreateService(ActivityThread.java:3446)
Error AndroidRuntime: at android.app.ActivityThread.-wrap6(ActivityThread.java)
Error AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1721)
Error AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
Error AndroidRuntime: at android.os.Looper.loop(Looper.java:154)
Error AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6682)
Error AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
Error AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
Error AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

When lauching a second time the app doesn't crash and the phone appears as a new valid user on One Signal website. When trying to send it a push message the app crashes with the same error:

Error AndroidRuntime: FATAL EXCEPTION: main
Error AndroidRuntime: Process: com.dupyx.cbfiller, PID: 24700
Error AndroidRuntime: java.lang.IllegalAccessError: Class com.google.firebase.iid.zzb extended by class com.google.firebase.messaging.FirebaseMessagingService is inaccessible (declaration of 'com.google.firebase.messaging.FirebaseMessagingService' appears in /data/app/com.dupyx.cbfiller-1/base.apk)
Error AndroidRuntime: at java.lang.VMClassLoader.findLoadedClass(Native Method)
Error AndroidRuntime: at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:742)
Error AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:362)
Error AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
Error AndroidRuntime: at android.app.ActivityThread.handleCreateService(ActivityThread.java:3446)
Error AndroidRuntime: at android.app.ActivityThread.-wrap6(ActivityThread.java)
Error AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1721)
Error AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
Error AndroidRuntime: at android.os.Looper.loop(Looper.java:154)
Error AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6682)
Error AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
Error AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
Error AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
rgomezp commented 5 years ago

Howdy everyone, It sounds like there is still a problem then. We are still investigating. Thanks for everyone's patience with this issue.

bipinGosain commented 5 years ago

@NilokiloxD Please help me in understanding this.

  1. turn on custom gradle build [done]

2.check patch gradle file in play services resolver settings [Done]

  1. and then edit this file after force resolve by changing all appearing Google play (also ads) libs down to 16.0.0.[what to change in gradle file?]

I have Unity Ads, Firebase Auth Messaging and Database in the project.

Also, the build fails after 2 of the above steps.

Error Log:

FAILURE: Build failed with an exception.

BUILD FAILED in 1s ] stdout[ NDK is missing a "platforms" directory. If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to C:\Users\Jack\AppData\Local\Android\Sdk\ndk-bundle. If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

]