google / play-unity-plugins

The Google Play Plugins for Unity provide C# APIs for accessing various Play services
Other
439 stars 112 forks source link

Unity Cloud Build #172

Open brockw opened 2 years ago

brockw commented 2 years ago

We are getting this error from Cloud Build but local builds work fine.

ERROR: Actionable build error: The highest installed Android API Level is 29, however version 30 is the minimum required to build for Google Play.

Is it possible the script that detects the Android API level is not working correctly? Has anyone else encountered this issue?

jamcohen commented 2 years ago

Hi @brockw,

Apologies for the late response. I'm not familiar with Unity's Cloud build. Can you change the "Target API Level" to "Android 11.0 (API Level 30)" in Player Settings?

It's possible that your project has it set to "Automatic (highest installed)". That could work locally because your machine has 30 or higher installed, but fail on Cloud Build because its environment only has 29 installed.

csonsteng commented 2 years ago

just commenting to say that we're having the exact same problem. I've had an open ticket with Unity support for a little while, but haven't found a solution yet.

jamcohen commented 2 years ago

@csonsteng, is your project's "Target API Level" set to "Automatic (highest installed)" in Player Settings?

csonsteng commented 2 years ago

@brockw what version of Unity are you using? We're on 2020.3.4f1

csonsteng commented 2 years ago

@jamcohen yes it is :(

jamcohen commented 2 years ago

Try setting it to "Android 11.0 (API Level 30)" and seeing if that works. My hope is that Unity's Cloud Build environment will properly download that version of the Android SDK.

csonsteng commented 2 years ago

@jamcohen will do! i'll let you know the result

csonsteng commented 2 years ago

@jamcohen i got the same error :(

124: [Unity] ERROR: Actionable build error: The highest installed Android API Level is 29, however version 30 is the minimum required to build for Google Play. 125: [Unity] Google.Android.AppBundle.Editor.Internal.BuildTools.BuildToolLogger:DisplayActionableErrorDialog (string) (at Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/BuildTools/BuildToolLogger.cs:45)

Tomorrow, i'm going to try an empty unity build with just the plugin and see if i get the same issue.

jamcohen commented 2 years ago

Hmm, in that case it sounds like either:

  1. Unity always builds with Android 29 regardless of what is specified in Player Settings.
  2. Unity downloads Android SDKs > 29 as needed, but after the plugin checks for the latest version. In which case, the plugin throws an error that the SDK isn't present, even though it will be downloaded as part of Unity's build process.

Hopefully we're dealing with 2, in which case we can add the following clause here:

var targetSdkVer = PlayerSettings.Android.targetSdkVersion;
if ((int) targetSdkVer >= MinimumVersion)
{
   return true;
}

That will skip the Android SDK version check if the Target API Level is set to something 30 or greater in Player Settings.

@csonsteng, is it possible for you to add that line, and try another Cloud Build?

Once the build succeeds, you'll want to make sure it was built with targetSdkVersion=30. Otherwise the build will be rejected by the Play Store. You can check this by opening the APK or AAB in Android Studio and checking the AndroidManifest for a <uses-sdk/> tag. Example:

<uses-sdk
        android:minSdkVersion="22"
        android:targetSdkVersion="30" />
csonsteng commented 2 years ago

@jamcohen we have progress! The build still failed, but now I get the following error.

125: [Unity] ERROR: Actionable build error: This build method doesn't support APK Expansion (OBB) files. 126: [Unity] Google.Android.AppBundle.Editor.Internal.BuildTools.BuildToolLogger:DisplayActionableErrorDialog (string) (at Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/BuildTools/BuildToolLogger.cs:45)

this might be something in my Unity Cloud Build config. I'll dig into it in a little bit and let you know if I find anything.

In case this ends up being a viable solution that you want to incorporate, you can wrap that code in the scripting symbol #IF UNITY_CLOUD_BUILD to make it only run on cloud builds.

jamcohen commented 2 years ago

That's interesting. And you're not getting that error when you build locally, right?

That error triggers if "Split Application Binary" is checked in your projects Player Settings. In older versions of Unity the checkbox is named something else, maybe "Use APK Expansion Files"? Either way, it should be the last checkbox in Player Settings -> Android -> Publishing Settings.

csonsteng commented 2 years ago

ahh that's a really good point. I'm not sure the last time I actually made a local build on this branch.

I did actually have that unchecked in the Player Settings, but Cloud Build's configuration overrides it with its own setting. I changed it on that end. It still failed to build.

I'll share the results in case you have any immediate thoughts, but it does seem like the original issue is resolved. I'll progress with trying and troubleshooting a local build. If I run into any struggles, I can open up a new issue.

Thank you for your help : )

159: [Unity] ERROR: Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details 160: [Unity] WARNING: The option 'android.enableR8' is deprecated and should not be used anymore. 161: [Unity] WARNING: The option 'android.enableR8' is deprecated and should not be used anymore. 162: [Unity] ERROR: 163: [Unity] WARNING: The option 'android.enableR8' is deprecated and should not be used anymore. 164: [Unity] WARNING: The option 'android.enableR8' is deprecated and should not be used anymore. 165: [Unity] at UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) [0x00033] in <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0 166: [Unity] at UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) [0x0002d] in <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0 167: [Unity] at UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) [0x0000a] in <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0 168: [Unity] at UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action1[T] progress, System.String error) [0x0001f] in <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0 169: [Unity] Rethrow as GradleInvokationException: Gradle build failed 170: [Unity] Rethrow as BuildFailedException: Exception of type 'UnityEditor.Build.BuildFailedException' was thrown. 171: [Unity] ERROR: Build error: Build failed with 4 error(s) 172: [Unity] Google.Android.AppBundle.Editor.Internal.BuildTools.BuildToolLogger:DisplayErrorDialog (string) (at Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/BuildTools/BuildToolLogger.cs:95)`

csonsteng commented 2 years ago

@jamcohen turns out the issues were from some custom manifest stuff I had previously tried doing as a different workaround to the cloud build error.

but it works! I was able to get a successful cloud build and confirm its sdk

    <uses-sdk
        android:minSdkVersion="19"
        android:targetSdkVersion="30" />

thank you for your help!

jamcohen commented 2 years ago

That's great to hear! In that case, I'll close this issue once I commit that workaround.

csonsteng commented 2 years ago

One final note on this. This workaround also requires that "Target API Level" in Player Settings is set to "Android 11.0 (API Level 30)"

Changing it back to "Automatic (highest installed)" gives the same error even with the workaround.

jamcohen commented 2 years ago

Thanks for calling that that out. The reason for this behavior is that we don't want cloud builds creating apps that have targetSdkVersion < 30, because those apps would be rejected by the Play Console for not meeting the target API level requirements.

brockw commented 2 years ago

Just got word that cloud build was updated and it does now support targetSDKVersion 30 and 31. Looks like my build passes the previous stage but now fails on

6920: [Unity] UnityEditor.CloudBuild.UnityReflector:GooglePlayBuildBundle (UnityEditor.BuildPlayerOptions,object) 6921: [Unity] UnityEditor.CloudBuild.Builder:BuildPlayerGoogle (UnityEditor.BuildPlayerOptions) 6922: [Unity] UnityEditor.CloudBuild.Builder:BuildPlayer (UnityEditor.BuildPlayerOptions) 6923: [Unity] UnityEditor.CloudBuild.Builder:Build () 6924: [Unity] (Filename: Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/BuildTools/AndroidBuilder.cs Line: 178) 6925: [Unity] DisplayProgressNotification: Build Failed 6926: [Unity] ERROR: Plugins colliding with each other.

Am I not able to have google play plugins installed while also using the built in Unity Google Play bundle checkbox?