adaptyteam / AdaptySDK-Unity

Unity SDK for growing mobile in-app purchases
https://docs.adapty.io/docs/quickstart
MIT License
50 stars 4 forks source link

Collides with Appsflyer Plugin #8

Closed efeurun closed 1 year ago

efeurun commented 1 year ago

image

The screenshot above displays a collision issue between the Appsflyer plugin and AdaptySDK-Unity, preventing further progress.

Do you have any suggestions or solutions to resolve this problem?

vladd-g commented 1 year ago

Please try the following solution:

  1. Add this file to the res/xml directory of android resources
  2. And add the lines 9 and 15 to the manifest from here
efeurun commented 1 year ago

Thank you for the prompt response. However, I am now encountering a different error even after attempting several solutions. Specifically, when running the processReleaseManifest task, I received the following warning message:

> Task :unityLibrary:processReleaseManifest F:\Work\Unity Projects\dopiverse\Temp\gradleOut\unityLibrary\src\main\AndroidManifest.xml:3:3-38:17 Warning: application@android:fullBackupContent was tagged at AndroidManifest.xml:3 to replace other declarations but no other declaration present.

efeurun commented 1 year ago

Hello again, just a little update. I've started a new, empty project and imported only AdaptySDK and Dependency Manager, turns out I'm still not able to get past gradle as it throws an error. Here's the error;

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':launcher:checkReleaseDuplicateClasses'.
> 1 exception was raised by workers:
  java.lang.RuntimeException: Duplicate class com.adapty.internal.crossplatform.AdaptyEligibilityAdapter found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.AdaptyErrorSerializer found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.AdaptyErrorSerializer$Companion found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.AdaptyErrorSerializer$WhenMappings found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.AdaptyImmutableListSerializer found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.AdaptyImmutableMapTypeAdapterFactory found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.AdaptyImmutableMapTypeAdapterFactory$Companion found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.AdaptyPaywallProductTypeAdapterFactory found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.AdaptyPaywallProductTypeAdapterFactory$Companion found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.AdaptyPaywallTypeAdapterFactory found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.AdaptyPaywallTypeAdapterFactory$Companion found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.AdaptyPeriodUnitSerializer found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.AdaptyProrationModeDeserializer found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.AdaptyResultTypeAdapterFactory found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.AdaptyResultTypeAdapterFactory$create$result$1 found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.BaseTypeAdapterFactory found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.BaseTypeAdapterFactory$create$result$1 found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.BuildConfig found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.CrossplatformHelper found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.CrossplatformHelper$Companion found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.EnumConverter found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.SerializationExclusionStrategy found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.SerializationFieldNamingStrategy found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.SerializationHelper found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.SerializationHelper$gson$2 found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.internal.crossplatform.UtilsKt found in modules com.adapty.internal.crossplatform-2.3-runtime.jar (:com.adapty.internal.crossplatform-2.3:) and com.adapty.internal.crossplatform-2.3-runtime.jar (:crossplatform-2.3:)
  Duplicate class com.adapty.unity.AdaptyAndroidCallback found in modules com.adapty.internal.unity-wrapper-2.3-runtime.jar (:com.adapty.internal.unity-wrapper-2.3:) and unity-wrapper-2.3-runtime.jar (:unity-wrapper-2.3:)
  Duplicate class com.adapty.unity.AdaptyAndroidMessageHandler found in modules com.adapty.internal.unity-wrapper-2.3-runtime.jar (:com.adapty.internal.unity-wrapper-2.3:) and unity-wrapper-2.3-runtime.jar (:unity-wrapper-2.3:)
  Duplicate class com.adapty.unity.AdaptyAndroidWrapper found in modules com.adapty.internal.unity-wrapper-2.3-runtime.jar (:com.adapty.internal.unity-wrapper-2.3:) and unity-wrapper-2.3-runtime.jar (:unity-wrapper-2.3:)
  Duplicate class com.adapty.unity.AdaptyAndroidWrapper$1 found in modules com.adapty.internal.unity-wrapper-2.3-runtime.jar (:com.adapty.internal.unity-wrapper-2.3:) and unity-wrapper-2.3-runtime.jar (:unity-wrapper-2.3:)
  Duplicate class com.adapty.unity.AdaptyAndroidWrapper$10 found in modules com.adapty.internal.unity-wrapper-2.3-runtime.jar (:com.adapty.internal.unity-wrapper-2.3:) and unity-wrapper-2.3-runtime.jar (:unity-wrapper-2.3:)
  Duplicate class com.adapty.unity.AdaptyAndroidWrapper$11 found in modules com.adapty.internal.unity-wrapper-2.3-runtime.jar (:com.adapty.internal.unity-wrapper-2.3:) and unity-wrapper-2.3-runtime.jar (:unity-wrapper-2.3:)
  Duplicate class com.adapty.unity.AdaptyAndroidWrapper$12 found in modules com.adapty.internal.unity-wrapper-2.3-runtime.jar (:com.adapty.internal.unity-wrapper-2.3:) and unity-wrapper-2.3-runtime.jar (:unity-wrapper-2.3:)
  Duplicate class com.adapty.unity.AdaptyAndroidWrapper$2 found in modules com.adapty.internal.unity-wrapper-2.3-runtime.jar (:com.adapty.internal.unity-wrapper-2.3:) and unity-wrapper-2.3-runtime.jar (:unity-wrapper-2.3:)
  Duplicate class com.adapty.unity.AdaptyAndroidWrapper$3 found in modules com.adapty.internal.unity-wrapper-2.3-runtime.jar (:com.adapty.internal.unity-wrapper-2.3:) and unity-wrapper-2.3-runtime.jar (:unity-wrapper-2.3:)
  Duplicate class com.adapty.unity.AdaptyAndroidWrapper$4 found in modules com.adapty.internal.unity-wrapper-2.3-runtime.jar (:com.adapty.internal.unity-wrapper-2.3:) and unity-wrapper-2.3-runtime.jar (:unity-wrapper-2.3:)
  Duplicate class com.adapty.unity.AdaptyAndroidWrapper$5 found in modules com.adapty.internal.unity-wrapper-2.3-runtime.jar (:com.adapty.internal.unity-wrapper-2.3:) and unity-wrapper-2.3-runtime.jar (:unity-wrapper-2.3:)
  Duplicate class com.adapty.unity.AdaptyAndroidWrapper$6 found in modules com.adapty.internal.unity-wrapper-2.3-runtime.jar (:com.adapty.internal.unity-wrapper-2.3:) and unity-wrapper-2.3-runtime.jar (:unity-wrapper-2.3:)
  Duplicate class com.adapty.unity.AdaptyAndroidWrapper$7 found in modules com.adapty.internal.unity-wrapper-2.3-runtime.jar (:com.adapty.internal.unity-wrapper-2.3:) and unity-wrapper-2.3-runtime.jar (:unity-wrapper-2.3:)
  Duplicate class com.adapty.unity.AdaptyAndroidWrapper$8 found in modules com.adapty.internal.unity-wrapper-2.3-runtime.jar (:com.adapty.internal.unity-wrapper-2.3:) and unity-wrapper-2.3-runtime.jar (:unity-wrapper-2.3:)
  Duplicate class com.adapty.unity.AdaptyAndroidWrapper$9 found in modules com.adapty.internal.unity-wrapper-2.3-runtime.jar (:com.adapty.internal.unity-wrapper-2.3:) and unity-wrapper-2.3-runtime.jar (:unity-wrapper-2.3:)
  Duplicate class com.adapty.unity.AdaptyInitProvider found in modules com.adapty.internal.unity-wrapper-2.3-runtime.jar (:com.adapty.internal.unity-wrapper-2.3:) and unity-wrapper-2.3-runtime.jar (:unity-wrapper-2.3:)
  Duplicate class com.adapty.unity.BuildConfig found in modules com.adapty.internal.unity-wrapper-2.3-runtime.jar (:com.adapty.internal.unity-wrapper-2.3:) and unity-wrapper-2.3-runtime.jar (:unity-wrapper-2.3:)
  Duplicate class com.adapty.unity.Constants found in modules com.adapty.internal.unity-wrapper-2.3-runtime.jar (:com.adapty.internal.unity-wrapper-2.3:) and unity-wrapper-2.3-runtime.jar (:unity-wrapper-2.3:)

  Go to the documentation to learn how to Fix dependency resolution errors.

* 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 20s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Update

Upon further investigation, I have found that the most recent version that works without any issues for me is "1.0.2". I am encountering errors with every release beyond version 2.0.

Additionally, I'm confused as to why the Adapty Unity Plugin utilizes C#9.0 features, given that it's not yet supported by the vast majority of Unity releases.

vladd-g commented 1 year ago

Hello @efelatte As for the duplicates, could you please try this version? 2.3.0-fixed.zip

vladd-g commented 1 year ago

If the attachment above solves that, please try it with your main project to check whether any manifest merging issues still exist

Actually it's a typical problem in such cases, basically it's not an issue of the concrete library, on Android sometimes things just need to be merged manually

Did you try solving it with a custom manifest, as the comment from the link above says?

efeurun commented 1 year ago

Hello @vladd-g , Thank you very much for your helps so far.

I am now able to successfully create the build in my main project. However, I still need to modify all "is not null" checks in my code to "!= null" or else Unity won't be able to compile.

Upon examining the Android Logcat after the build, I noticed that there are no logs about Adapty SDK. I am uncertain whether this issue is connected to the alterations I am making to null types, but I cannot avoid them as they are necessary for compilation in Unity. For reference, my Unity version is 2020.3.24.

vladd-g commented 1 year ago

@efelatte As for the logs, have you switched them on as described here?

vladd-g commented 1 year ago

Did you try to call any of the Adapty methods on Android? Does it work properly in your main project, besides the logs?

efeurun commented 1 year ago

Hello, @vladd-g!

After turning on the debugs, I observed the following error message:

2023.03.05 20:40:27.133 28330 28770 Error Adapty_v2.3.2 ERROR: The request was unsuccessful. https://api.adapty.io/api/v1/sdk/in-apps/google/token/restore/ Code: 400, Response: {"errors":[{"detail":"Google service account key is not set in Adapty dashboard.","status":"400","source":{"pointer":"/data"},"code":"GOOGLE_SERVICE_ACCOUNT_KEY_IS_NOT_SET_ERROR"}]}

It appears that you have resolved the problem, and the remaining task is to configure it on our end.

Thank you very much. Please feel free to close the issue.

Update

After setting service key in our account settings at Adapty, I can confirm everything seems to works fine now. You may want to release that fixed version. 😃

x401om commented 1 year ago

I am now able to successfully create the build in my main project. However, I still need to modify all "is not null" checks in my code to "!= null" or else Unity won't be able to compile.

Hi, @efelatte ! We have been testing our SDK 2.0 on Unity 2021.3 and newer. Now we have started to fixing those modern c-sharp api usages, so that the minimum version will be 2019.

efeurun commented 1 year ago

Thanks, @x401om! You all were awesome, and I really appreciate the quick help. Looking forward to upgrading to the new version when it's available.

x401om commented 1 year ago

Hey, @efelatte! We have released a new version. I have tested it with Unity 2019.4.38f and there are no build errors anymore. I will close this issue for now, feel free to open a new one in case of any questions :)