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

Cannot set D8 with Com.Onesignal package #185

Closed PawKanarek closed 4 years ago

PawKanarek commented 4 years ago

Description

New project configured to run with D8 and multi-dex with package Com.Onesignal won't compile because: 2>R8 : warning : Missing class: com.google.android.gms.location.LocationListener 2>R8 : error : Compilation can't be completed because some library classes are missing.

Steps to Reproduce Issue:

  1. Create new Xamarin.Forms project with "Xamarin.Forms" Version="4.5.0.356" & "Xamarin.Essentials" Version="1.5.1"
  2. Install newest nuget in XF project Com.Onesignal (3.7.3)
  3. Set Android DexCompiler as d8
  4. Set Enable Multi-Dex
  5. Set Code Shrinker option as empty
  6. Use workaround to r8d8 from https://github.com/xamarin/xamarin-android/issues/2670 6.1. add amazon-device-messaging-1.1.0.jar and in-app-purchasing-2.0.76.jar set build Action as AndroidExternalJavaLibrary 6.2. Add to mainifest inside tag
  7. Try to compile

Output:

**NU1603: Com.OneSignal 3.7.3 depends on Xamarin.Android.Support.CustomTabs (>= 26.0.2) but Xamarin.Android.Support.CustomTabs 26.0.2 was not found. An approximate best match of Xamarin.Android.Support.CustomTabs 26.1.0.1 was resolved.
NU1603: Com.OneSignal 3.7.3 depends on Xamarin.Android.Support.v4 (>= 26.0.2) but Xamarin.Android.Support.v4 26.0.2 was not found. An approximate best match of Xamarin.Android.Support.v4 26.1.0.1 was resolved.
NU1603: Com.OneSignal 3.7.3 depends on Xamarin.Android.Support.v7.CardView (>= 26.0.2) but Xamarin.Android.Support.v7.CardView 26.0.2 was not found. An approximate best match of Xamarin.Android.Support.v7.CardView 26.1.0.1 was resolved.
1>------ Build started: Project: Dextest.Android, Configuration: Debug Any CPU ------
1>  Dextest.Android -> C:\Users\Raix\source\repos\Dextest\Dextest\Dextest.Android\bin\Debug\Dextest.Android.dll
1>  No way to resolve conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e". Choosing "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily.
1>R8 : warning : Missing class: com.google.android.gms.location.LocationListener
1>R8 : error : Compilation can't be completed because some library classes are missing.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
**

Additional info

When mulidex is disabled, everything runs well (but my original project is huge, and wont compile without multi dex)

Environment Runing on Android 9.0, Huawei Mate 10 Pro Microsoft Visual Studio Professional 2019 Version 16.4.6 VisualStudio.16.Release/16.4.6+29905.134 Microsoft .NET Framework Version 4.8.03752

Installed Version: Professional ASP.NET and Web Tools 2019 16.4.462.24200 Azure App Service Tools v3.0.0 16.4.462.24200 C# Tools 3.4.1-beta4-20120-08+fa984e0202af4480c0273032da49cbbdeb32c582 Extensibility Message Bus 1.2.0 (d16-2@8b56e20) IntelliCode Extension 1.0 Microsoft Continuous Delivery Tools for Visual Studio 0.4 Microsoft JVM Debugger 1.0 Microsoft Library Manager 2.0.87+gbb515bf382 Microsoft MI-Based Debugger 1.0 Microsoft Visual Studio Tools for Containers 1.1 Mono Debugging for Visual Studio 16.5.24 (1fafd7e) NuGet Package Manager 5.4.0 Xamarin 16.4.000.313 (d16-4@793df40) Xamarin Designer 16.4.0.475 (remotes/origin/d16-4@ac250f5aa) Xamarin Templates 16.4.25 (579ee62) Xamarin.Android SDK 10.1.4.0 (d16-4/e44d1ae) Xamarin.Android Reference Assemblies and MSBuild support. Mono: fd9f379 Java.Interop: xamarin/java.interop/d16-4@c4e569f ProGuard: xamarin/proguard/master@905836d SQLite: xamarin/sqlite/3.28.0@46204c4 Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-5@9f4ed4b Xamarin.iOS and Xamarin.Mac SDK 13.10.0.21 (02c4b3b)

Sample repo

https://github.com/PawKanarek/Bug-Reproduction-Repo-OneSignal-185-

image

Workaround Can you help me find any workaround for this issue?

PawKanarek commented 4 years ago

It turn out that i need to install Xamarin.GooglePlayServices.Location nuget package... Can you add this package as nuget Dependency to your Com.Onesignal nuget package? Also, that's ultra wired that i need to install some .jars into project to run Com.OneSignal...

jkasten2 commented 4 years ago

@PawKanarek You could add -dontwarn com.google.android.gms.location.** to your r8 / d8 config. It isn't in the consumer-proguard-rules.pro file as it is included as an automatic dependency for the native SDK, but not for this Xamarin SDK.

PawKanarek commented 4 years ago

So maybe you could add nuget Xamarin.GooglePlayServices https://www.nuget.org/packages/Xamarin.GooglePlayServices.Location/ as dependency to com.onesignal nuget? image

rgomezp commented 4 years ago

Howdy, Apologies for the delayed response. Are you still encountering the issue or can I go ahead and close?