"Failed to attach debugger" when targetting android dmengine (SOLVED)

Hello,

So I installed dmengine.apk on an android device as per the instructions here: https://defold.com/manuals/dev-app/

Now I select it from the targets list in the editor.

image

But when I try to start the game I get the following error:

image

The full error message:

Server returned HTTP response code: 400 for URL: http://192.168.0.123:8001/post/@system/run_script
  • I have checked that both the dmengine on the phone and the editor are on Engine SHA1 5791ee6d96b87e50eee5acd70abaa4026fefef28 (1.2.170)
  • The app on the device correctly says “Listening on interfaces: 192.168.0.123”
  • I have tried restarting both the device and the editor multiple times.
  • I have tried more than one android phone, with both of them I get the same exact error.
  • Connecting through USB the device does not show up on the targets list, is it necessary to have adb installed?

Is this a bug or am I missing something?

Thanks in advance :slight_smile:

This could be a bug. I get the feeling that this kind of issue is happening more frequently now. We need to try and reproduce it.

Does it happen with all projects or just one?

1 Like

Thanks for the response :slight_smile:

I just tried it with the warbattles example too - exact same error.

I have the same problem. Build works normally through dmengine.apk but debugging throws HTTP 400 code in the editor. If I build and run the game first and then attach debugger, I get also this in the console:

ERROR:ENGINE: Too large message
WARNING:DLIB: Unsupported status code: 400

I also checked the editor log file from AppData\Local\Defold and this error comes in both debug and attach scenarios:

2020-07-14 13:27:36.325 109925 [JavaFX Application Thread] ERROR editor.debug-view - {:line 492, :msg “Failed to attach debugger to 192.168.178.21:8172.\nCheck that the game is running and is reachable over the network.\n”}
java.io.IOException: Server returned HTTP response code: 400 for URL: http://192.168.178.21:8001/post/@system/run_script
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1913)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1509)
at editor.engine$run_script_BANG_.invokeStatic(engine.clj:112)
at editor.debug_view$attach_BANG_$fn__43803.invoke(debug_view.clj:566)
at editor.debug_view$attach_BANG_.invokeStatic(debug_view.clj:566)
at editor.app_view$attach_debugger_BANG_$fn__45874.invoke(app_view.clj:865)
at editor.app_view$async_build_BANG_$fn__45774$fn__45782.invoke(app_view.clj:772)
at clojure.lang.AFn.run(AFn.java:22)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)

Info from editor:

Defold channel editor-alpha
Defold editor sha 93dfddbda0cfa48df9b4cbbd805addeeff1edae3
Defold engine sha 5791ee6d96b87e50eee5acd70abaa4026fefef28
Defold version 1.2.170
GPU GeForce GT 635M/PCIe/SSE2
GPU Driver 4.6.0 NVIDIA 391.35
Java version 11.0.1+13
OS arch amd64
OS name Windows 10
OS version 10.0

Info from dmengine.apk:

Defold version 1.2.170
SHA1 5791ee6d96b87e50eee5acd70abaa4026fefef28
Listening on interfaces: 192.168.178.21

Info from Android:

Model moto g7 plus (XT1965-3)
Android version 10
Security batch level June 1, 2020
Build number: QPWS30.61-21-11

Edit: I’ve also tried these:

  • restart phone and PC
  • check firewall settings and let through dmengine.exe and java.exe
  • delete Defold folders from AppData and and reinstall editor and dmengine.apk
  • test in different project (I created a new project from mobile project template)

If I remember right, this worked couple weeks back when I was using another computer. But I haven’t had many successes with Android debugging. It works sometimes :smiley:
Also a side question: Most of the time I have to wait approx. 5 minutes until my phone is showing in the editor Project -> Target. Is this normal?

1 Like

Not for me, it’s basically instant.

I’ve pushed a change to the editor now, and attaching the debugger should work properly again. Please update the editor and try again.

4 Likes

Awesome, thank you! :slight_smile: It works again.

1 Like

I updated and now I get a different error:

image

And from the log file:

2020-07-14 21:02:51.590 23956 [clojure-agent-send-off-pool-7] INFO  editor.boot-open-project - {:line 407, :message "project loaded"}
2020-07-14 21:03:04.951 37317 [pool-3-thread-1] ERROR editor.error-reporting - {:line 110}
java.net.SocketTimeoutException: connect timed out
	at java.base/java.net.PlainSocketImpl.waitForConnect(Native Method)
	at java.base/java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:107)
	at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
	at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
	at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
	at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403)
	at java.base/java.net.Socket.connect(Socket.java:591)
	at editor.debugging.mobdebug$try_connect_BANG_.invokeStatic(mobdebug.clj:328)
	at editor.debugging.mobdebug$connect_BANG_$fn__43028.invoke(mobdebug.clj:333)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)

Again on both of the phones that I tried it on.

I get that same error too if I start debugging the game before building it first. If you build it first and then debug/attach debugger it should work. I’ve had that error always. I don’t know if it’s a bug but it has not been a problem for me :smiley:

2 Likes

So I definitely built it in advance when I tried it.

But what solved it was this: Starting with CTRL-B instead of F5

A bit strange since I thought F5 was just a shortcut to Project > Build, but anyway, thanks for the tip!

1 Like