Why is my game not opening when exported and runned on android?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By App_develooer

I created a game, exported it to android, and then runned it on an android device. But whenever i click on the apk it just flips the screen(because my game is landscape) and then the game closes. In short, the game is not opening on the android device. Please help. How can i fix this problem? I really need some guidance and help.

I have noticed the same problem.

Would you happen to be using Godot 3.2? That’s where the issue happens.
Godot 3.1 works just fine with exporting to Android.

System_Error | 2020-03-12 17:43

So do i have to make my whole project again in godot 3.1? Thanks for your precious time and reply.

App_develooer | 2020-03-13 04:24

I did export/publish my (GLES2) project in Godot 3.2 successfully to Android. So there’s no general problem in 3.2. (Except with input fields when no max length is set which is solved in 3.2.1)

There are however some changes from 3.1 to 3.2. I.e. concerning CPU particles.

In your case I’d go the usual way of android debugging. And that would mean either setting up godot to directly execute/debug your app (Editor settings → Export → Android, & then clicking the little robot which occurs when the device is connected via USB).

Or - probably more informative in this case - use “adb logcat” on the command line to list any log entries written on android (can be filtered).

See i.e. this post:
My Godot Android game does not work! PANIC! (And what to do) | Digital KI

Sometimes the reason is quite simple:
#1: Fails due to wrong character case or special chars in ressource name:
i.e. you have put “Startupwindow.tscn” in autoload but the ressource is actually named “StartupWindow.tscn”. This would work in windows as it doesn’t care about character case in file names but it fails on Android (and Linux). Same can happen with file names in load / preload statements.

#2: Fails to load ressources which didn’t make it into the apk for some reason:
Sometimes some ressources don’t make it into the apk, or aren’t signed properly. This can happen due to some exclude setting in the export.

Or - if it is a non-ressource file - it wasn’t specified in the export include settings,.

Or it has special chars in the name and the jarsigner somehow fails to sign it.
The apk roughly is a simple zip file so you could use some unzip tool and check if at least the startup ressource files made it into the apk → /assets (keep in mind that the some converted binary ressource files will be with a slightly cryptic name in the assets/.imports folder).

#3: Some people actually try to write in the res:// folder:
This works in the editor but will fail on i.e. Android. Typically, you’re supposed to write in the user:// folder.

#4: You forgot to enabled some required privileges for your apk:
I.e. if you access the network then you need to enable the INTERNET privilege.

wombatstampede | 2020-03-13 07:26

i ve some problem before, after exporting my app, and the problem is the name of my image using “-”(dash) on its name, the project and export dont give me an error but that is the problem.

wahyuadiramadan | 2020-03-13 10:18

Ok, then renaming inside the godot file manager (and maybe in the script if it is loaded by script) should solve it. Mmaybe replace the dash with an underscore.

Personally, I encountered on another occasion & software a problem with a file which presumably had a dash in its name. But in fact that was only some unicode (line drawing) character which exactly looked like a dash(=minus sign).

wombatstampede | 2020-03-13 11:45

Hrm… wombatstampede, I don’t quite know where my case lies.

The very recently-made emulator I’m using ends up saying “The APK failed to install. Error: Could not parse error string.” (Emulating a Pixel 3a, with Android 10.0, via Android Studio.)

Logcat also says

03-13 04:48:35.907 2580 3208 W Conscrypt: Could not set socket write timeout: java.net.SocketException: Socket closed
03-13 04:48:35.928 2580 3208 W Conscrypt: at com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(:com.google.android.gms@200616041@20.06.16 (120800-296104215):2)
03-13 04:48:35.928 2580 3208 W Conscrypt: at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.setSoWriteTimeout(:com.google.android.gms@200616041@20.06.16 (120800-296104215):0)
03-13 04:48:36.019 2580 3208 W Conscrypt: Could not set socket write timeout: java.net.SocketException: Socket closed
03-13 04:48:36.020 2580 3208 W Conscrypt: at com.google.android.gms.org.conscrypt.Platform.setSocketWriteTimeout(:com.google.android.gms@200616041@20.06.16 (120800-296104215):2)
03-13 04:48:36.020 2580 3208 W Conscrypt: at com.google.android.gms.org.conscrypt.ConscryptFileDescriptorSocket.setSoWriteTimeout(:com.google.android.gms@200616041@20.06.16 (120800-296104215):0)
03-13 04:48:36.204 2580 3208 W GLSUser : [AppCertManager] IOException while requesting key:
03-13 04:48:36.204 2580 3208 W GLSUser : java.io.IOException: Invalid device key response.
03-13 04:48:36.204 2580 3208 W GLSUser : at iko.a(:com.google.android.gms@200616041@20.06.16 (120800-296104215):51)
03-13 04:48:36.204 2580 3208 W GLSUser : at ikm.a(:com.google.android.gms@200616041@20.06.16 (120800-296104215):43)
03-13 04:48:36.204 2580 3208 W GLSUser : at ikh.a(:com.google.android.gms@200616041@20.06.16 (120800-296104215):0)
03-13 04:48:36.204 2580 3208 W GLSUser : at ikk.a(:com.google.android.gms@200616041@20.06.16 (120800-296104215):10)
03-13 04:48:36.204 2580 3208 W GLSUser : at gxk.call(:com.google.android.gms@200616041@20.06.16 (120800-296104215):9)
03-13 04:48:36.204 2580 3208 W GLSUser : at java.util.concurrent.FutureTask.run(FutureTask.java:266)
03-13 04:48:36.204 2580 3208 W GLSUser : at sqf.b(:com.google.android.gms@200616041@20.06.16 (120800-296104215):14)
03-13 04:48:36.204 2580 3208 W GLSUser : at sqf.run(:com.google.android.gms@200616041@20.06.16 (120800-296104215):5)
03-13 04:48:36.204 2580 3208 W GLSUser : at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
03-13 04:48:36.204 2580 3208 W GLSUser : at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
03-13 04:48:36.204 2580 3208 W GLSUser : at swe.run(:com.google.android.gms@200616041@20.06.16 (120800-296104215):0)
03-13 04:48:36.204 2580 3208 W GLSUser : at java.lang.Thread.run(Thread.java:919)
03-13 04:48:38.680 2037 2347 W PackageParser: Failed to parse /data/app/vmdl684501135.tmp/base.apk
03-13 04:48:38.680 2037 2347 W PackageParser: java.io.FileNotFoundException: AndroidManifest.xml
03-13 04:48:38.680 2037 2347 W PackageParser: at android.content.res.ApkAssets.nativeOpenXml(Native Method)
03-13 04:48:38.680 2037 2347 W PackageParser: at android.content.res.ApkAssets.openXml(ApkAssets.java:156)
03-13 04:48:38.680 2037 2347 W PackageParser: at android.content.pm.PackageParser.parseApkLiteInner(PackageParser.java:1599)
03-13 04:48:38.680 2037 2347 W PackageParser: at android.content.pm.PackageParser.parseApkLite(PackageParser.java:1566)
03-13 04:48:38.680 2037 2347 W PackageParser: at com.android.server.pm.PackageInstallerSession.validateApkInstallLocked(PackageInstallerSession.java:1553)
03-13 04:48:38.680 2037 2347 W PackageParser: at com.android.server.pm.PackageInstallerSession.sealAndValidateLocked(PackageInstallerSession.java:1130)
03-13 04:48:38.680 2037 2347 W PackageParser: at com.android.server.pm.PackageInstallerSession.markAsCommitted(PackageInstallerSession.java:987)
03-13 04:48:38.680 2037 2347 W PackageParser: at com.android.server.pm.PackageInstallerSession.commit(PackageInstallerSession.java:849)
03-13 04:48:38.680 2037 2347 W PackageParser: at android.content.pm.PackageInstaller$Session.commit(PackageInstaller.java:1072)
03-13 04:48:38.680 2037 2347 W PackageParser: at com.android.server.pm.PackageManagerShellCommand.doCommitSession(PackageManagerShellCommand.java:2810)
03-13 04:48:38.680 2037 2347 W PackageParser: at com.android.server.pm.PackageManagerShellCommand.runInstall(PackageManagerShellCommand.java:1076)
03-13 04:48:38.680 2037 2347 W PackageParser: at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:169)
03-13 04:48:38.680 2037 2347 W PackageParser: at android.os.ShellCommand.exec(ShellCommand.java:104)
03-13 04:48:38.680 2037 2347 W PackageParser: at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:21729)
03-13 04:48:38.680 2037 2347 W PackageParser: at android.os.Binder.shellCommand(Binder.java:881)
03-13 04:48:38.680 2037 2347 W PackageParser: at android.os.Binder.onTransact(Binder.java:765)
03-13 04:48:38.680 2037 2347 W PackageParser: at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4860)
03-13 04:48:38.680 2037 2347 W PackageParser: at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4014)
03-13 04:48:38.680 2037 2347 W PackageParser: at android.os.Binder.execTransactInternal(Binder.java:1021)
03-13 04:48:38.680 2037 2347 W PackageParser: at android.os.Binder.execTransact(Binder.java:994)
03-13 04:48:38.661 2037 2037 W Binder:2037_8: type=1400 audit(0.0:35): avc: denied { getopt } for scontext=u:r:system_server:s0 tcontext=u:r:shell:s0 tclass=unix_stream_socket permissive=0
03-13 04:48:38.787 1872 1872 E : Couldn’t opendir /data/app/vmdl684501135.tmp: No such file or directory
03-13 04:48:38.788 1872 1872 E installd: Failed to delete /data/app/vmdl684501135.tmp: No such file or directory
03-13 04:48:38.791 2037 2037 W Binder:2037_8: type=1400 audit(0.0:36): avc: denied { getopt } for scontext=u:r:system_server:s0 tcontext=u:r:shell:s0 tclass=unix_stream_socket permissive=0
03-13 04:48:38.801 1853 1853 W adbd : type=1400 audit(0.0:39): avc: denied { shutdown } for scontext=u:r:adbd:s0 tcontext=u:r:shell:s0 tclass=unix_stream_socket permissive=0

System_Error | 2020-03-13 11:55

I’d try out a “real” Android device. Just connect it via usb. (Although it is possible to switch to debugging via WiFi but this would make it to complicated for now)

In that log file I just see a message that it couldn’t find the file “AndroidManifest.xml” in a file called “base.apk”. Is your apk named “base.apk”?

wombatstampede | 2020-03-13 12:19

In mine case, there is no error showing on the output screen of godot when exporting to android and yet it still not opens on android(i tried opening in 2 different android devices but in both it does not opens). How can i fix this error?

App_develooer | 2020-03-13 12:30

What messages concerning godot where listed via “adb logcat”?

Did you check your app against the topics 1-4 which I listed above?

wombatstampede | 2020-03-13 12:40

So I plugged my phone in, and attempted to test the game on it.
(I couldn’t find a way to run Logcat for the device, though…)

Godot seems to be unable to get the game onto my phone (which is in Dev Mode).
It’s really annoying, because I designed this game to work on Android devices.

The apk’s supposed to be lasershipdefense_debug.apk

System_Error | 2020-03-13 13:27

I checked all the 4 topics. There is no problem with all except 1, because i could not see the autoload neither did i put something in autoload(i dont even know what it is). So how can i check the first topic. Thanks for your precious time and reply.

App_develooer | 2020-03-13 14:27

On another android device , i am getting error saying “{game name} has stopped working”. Please help. What should i do?

App_develooer | 2020-03-14 05:38

Find the path to the adb tool.
Maybe it is already configured in your godot Editor (!) settings → Export → Android → Adb.
If not, then add it there.

Make sure that USB-Debugging is enabled on your phone.

Before starting the app on the (via usb connected) phone start adb logcat > output.txt.

Logcat command-line tool  |  Android Studio  |  Android Developers

more advanced command line here:
My Godot Android game does not work! PANIC! (And what to do) | Digital KI

After the game has failed to start → stop adb with strg+c.
Check output.txt for godot related messages. (if not told otherwise adb will list all android log messages). If in doubt → post them here.

You can add print commands to your startup code (gdscript). They should also appear in the logcat output. Maybe that helps identifying how far it gets.

wombatstampede | 2020-03-14 10:24

This is the main output by running adb logcat ( note: gameofballs is the name of my game and com.GameOfbAlls is the package name):

Process: com.GameOfbAlls, PID: 29798
03-13 19:04:56.760 29798 29841 E AndroidRuntime: java.lang.ClassNotFoundException: Didn’t find class “org/godotengine/godot/GodotAdMob” on path: DexPathList[[zip file “/data/app/com.GameOfbAlls-Eqbzo0CrGL7Lsz1Vm9N26A==/base.apk”],nativeLibraryDirectories=[/data/app/com.GameOfbAlls-Eqbzo0CrGL7Lsz1Vm9N26A==/lib/arm, /data/app/com.GameOfbAlls-Eqbzo0CrGL7Lsz1Vm9N26A==/base.apk!/lib/armeabi-v7a, /system/lib, /system/vendor/lib]]

This error was listed there many times with all the same things, just the PID was different.
I think that the problem is with my admob code (because something about admob is written up there). This is my admob code:

https://drive.google.com/file/d/1j4itotsmEiUoCx7NL3ZqSy3SvmmNnjpZ/view?usp=drivesdk

How can i fix this?
Thanks for helping!!

App_develooer | 2020-03-14 14:16

Please help!

App_develooer | 2020-03-15 05:22

I do also founded something , that the statement if Engine.has_Singleton(“Admob”) , returns false. What should i do?

App_develooer | 2020-03-15 15:19

Well, if Engine.has_Singletom(“Admob”) returns false, I have a couple questions.

First, check in your Project Settings. There’s a section for Android. Do you have org/godotengine/godot/GodotAdMob in the Modules list?

Also, check through the hidden files of your game. There should be a folder labeled “android”. In the “build” folder within that, you should have your “admob-lib”. Is it in there?

System_Error | 2020-03-15 16:06

Yes i do have “org/godotengine/godot/GodotAdMob” in the modules list.
But there is no folder labeled “android”. What should i do? Thank you for your precious time and reply.

App_develooer | 2020-03-16 06:06

Do you have the Android Build Template?

If not, open the Project tab, and click on Install “Android Build Template…” That will generate the necessary folders for your project.

System_Error | 2020-03-16 12:51

Done… i had installed the android build template and now it is opening and not crashing. But now, it just loops between 2 screens and the game not starts in android. The first screen is godot symbol followed by “godot game engine” written. Then the next screen is just a blank black screen. First, the first screen comes, then second,then again first and so on and the game never starts. What should i do?

App_develooer | 2020-03-17 07:41

Hrm… and you have previously set the main scene that should open up when you run the game?

Perhaps get the LogCat output. Filter it for only Godot messages.

System_Error | 2020-03-17 15:01

:bust_in_silhouette: Reply From: Godotmen

I found that some problems with running the game are from puting sprites or pictures with different language than english or some symbols. So solution to run the game is to puting in Godot foldders only files with english names and withouth symbols.