OneSignal / OneSignal-Xamarin-SDK

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

One Signal for Xamarin - how use with Android X? #219

Closed FetFrumos closed 3 years ago

FetFrumos commented 4 years ago

I using OneSignal(3.10.1) in my Xamarin Forms app. I have problem with android. I use some package I use several packages that need Android X. This is:

-BarcodeScanner.XF -Xam.Plugins.Android.ExoPlayer

But OneSignal using CompileSdkVersion - Android 9(Api Level 28). When I try install OneSignal in android project(for Android 10) than I get this error:

   BarcodeScanner.XF 4.8.0 -> Xamarin.Android.Support.Compat (>= 28.0.0.3) 
   Com.OneSignal 3.10.1 -> Xamarin.Android.Support.CustomTabs 26.0.2 -> Xamarin.Android.Support.Compat (= 26.0.2).  

So for the single packages I need Android X for the other ones - Android 9(CompileSdkVersion). How do I solve this problem and is it possible?

EmilAlipiev commented 3 years ago

It is not supporting yet. As you can see here, their original Android library still uses old Support libraries https://github.com/OneSignal/OneSignal-Android-SDK/blob/master/OneSignalSDK/onesignal/build.gradle

And this xamarin version is the wrapper of this android version.

jkasten2 commented 3 years ago

@FetFrumos @EmilAlipiev You can add Xamarin.AndroidX.Migration to your project if you have updated to AndroidX and need to use OneSignal. It allows for packages that are still using the "Android Support Library" to work with your project, like Jetifier does for Android Native projects. See their readme for more details. https://github.com/xamarin/AndroidX/tree/master/source/migration

We will soon have a major release 4.0.0 version beta to try out for Xamarin where it will be updated to use AndroidX as well going forward so this won't always be required.

QuangKhanDo commented 3 years ago

I have face the same issue, for me it's:

NU1107  Version conflict detected for Xamarin.Android.Support.Annotations. Install/reference Xamarin.Android.Support.Annotations 28.0.0.3 directly to project KApp.Android to resolve this issue. 
 KApp.Android -> Xamarin.Forms.Maps 4.8.0.1687 -> Xamarin.Android.Support.v4 28.0.0.3 -> Xamarin.Android.Support.Media.Compat 28.0.0.3 -> Xamarin.Android.Support.Annotations (= 28.0.0.3) 
 KApp.Android -> KApp-> Com.OneSignal 3.10.2 -> Xamarin.Android.Support.v7.CardView 26.0.2 -> Xamarin.Android.Support.Annotations (= 26.0.2).   KApp.Android

So what i have to do now is waiting for the new version or using AndroidX Migration? Is it correct ?

PawKanarek commented 3 years ago

@jkasten2

We will soon have a major release 4.0.0 version beta to try out for Xamarin where it will be updated to use AndroidX as well going forward so this won't always be required.

Soon means? Can you provide an estimated delivery time for the new version? A month, a year or something?

Jacko1394 commented 3 years ago

I wait in anticipation for this 4.0.0 beta... Seems pretty important as Google Play now requires apps be built with at least Android SDK API 29 now.

alexkozler commented 3 years ago

Still no word on this or commits towards it?

excellapay commented 3 years ago

Has anyone gotten OneSignal and AndroidX to work?

dazcro commented 3 years ago

Any update on this issue?

ndastur commented 3 years ago

A timeline would be good please.

rgomezp commented 3 years ago

Howdy, Thanks everyone for your patience.

We are working hard to get out the next major release version. In the meantime, please see this comment for a workaround.

We don't have a set timeline, though in order to manage expectations this won't be released on the order of weeks but rather months more likely.

Please try the above proposed solution. If it works for you or have anything to add that could help others, any comments would be greatly appreciated. If it doesn't work for you, also let us know with information related to your app environment.

Cheers

alexkozler commented 3 years ago

@rgomezp I don't think the proposed solution has worked for anyone.

Even with the Migration library, it is just a countless cycle of these errors, especially on phone reboots:

java.lang.InstantiationException: java.lang.Class<com.google.firebase.iid.FirebaseInstanceIdService> cannot be instantiated

and

java.lang.InstantiationException: java.lang.Class<com.onesignal.RestoreKickoffJobService> cannot be instantiated

and

java.lang.InstantiationException: java.lang.Class<com.onesignal.RestoreJobService> cannot be instantiated

These are hard app crashes for anyone on an Android 10, 11, or 12 device... with or without the Android X migration library. It does not happen in debug mode, only in Release mode or when actually deployed to a physical device.

joanorts95 commented 3 years ago

It worked for me!

JigarM commented 3 years ago

@alexthekid07 Its not working for me too. I have tried but still facing the issue. https://github.com/OneSignal/OneSignal-Xamarin-SDK/issues/230

JigarM commented 3 years ago

This solution works for me. Please check this comment. https://github.com/OneSignal/OneSignal-Xamarin-SDK/issues/228#issuecomment-813979825

jkasten2 commented 3 years ago

We just released Com.OneSignal 3.10.5 with dependency changes to resolve the AndroidX compatibility. Simply upgrade to this version and rebuild your project.

christianrr commented 3 years ago

Don't forget to include a proguard configuration when using R8. I was facing the exact same issue because OneSignal was not declared to be excepted in the proguard.cfg. Here is my working config:

-dontwarn com.google.android.gms. -keep class com.google.firebase.provider.FirebaseInitProvider -keep class com.google.firebase.iid.FirebaseInstanceIdReceiver -keep class com.google.firebase.messaging.FirebaseMessagingService -keep class com.onesignal. { *; } -keep class com.google.firebase.* { ; }

taublast commented 2 years ago

We just released Com.OneSignal 3.10.5 with dependency changes to resolve the AndroidX compatibility. Simply upgrade to this version and rebuild your project.

I still got this error with Com.OneSignal Version="3.10.6"

until i added the migration nuget that solved the issue.

jkasten2 commented 2 years ago

@taublast Not sure why it didn't pull that in as a dependency for you but good to hear that fixed it for you.

Also wanted to note in OneSignal-Xamarin-SDK 4.0.0 this is no longer required for OneSignal at least, since it now uses AndroidX instead of Android Support.