googleads / googleads-mobile-unity

Official Unity Plugin for the Google Mobile Ads SDK
https://developers.google.com/admob/unity
Apache License 2.0
1.33k stars 1.09k forks source link

Android build crashes on startup after updating #3334

Open vincent-savysoda opened 3 weeks ago

vincent-savysoda commented 3 weeks ago

[REQUIRED] Step 1: Describe your environment

[REQUIRED] Step 2: Describe the problem

So to preface this, I've basically been unable to update to any of the latest Admob releases as all builds after v8.5.3 had build issues for me, until this latest one. I had no issues building for this version. However, the problem now is that the Android build crashes on startup. I've checked and the appids are unchanged. The only thing i've changed settings-wise is that i've ticked the "Remove property tag" option as was recommended by the upgrade guide. Any ideas as to what may potentially be causing this?

vinkini commented 2 weeks ago

A crash might be occuring if the plugin tries to access a dependency that is not available to it. The Google Mobile Ads Unity plugin utilizes the External Dependency Manager and Gradle to pull relevant dependencies. Can you try resolving dependencies and running the app again? You can access "Force Resolve" under Assets > External Dependency Manager > Android Resolver > Force Resolve. If that doesn't fix your issue can you please provide us device logs to further diagnose the issue.

vincent-savysoda commented 2 weeks ago

A crash might be occuring if the plugin tries to access a dependency that is not available to it. The Google Mobile Ads Unity plugin utilizes the External Dependency Manager and Gradle to pull relevant dependencies. Can you try resolving dependencies and running the app again? You can access "Force Resolve" under Assets > External Dependency Manager > Android Resolver > Force Resolve. If that doesn't fix your issue can you please provide us device logs to further diagnose the issue.

Force resolving did nothing.

However, when i tried reimporting the plugin files I noticed a few things, but unsure if related. The first was that these set of files kept refusing to be imported: image

And everytime i attempt to reimport them I get these errors on console: image

At any rate, I've ran my device while connected to Android Logcat and these are the error logs that I got: com.savysoda.pixelstarships-logcat.txt

Hope that helps!

xGeorgeV commented 2 weeks ago

Unity version: 2023.2.20f1 Google Mobile Ads Unity plugin version: v9.1.0 Platform: Android Mediation ad networks: AppLovin, LiftOff, Pangle.

After upgrading from GMA Unity v8.7.0 to GMA Unity v9.1.0 External Dependency Manager 1.2.179 Force Resolve DO NOTHING!

NVentimiglia commented 2 weeks ago

@vincent-savysoda I am a little confused. Your screen shot shows iOS related issues but you are on Android? Looking at the log I do not see any reference to the iOS dll. Are these two separate issues ?

For the iOS issue, try making sure you delete the plugin before installing it again. The install location is different when using package manager and the .unitypackage. Also make sure you are targeting Android build platform.

Looking at the android issue I see this log:

Throwing new exception 'No interface method getPackStates(Ljava/util/List;)Lcom/google/android/gms/tasks/Task; in class Lcom/google/android/play/core/assetpacks/AssetPackManager; or its super classes (declaration of 'com.google.android.play.core.assetpacks.AssetPackManager' appears in /data/app/oAdZ1ZiyHEUE7_WmoVgluA==/com.savysoda.pixelstarships-EQb9UPvEdePtJL7x7ennWw==/base.apk!classes2.dex)' with unexpected pending exception: java.lang.NoSuchMethodError: No interface method getPackStates(Ljava/util/List;)Lcom/google/android/gms/tasks/Task; in class Lcom/google/android/play/core/assetpacks/AssetPackManager; or its super classes (declaration of 'com.google.android.play.core.assetpacks.AssetPackManager' appears in /data/app/oAdZ1ZiyHEUE7_WmoVgluA==/com.savysoda.pixelstarships-EQb9UPvEdePtJL7x7ennWw==/base.apk!classes2.dex)

We do not use AssetPackManager in our plugin. Can you make sure you have that package installed in the package manager?

NaveedAhmed12 commented 2 weeks ago

i use unity 2020.3.27f1 with admob 8.1.0 and mediation also i want to update both but i am confused because of crashes can any one help me telling me which version is both compatibale and less crashes

xGeorgeV commented 2 weeks ago

Unity version: 2023.2.20f1 Google Mobile Ads Unity plugin version: v8.7.0 Platform: Android Mediation ad networks: AppLovin, LiftOff, Pangle. External Dependency Manager 1.2.177 IT WORKS FINE!

I am struggling with this now: GMA Unity version 9.1.0 and External Dependency Manager 1.2.179 With mainTemplate.gradle version generates many errors when creating the application. In a traditional way (AARs in Assets/Plugin/Android) EDM freezes during operation.

vincent-savysoda commented 2 weeks ago

@vincent-savysoda I am a little confused. Your screen shot shows iOS related issues but you are on Android? Looking at the log I do not see any reference to the iOS dll. Are these two separate issues ?

For the iOS issue, try making sure you delete the plugin before installing it again. The install location is different when using package manager and the .unitypackage. Also make sure you are targeting Android build platform.

Looking at the android issue I see this log:

Throwing new exception 'No interface method getPackStates(Ljava/util/List;)Lcom/google/android/gms/tasks/Task; in class Lcom/google/android/play/core/assetpacks/AssetPackManager; or its super classes (declaration of 'com.google.android.play.core.assetpacks.AssetPackManager' appears in /data/app/oAdZ1ZiyHEUE7_WmoVgluA==/com.savysoda.pixelstarships-EQb9UPvEdePtJL7x7ennWw==/base.apk!classes2.dex)' with unexpected pending exception: java.lang.NoSuchMethodError: No interface method getPackStates(Ljava/util/List;)Lcom/google/android/gms/tasks/Task; in class Lcom/google/android/play/core/assetpacks/AssetPackManager; or its super classes (declaration of 'com.google.android.play.core.assetpacks.AssetPackManager' appears in /data/app/oAdZ1ZiyHEUE7_WmoVgluA==/com.savysoda.pixelstarships-EQb9UPvEdePtJL7x7ennWw==/base.apk!classes2.dex)

We do not use AssetPackManager in our plugin. Can you make sure you have that package installed in the package manager?

Oh I'm just showing you what I got when I tried to import the release into the project. I wasn't sure if it was related. I was definitely on Android platform, as I had to use the EDM resolver.

Regarding AssetPackManager, I don't see/use it either, but I definitely do see an AssetPack library from GooglePlayPlugins though?

vincent-savysoda commented 2 weeks ago

Ok so I think I managed to fix the issue by updating the other Google Play related plugins.

xGeorgeV commented 2 weeks ago

Unity version: 2023.2.20f1 Google Mobile Ads Unity plugin version: v8.7.0 Platform: Android Mediation ad networks: AppLovin, LiftOff, Pangle. External Dependency Manager 1.2.177 IT WORKS FINE!

I am struggling with this now: GMA Unity version 9.1.0 and External Dependency Manager 1.2.179 With mainTemplate.gradle version generates many errors when creating the application. In a traditional way (AARs in Assets/Plugin/Android) EDM freezes during operation.

I updated the Gradle to version 8.7.0 in Unity 2023.2.20f1. The GMA Unity version 9.1.0 and External Dependency Manager 1.2.179 using a traditional way (AARs in Assets/Plugin/Android, it is necessary because I have to delete duplicate libraries because mediations download the libraries also) and IT WORKS FINE!

ReDPluto commented 1 week ago

No consigo hacer que la app funcione, tengo el mismo problema y he probado con varias versiones de GMA y varias versiones de Unity, no entiendo porque no funciona ninguna aplicación cuando se le añade el assets de Google Mobile Admo, en unity todo funciona bien pero luego no funciona en el dispositivo.

xGeorgeV dices que te funciona con la GMA unity 9.10 (es la última) y con la External Dependcy Manager 1.2.179 que es la que viene al instalar el packmanager de GMA, pero dices que has actualizdo Gradle a 8.7.0 ¿me puedes decir como se actualiza eso? esto es desesperante no entiendo como es posible que saquen tantas últimas versiones y no funcione ninguna app al añadir el GMA.

Te agredeceria mucho tu ayuda.

Un saludo

xGeorgeV commented 1 week ago

Download Gradle 8.7.0 from: https://gradle.org/releases/ Install it somewhere. Setup in Unity: (I copied all the components from my Unity to another location.)

Unity_Gradle

Unity > Assets > Google Mobile Ads > Settings: Set App IDs, Check All [x] ON.

Unity > Assets > External Dependency Manager > Android Resolver > Settings:

image

Player Settings:

Unity_PlayerSettings

Check proguard-user.txt: (Contains extra spaces to avoid formatting the text in this comment.)

-keep class com.google.unity . { ; } -keep public class com.google.android.gms.ads . { public ; } -keep public class com.google.ads . { public ; } -keep public class com.google.android.ump . { public ; }

-keepattributes Annotation -ignorewarnings -dontobfuscate

-keep class com.google.android.gms.appset . { ; } -keep class com.google.android.gms.tasks . { ; }

When you're ready: Unity > Assets > External Dependency Manager > Android Resolver > Force Resolve

WARNING! Gradle does not like special characters in user names. Example: space,é,á,ű,ő,ú,ö,ü,ó,í,É,Á,Ű,Ő,Ú,Ö,Ü,Ó,Í Example your user name is: "C:\Users\Jöhn Dőe" you must rename it to "C:\Users\JohnDoe"

GOOD WORK!

NVentimiglia commented 1 week ago

Thanks for the update, we are looking into this on our end.

vincent-savysoda commented 1 week ago

@NVentimiglia regarding the iOS issue you asked me to send a report to the Android SDK team but the link you provided requires a login?

ReDPluto commented 1 week ago

Thank you very much for the help but I have tried to follow the steps in your explanation and I get an error when compiling in Unity, I don't know what I did wrong.

CommandInvokationFailure: Gradle build failed. C:\Program Files\Unity\Hub\Editor\2022.3.28f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Users\David\Downloads\gradle-8.7-all\gradle-8.7\lib\gradle-launcher-8.7.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"

Environment Variables: PROCESSOR_ARCHITECTURE = AMD64 AMPLITUDE_API_KEY_YELLOWBUCKET_DEV = 48835b4d1f5e342aefe5f016324d296a ANDROID_NDK_ROOT = C:\Program Files\Unity\Hub\Editor\2022.3.28f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK DriverData = C:\Windows\System32\Drivers\DriverData USERDOMAIN = SUPERORDENADORP CommonProgramFiles(x86) = C:\Program Files (x86)\Common Files COMPUTERNAME = SUPERORDENADORP DEBUG_ENV_VAR = UnityHub LOGONSERVER = \SUPERORDENADORP AMPLITUDE_TOKEN_GREENBUCKET_PROD = ZpUcbAdZXJYzNSoHsAWtL_s_JppwWid9 PUBLIC = C:\Users\Public ProgramData = C:\ProgramData SESSIONNAME = Console AMPLITUDE_TOKEN_YELLOWBUCKET_PROD = UYDQtPOw83dIfVy3SrW5oMyo7ru4PRkV RlsSvcPort = 22112 ALLUSERSPROFILE = C:\ProgramData SystemRoot = C:\WINDOWS windir = C:\WINDOWS AMPLITUDE_API_KEY_REDBUCKET_DEV = 46b8b46515e7632fc42a504b72e05fd0 ProgramFiles(x86) = C:\Program Files (x86) ProgramW6432 = C:\Program Files OS = Windows_NT PROCESSOR_IDENTIFIER = AMD64 Family 23 Model 113 Stepping 0, AuthenticAMD HOMEPATH = \Users\David TMPDIR = C:\Users\Public\Documents\Wondershare\CreatorTemp AMPLITUDE_TOKEN_REDBUCKET_DEV = U4PSN7S7PuYVRODivvdcFwbu8R6IHGqa CHROME_CRASHPAD_PIPE_NAME = \.\pipe\crashpad_7728_QJNEQHEGJSUTFTYR PROCESSOR_LEVEL = 23 JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF-8 CommonProgramFiles = C:\Program Files\Common Files JAVA_HOME = C:\Program Files\Unity\Hub\Editor\2022.3.28f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK USERDOMAIN_ROAMINGPROFILE = SUPERORDENADORP TEMP = C:\Users\David\AppData\Local\Temp ProgramFiles = C:\Program Files CommonProgramW6432 = C:\Program Files\Common Files AMPLITUDE_TOKEN_YELLOWBUCKET_DEV = wKi8foVigDditGFvmZewRFWsEbX9Y0YO AMPLITUDE_API_KEY_GREENBUCKET_DEV = 3ded2a762163603391a425f688f990c8 FPS_BROWSER_USER_PROFILE_STRING = Default AMPLITUDE_API_KEY_REDBUCKET_PROD = ca12bb461ea96f9bdf5df4ded7d52994 VBOX_HWVIRTEX_IGNORE_SVM_IN_USE = 1 HOMEDRIVE = C: AMPLITUDE_API_KEY_STAGING = 83ee04fccc67e4fcc7dd527c4c6f1e21 USERNAME = David OneDrive = C:\Users\David\OneDrive AMPLITUDE_API_KEY_YELLOWBUCKET_PROD = e03a9bbe92dc38a88cdb068d24c65b46 PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC AMPLITUDE_TOKEN_REDBUCKET_PROD = jTIgKs5KTZOjiqEEVdZFbgo_VRhABduL NUMBER_OF_PROCESSORS = 12 AMPLITUDE_TOKEN_GREENBUCKET_DEV = 84H2gMm_FJzhr3mBaX1lM1JVukmCM7d9 AMPLITUDE_DEPLOYMENT_KEY_RED_BUCKET_DEV = client-wbjHYrmeSR87GmWOE7LDpf7sUySOIKHm AMPLITUDE_API_KEY_GREENBUCKET_PROD = c86fea37a9e1d3f0878b96e15b111c7c ComSpec = C:\WINDOWS\system32\cmd.exe ORIGINAL_XDG_CURRENT_DESKTOP = undefined PROCESSOR_REVISION = 7100 AMPLITUDE_DEPLOYMENT_KEY_RED_BUCKET_PROD = client-zH8Y7OK1i331EKuG77C6UxN8ygcM6LzS TMP = C:\Users\David\AppData\Local\Temp SystemDrive = C: AMPLITUDE_API_KEY = 28f3cae0b33b8b3702120c9ed1a935aa JD2_HOME = C:\Users\David\AppData\Local\JDownloader 2.0 FPS_BROWSER_APP_PROFILE_STRING = Internet Explorer SENTRY_ACCESS_TOKEN = 3df78d9e53f8456aa90fbae044ce1a6261421ab1d0014674bc2e933477289017 APPDATA = C:\Users\David\AppData\Roaming Path = C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Calibre2\;C:\Program Files (x86)\Pinnacle\Shared Files\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\AutoFirma\AutoFirma;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\David\AppData\Local\Microsoft\WindowsApps; PSModulePath = C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules LOCALAPPDATA = C:\Users\David\AppData\Local USERPROFILE = C:\Users\David WOOTRIC_CLIENT_TOKEN = NPS-aa8be4c3

stderr[ Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

FAILURE: Build failed with an exception.

BUILD FAILED in 33s ] stdout[ Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.7/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation. ] exit code: 1 UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at :0) UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at :0) UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at :0) UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action1[T] progress, System.String error) (at <eab0d59bd73a4e308f0300c0ea577056>:0) UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action1[T] progress) (at :0) Rethrow as GradleInvokationException: Gradle build failed UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action`1[T] progress) (at :0) UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :0) UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

xGeorgeV commented 6 days ago

Try with Unity 2023.2.20f1, Gradle 8.7.0, install Unity to "C:\Programs" (Program Files cannot be written), install Android components with Android Studio: Android SDK Platform 34 (Set target API level to 34 in Player Settings), Bulid Tools: 32.0.0 and 34.0.0, CMake 3.22.1, Command-line Tools 6.0, NDK 23.1.7779620, SDK Platform-Tools 35.0.1, SDK Tools 26.1.1.

Use Custom Main Manifest at Player Settings. Check AndroidManifest.XML (Assets\Plugins\Android):

< activity > . . . < intent-filter > < action android:name="android.intent.action.MAIN" / > < category android:name="android.intent.category.LAUNCHER" / > < / intent-filter > . . . < / activity >

Then Unity > Assets > External Dependency Manager > Android Resolver > Force Resolve.

Then try Build Settings > Build Button [v] > Clean Build.

ReDPluto commented 3 days ago

xGeorgeV Thanks for your help.