UPDATED: Unity google.play.core EDM4U custom gradle UnityPlayer cannot find symbols build error

1.4k Views Asked by At

UPDATE:

I was able to get the dependency issue to resolve using Maven to build a local .m2/repoisitry and simply include the com/google/... folder directly. This has resolved the Plugin conflict but also removes the com.google.play.core dependency in the mainTemplate.gradle. which was originally here;

dependencies { // Android Resolver Dependencies Start implementation 'com.google.android.play:asset-delivery:2.0.0' // Assets/GooglePlayPlugins/com.google.play.assetdelivery/Editor/Dependencies.xml:3 implementation 'com.google.android.play:core-common:2.0.0' // Assets/GooglePlayPlugins/com.google.play.core/Editor/Dependencies.xml:3 // Android Resolver Dependencies End DEPS}

This feature should be included by Unity as a dependency of In App Purchasing, but when looking at the Bee/Android/.../build.gradle there is no include for this library, along with UnityPlayer not being resolved, leading to a Gradle Build Failure. I'm really not sure what is causing this issue;

{Build-Path} - Assets\Library\Bee\Android\Prj\IL2CPP\Gradle\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java:15: error: cannot find symbol public class UnityPlayerActivity extends Activity implements IUnityPlayerLifecycleEvents ^ symbol: class IUnityPlayerLifecycleEvents {Build-Path} - Assets\Library\Bee\Android\Prj\IL2CPP\Gradle\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java:17: error: cannot find symbol protected UnityPlayer mUnityPlayer; // don't change the name of this variable; referenced from native code ^ symbol: class UnityPlayer location: class UnityPlayerActivity {Build-Path} - Assets\Library\Bee\Android\Prj\IL2CPP\Gradle\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java:40: error: cannot find symbol mUnityPlayer = new UnityPlayer(this, this);

This seems to point to an issue with the Unity implementation, similar to this; https://github.com/yasirkula/UnityIonicIntegration/issues/41

Except this was an Android Studio build. I have not been able to find anything similar when building in Unity itself, although I will keep looking.

If I remove the custom .gradle options in Project Settings as asked for by EDM4U it will build and crash with AssetPackManager.GetPackStatus() No Implementation. If I include the EDM4U custom gradle I get the above error.

I have updated my Unity editor in the hope this would resolve the Gradle conflict. Made sure that EDM4U is pointing to the correct repository/com folder and run Force Resolve, but am having no luck. The next steps could include downgrading the Gradle version, as this has worked on previous issues with similar Google Plugins, but the issue seems more like a Unity Gradle issue instead of a Plugin conflict.

I've deleted the Library file and re-built the main project but continue to get the UntiyPlayer issues and can't seem to find any solution online.

Any help in finding an in-road to this issue would be a massive help.

ORIGINAL:

I am having difficulty dealing with the google.play.core library conflict between;

Assets/GooglePlayPlugins/com.google.play.assetdelivery 2.0.0 Assets/GooglePlayPlugins/com.google.play.core 1.10.3

This is a documented issue in play-unity-plugins for google; https://github.com/google/play-unity-plugins/blob/master/README.md#play-core-conflicts

The downloaded empty monolithic Play Core library .zip contains the following file structure;

Assets/GooglePlayPlugins/com/google/android/play/core/2.0.0

With a (maven-metadata.xml) file at the /core/ and (core-2.0.0.aar and core-2.0.0.pom) files at the /2.0.0 levels.

Following the steps in the fix I am unable to get an Editor > Google > Build Android App Bundle to work. Here is the following build Error;

Assets\Library\Bee\Android\Prj\IL2CPP\Gradle\launcher\src\main\AndroidManifest.xml:24:17-38 Error: Attribute meta-data#com.google.android.play.core.assetpacks.versionCode@value value=(20000) from [com.google.android.play:asset-delivery:2.0.0] AndroidManifest.xml:24:17-38 is also present at [com.google.android.play:core:1.10.3] AndroidManifest.xml:38:17-38 value=(11003). Suggestion: add 'tools:replace="android:value"' to element at AndroidManifest.xml to override.

The issue is in using EDM4U - External Dependency Manager for Unity Local Maven Repo Directory. I have included the empty monolithic Play Core library and point the Android Resolver Settings towards it, but am not getting any includes in the custom mainTemplate.gradle file.

I have tried manually updating the mainTemplate.gradle following this approach; Encountering two errors when building unity for android, firebase SDK

 project.repositories {
    def unityProjectPath = $/file:///**DIR_UNITYPROJECT**/$.replace("\\", "/")
    maven {
        url "https://maven.google.com"
    }
    maven {
        url "Assets/GooglePlayPlugins/com/google/android/play/core/2.0.0"
    }
    mavenLocal()
    mavenCentral()
}

And also implementing the plugin directly;

    dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'com.google.android.play:asset-delivery:2.0.0' // 
Assets/GooglePlayPlugins/com/google/android/play/core/maven-metadata.xml.xml:3

implementation 'com.google.android.play:asset-delivery:2.0.0' // 
Assets/GooglePlayPlugins/com.google.play.assetdelivery/Editor/Dependencies.xml:3
implementation 'com.google.android.play:core:1.10.3' // 
Assets/GooglePlayPlugins/com.google.play.core/Editor/PlayCoreDependencies.xml:3
implementation 'com.google.android.play:core-common:2.0.0' // 
Assets/GooglePlayPlugins/com.google.play.core/Editor/Dependencies.xml:3
}

But EDM4U > Force Resolve removes these changes. Other approaches suggest manually adding the repo to maven settings.xml (How to configure maven local and remote repository in gradle build file?), but I am really unsure about doing this and can't locate the file or folder on my machine.

I've spent a couple of days googleing around to try and understand what the zip library files are in the solution, but can't seem to find a clear or meaningful way to implement the maven repo.

Any help in understanding this issue would be really great as I feel like I'm going in circles.

Many thanks.

1

There are 1 best solutions below

1
On

The 2.0.0 Play Core libraries have been deprecated and will not work for Asset Delivery. I was able to produce a work-around by installing a local MAVEN repository containing an empty folder for the 2.0.0 Play Core which you can point the Plugin auto-resolver towards to remove the Errors, but this doesn't solve the problem of getting an app to connect to Play Store for either Purchases or Asset Delivery.

The Play Core Libraries are now all contained in the In-App Purchasing and Adressables packages from the UNITY Package Manager, so there is no need to use the libraries directly.

https://docs.unity3d.com/Packages/[email protected]/manual/StoresSupported.html

https://docs.unity3d.com/2023.3/Documentation/Manual/com.unity.addressables.html

If you are planning to publish to Google Play Store with Purchasing or Asset Delivery, you will need to update your UNITY Editor to 2022 or higher, and install the In-App Purchasing or Addressables packages, as these are the in-built systems to wrap the Play Core Libraries and connect to the Play Store.

If you are using Google Play Core 2.0.0 for another reason you can follow this link which describes implementing the MAVEN repo.

https://github.com/google/play-unity-plugins/blob/master/README.md#play-core-conflicts

But be aware that these Plugins are outdated given the In-App Purchasing and Addressables solutions in Unity. As my own project was too far along to integrate these solutions cleanly, a work-around is to contain your Assets for delivery within the project at build time and put them behind a pay wall. Simply use the In-App Purchasing to deliver a receipt for any purchase made and use this to unlock your content in App - Boolean flag, gameObject.SetActive(true), whatever works best..

This is not an ideal solution if your assets are large but it does get around the Play Asset Delivery issue of the Plugins. Ideally you will be able to migrate your project over to Addressables, but it is understandable if this is not possible as there were some significant changes happening around this time as major systems and new Unity versions were becoming available.