godot-admob-android
godot-admob-android copied to clipboard
[BUG] App crash on startup
Describe the bug This plugin is amazing and has helped me a ton. However it works great unless I export it and run it on Android 12 (anything below that works perfectly). When you install an app with this on Android 12 it just crashes. I think it has something to do with the manifest xml file. When I disable the plugin the app runs perfectly, albiet not making money
To Reproduce Steps to reproduce the behavior: Make an android game with this Follow the instructions (I think it's the manifest xml file that messes w it) Install on Android 12 Crash on app startup on phone
Expected behavior App crashes on startup
Smartphone (please complete the following information):
- Device: any android running 12
- OS: android 12
Thank you for openning this issue!
Unfortunately I don't have a device to test, I'll check what could be causing this error and provide a build for you to test, okay?
@RintaDev
I didn't find anything that could cause this error, please I ask you to test with this .apk
:
https://www.mediafire.com/file/mtyl8mzq1aiwyhp/AdMobAddon.apk/file It will be available for 14 days.
Build on:
Godot 3.5 standard https://github.com/godotengine/godot/releases/tag/3.5-stable
Editor v1.3.1 https://github.com/Poing-Studios/godot-admob-editor/releases/tag/v1.3.1
Android v2.1.0 https://github.com/Poing-Studios/godot-admob-android/releases/tag/v2.1.0 https://github.com/Poing-Studios/godot-admob-android/releases/download/v2.1.0/android-standard-template-v3.5.zip
I found this:
https://developers.google.com/admob/android/quick-start#import_the_mobile_ads_sdk
But it doesn't work for us because it's only for Android 13 and besides, it wouldn't be necessary as our SDK version is 20.4.0: https://github.com/Poing-Studios/godot-admob-android/blob/ master/admob/build.gradle#L30
And this change is only for earlier than 20.4.0:
If the .apk
I sent you works, you must be doing something wrong when compiling.
If it doesn't work, I recommend you at least try to add this line in your "godot-project\android\build\AndroidManifest.xml"
<-- For apps targeting Android 13 or higher & GMA SDK version 20.3.0 or lower -->
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
If it still doesn't work, I ask you to wait until this Issue is completed: https://github.com/Poing-Studios/godot-admob-android/issues/127
Ok! I'll test it out!
I have tested and the apk crashes upon startup. I have no idea why. Shin nil's plugin seems to work fine.
Have you tried to add this line in your "godot-project\android\build\AndroidManifest.xml"
<-- For apps targeting Android 13 or higher & GMA SDK version 20.3.0 or lower -->
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
If not, please do it to check if still happens
I will only be available to develop to the plugin in 3 days.
yeah i tried that it didnt work. Sorry
@RintaDev I didn't find anything that could cause this error, please I ask you to test with this
.apk
:
I have tested the apk and got a crash log of a android 12.0 device
--------- beginning of crash
2022-08-06 12:25:14.468 10250-10324/org.godotengine.admobaddon E/AndroidRuntime: FATAL EXCEPTION: pool-3-thread-1
Process: org.godotengine.admobaddon, PID: 10250
java.lang.IllegalArgumentException: org.godotengine.admobaddon: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
at androidx.work.impl.utils.ForceStopRunnable.getPendingIntent(ForceStopRunnable.java:174)
at androidx.work.impl.utils.ForceStopRunnable.isForceStopped(ForceStopRunnable.java:108)
at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:86)
at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:75)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:920)
2022-08-06 12:25:14.763 537-2835/? W/ActivityTaskManager: Force finishing activity org.godotengine.admobaddon/com.godot.game.GodotApp
But I didn't see the code using PendingIntent anywhere, so I search and found this:
If you are NOT USING PendingIntent anywhere. The issue might be resolved by adding or updating this dependency
// required to avoid crash on Android 12 API 31
implementation 'androidx.work:work-runtime-ktx:2.7.0'
This fixed my problem.
and this:
For those using Java: Add the following line to your build.gradle(app) under dependencies.
dependencies {
// ...
implementation 'androidx.work:work-runtime:2.7.1'
}
Thanks, this seems to have fixed it!
Yes the fix for now is add androidx.work:work-runtime:2.7.1
to the remote list on AdMob.gdap
file.
I could create a PR for this but it's better wait #127 be fixed, maybe fixing that issue will solve the issue here as well without needing to add another dependency.
@gumaciel when You fix #127, You can ping me and I'll test it as soon as I can.
Thank you so much guys for your collaboration
I need your opinion: If we change to the latest version, we will have to stop supporting versions older than 3.4.5: https://github.com/Poing-Studios/godot-admob-android/discussions/117#discussioncomment-3015011
I would like to delay this improvement https://github.com/Poing-Studios/godot-admob-android/issues/127 a little longer because I think it would be better to wait to have Mediation support for older versions
@gianlluca The fix is only to change the AdMob.gdap
and add androidx.work:work-runtime:2.7.1
?
@gianlluca The fix is only to change the
AdMob.gdap
and addandroidx.work:work-runtime:2.7.1
?
Yeah, adding androidx.work:work-runtime:2.7.1
to AdMob.gdap
file solves this issue and makes it work correctly on android 12.
Just tried this fix on 3.4.4 and 3.4.5 and doesn't work, so we will need to stop provide builds for 3.4.5 and lower :disappointed:
Works for me with 3.5 and sdk32. Thanks :)
While i was working on the upgrade version #127 , i saw this:
So on futures versions of AdMob this androidx.work:work-runtime:2.7.1
is not more required just as @gianlluca said, thanks!
Hi guys, just released this version with #127 , if possible test to check if the problem was solved: https://github.com/Poing-Studios/godot-admob-android/releases/tag/v2.1.1
Thanks for the plugin. I'm getting a data error since I upgraded to godot 3.5. I followed all recommended methods but I still get the same error report.
Device(s) with issues Google Pixel 6 (oriole) - Android 12 Google Pixel 2 (Pixel2Emulator) - Android 12 Google Pixel 2 (Pixel2Emulator) - Android 13 Google Redfin 64-bit only (redfin_64) - Android 13
Exceptions Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
Hi @ayhanasker are you using this version?
https://github.com/Poing-Studios/godot-admob-android/releases/tag/v2.1.1
If you are using the v2.1.1
and the problem still continues, then test again add androidx.work:work-runtime:2.7.1
to AdMob.gdap
yes i am using v2.1.1 version. I tried again but it still didn't solve my problem. When I test it locally on the device, there is no problem. When I send it to the google play test version, the application crashes.
config.gradle versions ... ext.versions = [ androidGradlePlugin: '7.0.3', compileSdk : 32, minSdk : 23, // Also update 'platform/android/java/lib/AndroidManifest.xml#minSdkVersion' & 'platform/android/export/export_plugin.cpp#DEFAULT_MIN_SDK_VERSION' targetSdk : 32, // Also update 'platform/android/java/lib/AndroidManifest.xml#targetSdkVersion' & 'platform/android/export/export_plugin.cpp#DEFAULT_TARGET_SDK_VERSION' buildTools : '32.0.0', kotlinVersion : '1.6.21', fragmentVersion : '1.3.6', nexusPublishVersion: '1.1.0', javaVersion : 11, ndkVersion : '23.2.8568313' // Also update 'platform/android/detect.py#get_ndk_version' when this is updated.
] ...
"If you are using the v2.1.1 and the problem still continues, then test again add androidx.work:work-runtime:2.7.1 to AdMob.gdap" regarding this:
I added it to android/build/build.gradle implementation 'androidx.work:work-runtime:2.7.1' ... dependencies { implementation libraries.kotlinStdLib implementation libraries.androidxFragment
if (rootProject.findProject(":lib")) {
implementation project(":lib")
} else if (rootProject.findProject(":godot:lib")) {
implementation project(":godot:lib")
} else {
// Custom build mode. In this scenario this project is the only one around and the Godot
// library is available through the pre-generated godot-lib.*.aar android archive files.
debugImplementation fileTree(dir: 'libs/debug', include: ['*.jar', '*.aar'])
devImplementation fileTree(dir: 'libs/dev', include: ['*.jar', '*.aar'])
releaseImplementation fileTree(dir: 'libs/release', include: ['*.jar', '*.aar'])
}
// Godot user plugins remote dependencies
String[] remoteDeps = getGodotPluginsRemoteBinaries()
if (remoteDeps != null && remoteDeps.size() > 0) {
for (String dep : remoteDeps) {
implementation dep
}
}
// Godot user plugins local dependencies
String[] pluginsBinaries = getGodotPluginsLocalBinaries()
if (pluginsBinaries != null && pluginsBinaries.size() > 0) {
implementation files(pluginsBinaries)
}
// required to avoid crash on Android 12 API 31
implementation 'androidx.work:work-runtime:2.7.1'
} ...
android/plugins/AdMob.gdap file content
[config] name="AdMob" binary_type="local" binary="admob-release.aar"
[dependencies]
remote=["com.google.android.gms:play-services-ads:20.4.0", "com.google.android.ump:user-messaging-platform:2.0.0"]
thank you for your help.
Hi @ayhanasker please replace this on your .gdap
:
[dependencies]
remote=["com.google.android.gms:play-services-ads:21.1.0", "com.google.android.ump:user-messaging-platform:2.0.0"]
@gumaciel thank you for your help [dependencies] remote=["com.google.android.gms:play-services-ads:21.1.0", "com.google.android.ump:user-messaging-platform:2.0.0"] This way admob works fine. The problem wasn't just about admob. It was fixed when I set the versions on them like Firebase, rateme
Thank you for your response! I will close this issue since seems to be fixed