On Android, nothing is displayed on the screen

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

After exporting to Android like title, you will not see anything on screen when you run it on your device

The first scene is well displayed Text or buttons etc.

However, if you move on to the next scene, nothing will be displayed except for the default gray background

Many of my nodes and buttons are not visible

Their names are made up of lowercase letters

When testing on a PC, it will display well, but not only on Android.

I do not know why.

Please show the code (GDScript) which you use to load the new scene.

Please show the code - if any - which is in the _ready() function(s) of the new scene or any controls.

wombatstampede | 2019-02-25 17:14

enter image description here
↑load the new scene script

enter image description here
↑next scene’s script

MungMoong | 2019-02-25 17:59

save_doctionary() writes to a file? Maybe it tries to write to a file in res:// which os forbidden on some platforms including Android. Write to user:// instead.

Just a guess though.

wombatstampede | 2019-02-25 18:57

I saw your comment and replaced it with ‘user’ instead of ‘res’
But there is no difference …

MungMoong | 2019-02-26 05:21

If you start the android app via the one-click deploy (little android robot icon in the upper right) and enabled remote debugging (debugging menu) then you should get Error Messages and Output of the android app.

There, you should also be able to see which error occured.

If that doesn’t help further then try “printf debugging”. Which means that you place some print(“still alive! 1/2/3…”) in i.e. your new scene code to see how far the code gets until it runs on an error…

wombatstampede | 2019-02-26 07:35

I have enabled remote debugging but nothing is output to the editor
Something seems to be wrong
I want to find more posts, but most of them are old versions.
There any recent posts that I can refer to?

MungMoong | 2019-02-26 10:09

Naturally, you need to enable “Start with remote debugging” in the Debug menu.

I needed also to enter/select my computers local Network IP in the Editor Settings → Network → Debug → Remote Host.

wombatstampede | 2019-02-26 13:46

Finally connected
Remote debugging is only possible when running in one click deploy

I get an error in the ‘save_dictionary’ part as you said
Nonexistent function ‘load_data’in base’ Nill 'error
Maybe there is a problem with the script used in the singleton

And when you run it with remote debugging, it stops when you move from the first screen to the next scene
If you run it without remote debugging, it will jump from the first screen to the next scene, but nothing will be displayed

MungMoong | 2019-02-26 14:18

This reads like global isn’t autoloaded and therefore Nil and therefore its load_data() method is not found.

Normally, you define global in Project->Settings->Autoload. (Checkmark at ‘Singleton’)
But I guess, you already did this because it runs in Windows.

Maybe global failed to load for some reason. I.e. an error in its _ready() method (if any).
Put a print("global _ready start") on the start of that function and a print("global _ready complete") on its end.

Check your error handling in file loading and saving methods. And do error checking and reporting as much as possible.

Here’s an example for “safe” file reading:

func load_a_file(filename):
	var file = File.new()
	var contents=""
	if file.file_exists(filename):
		file.open(filename, file.READ)
		contents = file.get_as_text()
		file.close()
	else:
		print("Error: File: "+filename+" not found!")
	return contents

Maybe you try to read a file which exists in windows but does not exist/is not exported in Android.

Finally: There’s usually no mouse click on android. But the (default) option to emulate mouse clicks via touch will generate that. It is possible though that this emulation behaves a bit different here and there. Just look that you get your “pressed!” print output only once for example.

Edit:
Make sure that you didn’t define Global.gd in your Autoload project settings while the file is actually named global.gd. In other words: Check the case. (You said you already did but case sensitivity problems are the most probable reason for your global singleton not loading.)

wombatstampede | 2019-02-26 14:47

You were right.
There is no ‘print’ statement in print.
The editor also displays the above
However, in the PC environment, the ‘print’ statement is also printed and there is no error
And as you can see in the picture above, the name of the script using the singleton is lowercase.

How do I do this?
Would I change the ‘res’ part back to ‘user’?

  • I am very sorry to have asked you a lot of questions.

MungMoong | 2019-02-26 18:13

Your posted images are very difficult to obtain. I was only able to catch the last only from the email notification. Maybe use another image hoster ( imgur.com ? ).

The error message says that global.gd could not be loaded. Maybe the file didn’t make it in the android apk.

I’d check the console window during build for any messages concerning global.gd. (In windows you can set the console window buffer size to a higher line number and then copy&paste the content to a text editor).

I’d make a copy of the apk from the temporary path (one-click) or from the export function and look into it with some unzip tool (personally, I use Total Commander but anything might do (i.e. WinZip). You should find global.gdc and global.remap in the scripts subdirectory (in your case).

I have to add that this is not normal. I have never encountered any problems with scripts not being added to the apk. I can just guess that there’s some error happening during the build/compile process.

wombatstampede | 2019-02-27 06:59

Oh, I found out why.
Export - Android - Resources - Export mode

I do not seem to have any images running in the singleton because I selected ‘Export selected scene’ without selecting ‘Export all resources in project’

I set up ‘Export all resources in my project’ and tested it on my device so I can see the images

Thank you very much! :smiley:

MungMoong | 2019-02-27 11:06