Skip to content Skip to sidebar Skip to footer

How Do I Import "com.unity3d.player.unityplayer" Into My Android Library?

I'm having issues getting the UnityPlayer dependencies into my Android Library plugin for Unity. I just can't figure out the correct way to add dependencies to my plugin. Before I

Solution 1:

I figured out exactly what is contained in these AAR files I've been importing in to Unity. I have been doing the correct thing by including classes.jar from Unity into my plugin/libs. The problem was that by building my plugin in Android Studio with classes.jar in libs, classes.jar was being included in the final AAR output, which on the Unity side of things is redundant because Unity already has this data, thus the duplicate classes error I've been getting.

The fix was to open the AAR is some archive editor (7-zip or winrar) and extract only the clases.jar within that and import only that into Unity.

enter image description here

I'm surprised there's not more official documentation on this process.

Also, this fix means no edits to the Gradle build script is necessary unless you want to automate the copy process from intermediate builds to Unity.

Solution 2:

Change implementation to compileOnly for 'com.unity3d.player'. This allows the unity player classes.jar to be used at compile time, but not at run time which was causing the duplication.

Solution 3:

Opening the unity player class after adding classes.jar file from unity in libs folder solved this issue for me.

Solution 4:

What i did was renamed the Unity Jar [classes.jar] to [clases.jar]

enter image description here

and Added the following in Gradle file enter image description here

If this still gives the error then: Goto File>>Settings

enter image description here

Post a Comment for "How Do I Import "com.unity3d.player.unityplayer" Into My Android Library?"