Does anyone know how to build to SDK30 and Gradle 7.x since now the Play Store requires SDK30 and it will only compile with Gradle 7.x and above? I can compile just fine to SDK29 with Gradle 4.x that Unity ships with, but when deploying to the Play Store it says I must be SDK30, So far I have spent about 4 days straight trying every which way to Sunday to get this to work, the only success I have had thus far, which is only minor success, is to export the project and upgrade it to SDK30 in Android Studio with Gradle 7, however, a signed APK from a Unity build is the only thing I can do in Android Studio which is clearly missing my components, and doing a package wonât upload do to it using deprecated packages that are not allowed it seems.
So if you have steps you perform to make the latest build of Unity being 2020.3.18f1 as of this post, it would be highly appreciated.
Iâve already replied here Gradle build fails with build tools 31.0.0 but Iâll repeat that you donât have to use SDK build-tools 30. Google Play requires that apps target API level 30, which requires platforms API 30 to be installed. If your Unity editor installation uses SDK installed with the editor, there is a sdkmanager tool in editorâs installation directory PlaybackEngines\AndroidPlayer\SDK\tools\bin. You can run that tool like this sdkmanager "platforms;android-30" to install API level 30 (make sure you have administrator privileges, so that sdkmanager can install things). Alternatively you can use Android Studio and install only Platforms component with API level 30.
Edit: just in case, I have to mention that after installing API level 30 you must also specify it has to be used. In Player Settings you have to set âTarget API Levelâ to âAutomatic (highest installed)â or âAndroid 11.0 (API level 30)â to actually target API 30 and satisfy Play store requirement.
I appreciate your help JuliusM, the problem literally is that Gradle 6.1.1 even (which is what is in the list for Unity version I am using, doesnât work for API level 30, or hasnât so far for me. I will test this above thing your are mentioning to see if that fixed me, I pray it does, but so far, no real luck in this, it would be nice if Unity had the API level 30 already available and tested within the Unity builds. I know that has to be a pain though.
Running as the command prompt-Administrator, tried in several iterations of the engine
D:\Unity Editors\2020.3.18f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\bin>sdkmanager "platforms;android-30"
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
D:\Unity Editors\2020.3.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\bin>sdkmanager "platforms:android-30"
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
... 5 more
Also on the whole âbuild tools 31 corrupt thingâ there is a fix:
Maybe Iâm mixing a few things up. Iâve re-read through your posts i this thread Android build from unity not 64 bit compliant and now Iâm not sure what error is still left for you. Could you specify what exact error you still get in Unity editor now?
Oh, the error that you get seems to be caused by the fact that sdkmanager only supports JDK 8, but there is a newer JDK version installed on your machine.
This also raises a question, do you use a custom JDK in Unity, or the one that comes with Unity? Android tools currently used by Unity donât work with newer JDK versions than 8, so maybe that is also somehow related to your other issues.
There was this post about JDK versions Java 9 (JDK 9) support by Unity Android it was pinned for a long time, but now I see it is not pinned anymore, even though it is still relevant for now.
I am using the built in Unity SDK/JDK, not the external, it is the default on the âeditâ the âpreferencesâ then âexternal toolsâ, all of the Android are checked off to use the internal unity items. Last error I got was that gradle was not compatible with the current build tools, i finally got Unity to upgrade to Android 11 (API Level 30), after I opened the folder where the binary was and set it to run this program as administrator (compatibility tab on file properties)
âD:\Unity Editors\2020.3.18f1\Editor\Unity.exeâ
This then did the install without arguing with me, I have also set the project to IL2CPP ARM64 bit build (play store only wants 64 bit now, the rest could probably just be removed as options honestly)
I created a brand new mobile 3d game, and brought in only the 3 main game entry videoâs, created a plain old gui canvas with 1 line of text and 1 button that triggers the videos to launch, still working on this. If I can get that to work cleanly, then I need to figure out the hosted build solution with Unity and see if that would be best.
I had also attempted to export the project and build in Android Studio to no avail.
So, this has been tried many ways, I guess I will eventually find one that works.
Here is the list of what goes wrong when building now since Android 11 installed via Unity installer:
CommandInvokationFailure: Gradle build failed.
D:\Unity Editors\2020.3.18f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "D:\Unity Editors\2020.3.18f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-6.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "bundleRelease"
stderr[
Note: D:\Projects\Game\Android\Temp\gradleOut\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':launcher:assetPackReleasePreBundleTask'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Required array size too large
These errors seem similar to this issue https://issuetracker.unity3d.com/issues/android-build-fails-when-there-are-680-or-more-files-in-the-streaming-assets-folder
Do you have many files in the streaming assets directory? Do those files have extensions?
In Unity 2020.3.18f1 if certain criteria are met, we should specify only extensions instead of full paths. If you have custom gradle templates you might have to update them based on the default gradle templates present in Unity 2020.3.18f1.
No custom gradle templates, no streaming assets at all, zero actually. So my array is zero for streaming assets.
So maybe lacking that folder is the problem? I have never used it.
All my videos are in a folder I called Videos under my Scenes folder in my assets folder. I use the video player to play them.
No, lacking streaming assets should definitely not be a problem you can try increasing java heap size (though this is a blind guess). The heap size is specified in Editorâs preferences â External Tools tab. The setting is called âMaximum JVM heap sizeâ. But Iâm really not sure if that will help you.
How big is your project? Do videos take a lot of space?
I increased the heap size, didnât help any, my project size is the problem it seems, at lease google play takes up to 1 GB of a game in size, I literally unchecked level after level until the game would successfully compile. The maximum heap size for 64 bit JVM is 8192. But that doesnât get rid of the message for the array. I saw in the asset store someone wrote a plugin to get all the details on assets as to how much space they take up, looks like i need to purchase that, my overall game is 2GB in size, I was trying to figure out how to use a patching system with Unity now, the game is in internal tested on the play store now, first 2 entire regions are in the 1 GB package, but the last 5 regions simply wonât fit in the 1GB, hopefully I can do something about that or somehow stream the last 1 GB of assets as a patch, just not sure how yet, Unity build doesnât have a built in build that says to use thing as patch files. The videos take up about less than 200MB, but I might have to downstream them a little, i dropped them to 720dpi, canât go any lower.
Exactly this happens if you have the Android !12! SDK installed (via Android Studio for example) and its selected in Unity.
Make sure that you dont select âUse highest api versionâ but select 30 as highest in Unity. At least that was the issue in my case
java.lang.RuntimeException: Duplicate class com.google.android.play.core.appupdate.AppUpdateInfo found in modules com.google.android.play.core-1.8.3-runtime.jar (:com.google.android.play.core-1.8.3:) and core-1.10.0-runtime.jar (com.google.android.play:core:1.10.0)
So I would like to remove the 1.10.0, but I am thinking that is bundled in a Unity Engine library set as a collection, because I searched my entire project and no where in my project is the jar of core-1.10.0-runtime.jar, it doesnât exist, this entire part started after I installed the kit by Easy Mobile, I have tried to email them for over a week, they responded 1 time asking for proof I purchased (actually I purchased 2 licenses from them) and I did supply them with proof I purchased it, but zero support, so other than asking for a refund and removing easy mobile pro for current lack of support, I figured if I could just get rid of one or the other it might work, but the plugin puts it back in every time I delete 1.8.3, I guess it needs it for the most recent tools. Anything else I can do other than just never use easy mobile pro?
Unity specifies âimplementation âcom.google.android.play:core:1.10.0ââ dependency in unityLibrary/build.gradle file, however it first checks if play:core dependency is not yet specified. You could enable a âCustom Main Gradle Templateâ in Player settings and then add âimplementation âcom.google.android.play:core:1.8.3ââ dependency in there. This should add the same version dependency as in the plugin.
@JuliusM
May I know what unity versions are affected with this dependency inclusion?
Any reason for hardcoding this dependency? From quite sometime, play:core got some significant changes and they split review feature from core library and made itâs own artifact (ex: com.google.android.play:review:2.0.1).
When we include play:review dependency, now it says some of the classes already exist in the dependency unity adds (com.google.android.play:core:1.10.0) which is a very old version. Earlier review feature was shipped with play:core v1 and now it has itâs own aar file leading to play:core-common file.
We tried fixing by adding com.google.android.play:core-common dependency along with play:review but it didnât work either.
Anyways to avoid this issue or stop unity from adding com.google.android.play:core:1.10.0 completely?
For the time being, here is a post processor to remove the entry added by Unity (for PAD auto built-in support) if your project uses latest play core libraries.
Place the attached file in Editor folder.
But still would request @JuliusM to consider upgrading to 2.x or remove if any of the 2.x libraries are being used to avoid duplicate errors.
sorry it doesnât seem to do anything.
i tried to debug log whether it patched a line or use the original one.
if(!(hasPriorityEntries && (each.Contains(playCoreOldDependencyEntry) || each.Contains(patchedEntry)))) //Considering old play core dependency will be added by unity at last
{
Debug.Log($"original: {each}");
builder.AppendLine(each);
}
else
{
Debug.Log($" patched: {patchedEntry}");
builder.AppendLine(patchedEntry);
}
I recently got an update from an user that it worked perfectly fine.
May I know what is the unity version you are on? Also, share the exact error you face and also if possible the final build.gradle you find in subfolders of Library/Bee/AndroidPrjâŚ
thanks for respond. iâm using Unity 2021.3.15f1.
we have been getting complain from Google Play that our build contains soon deprecated com.google.android.play:core:1.10.0
I have no idea where this âcoreâ dependency coming from. I searched through the plugins and android resolves and there is none. but then this thread tell us Unity adds it!
so, iâm hoping your script would remove it, but seem failing.
(even if this remove the core, iâm not sure which of the libraries should i include and use. iâm all confused about those functionalities)