Build custom dmengine.apk with native extensions included

Hi everyone!
I was wondering if it was possible to build a custom dmengine.apk with some native extensions integrated into it (for example Admob).

This would be really useful, because the current way I’m doing it is to rebuild an Android release every time I need to test something related to an extension.

In Gideros there’s the possibility to export and build a project as “player”, which includes only the engine and the extensions and act like an empty dmengine.

Is there a way to do so in Defold?

EDIT: I just found this topic Launching "dmengine" directly with native modules (SOLVED) and it looks like that by building in “Debug” mode this acts like a custom dmengine. I tried that in the past but I could not connect from the editor to the phone, I’ll try again as soon as I get home.

Crypto

2 Likes

When you build a debug version of your APK with any included native extensions, it can be used for live update. Exactly the same way as vanilla dmengine.apk.

4 Likes

Thanks, you are right! I just found this topic Launching "dmengine" directly with native modules (SOLVED) which explains that.

(I was indeed trying to test your AdMob extension. Great job!)

3 Likes

I’ve updated the mobile dev app manual to try and highlight this a bit better.

3 Likes

After some messing around I noticed that after adding a couple of extension I couldn’t re-run the game on the already installed apk.

  • Defold 1.2.156 on Windows 10
  • OnePlus 6 - Android 9.0.6

Steps:

  1. Export the project for Android in Debug mode
  2. Install the APK on the phone and run the app
  3. On Defold, try to run the game on the Android device.
  4. The already-running game should freeze until it’s closed or crashes (I’ve seen both behaviors)
  5. On Defold, this error should come up:
FATAL:ENGINE: Unable to load project file: 'http://10.XX.XX.XX:50460/build/game.projectc' (-1)

Is this a know thing or am I doing something wrong?

Here’s an almost empty project I used to replicate the issue: DMEngine Mod.zip (73.3 KB)

I’m actually unable to reproduce this on my phone. I am running on macOS though, but I’m not sure if this matters or not.

Thank you. Unfortunately I don’t have a macOS machine to test the project on, however I will try with different Android smartphones and let you know.

Tried with:

  • Different Windows 10 machines: YES - Issue present
  • Different macOS machines: NO
  • Different Android phones: NOT YET
  • Different iOS phones: NO

And what does the adb logcat say?

Quick update, on my Desktop PC the issue seems to not be present. The apps launches fine.
However when I try to run it from my laptop the installed apk freezes and crashes after a while. The Defold versions are the same (1.2.156, both on editor-alpha with the same SHA1).

The only (apparent) differences between the two systems are:

  • The Desktop is on the latest Windows 10 May 2019 update (the notebook isn’t but I’m currently updating, this might be a reason)
  • The Desktop is directly connected via Ethernet to the switch, the notebook is on WiFi (obviously the phone is on WiFi too)

Logcat after crashing:

06-24 19:20:53.636   876  1538 I InputDispatcher: Application is not responding: Window{dc7d6fa u0 net.crypto.dmenginemod/com.dynamo.android.DefoldActivity}.  It has been 5006.4ms since event, 5005.2ms since wait started.  Reason: Waiting to send non-key event because the touched window has not finished processing certain input events that were delivered to it over 500.0ms ago.  Wait queue length: 20.  Wait queue head age: 5683.1ms.
06-24 19:20:53.643   876  1538 I WindowManager: Input event dispatching timed out sending to net.crypto.dmenginemod/com.dynamo.android.DefoldActivity.  Reason: Waiting to send non-key event because the touched window has not finished processing certain input events that were delivered to it over 500.0ms ago.  Wait queue length: 20.  Wait queue head age: 5683.1ms.
06-24 19:20:57.107   876 32203 E ActivityManager: ANR in net.crypto.dmenginemod (net.crypto.dmenginemod/com.dynamo.android.DefoldActivity)
06-24 19:21:01.189  1777  1777 I PhoneStatusBarView: isFullAndNotchEnabled() isFullMode=false pkg=net.crypto.dmenginemod isCameraNotchIgnoreSetting=false, uid=10220
06-24 19:21:06.722   876  1538 I InputDispatcher: Application is not responding: Window{dc7d6fa u0 net.crypto.dmenginemod/com.dynamo.android.DefoldActivity}.  It has been 5011.6ms since event, 5009.8ms since wait started.  Reason: Waiting to send non-key event because the touched window has not finished processing certain input events that were delivered to it over 500.0ms ago.  Wait queue length: 20.  Wait queue head age: 18768.7ms.
06-24 19:21:06.725   876  1538 I WindowManager: Input event dispatching timed out sending to net.crypto.dmenginemod/com.dynamo.android.DefoldActivity.  Reason: Waiting to send non-key event because the touched window has not finished processing certain input events that were delivered to it over 500.0ms ago.  Wait queue length: 20.  Wait queue head age: 18768.7ms.
06-24 19:21:09.972   876 32263 E ActivityManager: ANR in net.crypto.dmenginemod (net.crypto.dmenginemod/com.dynamo.android.DefoldActivity)
06-24 19:21:09.972   876 32263 E ActivityManager:   0.9% 32035/net.crypto.dmenginemod: 0.5% user + 0.3% kernel / faults: 883 minor
06-24 19:21:16.846 32035 32054 F pto.dmenginemo: java_vm_ext.cc:542]   native: #09 pc 000000000024c430  /data/app/net.crypto.dmenginemod-Bhwm-7czXvO5L8n1dvuzLw==/lib/arm64/libDMEngineMod.so (dmSound::PlatformFinalize()+80)
06-24 19:21:16.846 32035 32054 F pto.dmenginemo: java_vm_ext.cc:542]   native: #10 pc 000000000023eb88  /data/app/net.crypto.dmenginemod-Bhwm-7czXvO5L8n1dvuzLw==/lib/arm64/libDMEngineMod.so (dmSound::Finalize()+20)
06-24 19:21:16.846 32035 32054 F pto.dmenginemo: java_vm_ext.cc:542]   native: #11 pc 000000000005ed40  /data/app/net.crypto.dmenginemod-Bhwm-7czXvO5L8n1dvuzLw==/lib/arm64/libDMEngineMod.so (dmEngine::Delete(dmEngine::Engine*)+120)
06-24 19:21:16.846 32035 32054 F pto.dmenginemo: java_vm_ext.cc:542]   native: #12 pc 000000000005efc4  /data/app/net.crypto.dmenginemod-Bhwm-7czXvO5L8n1dvuzLw==/lib/arm64/libDMEngineMod.so (_ZN8dmEngineL7InitRunEPN15dmEngineService13EngineServiceEiPPcPFvPNS_6EngineEPvES9_S7_+228)
06-24 19:21:16.846 32035 32054 F pto.dmenginemo: java_vm_ext.cc:542]   native: #13 pc 000000000005f094  /data/app/net.crypto.dmenginemod-Bhwm-7czXvO5L8n1dvuzLw==/lib/arm64/libDMEngineMod.so (_ZN8dmEngine6LaunchEiPPcPFvPNS_6EngineEPvES6_S4_+160)
06-24 19:21:16.846 32035 32054 F pto.dmenginemo: java_vm_ext.cc:542]   native: #14 pc 000000000005b660  /data/app/net.crypto.dmenginemod-Bhwm-7czXvO5L8n1dvuzLw==/lib/arm64/libDMEngineMod.so (engine_main(int, char**)+120)
06-24 19:21:16.846 32035 32054 F pto.dmenginemo: java_vm_ext.cc:542]   native: #15 pc 00000000000582cc  /data/app/net.crypto.dmenginemod-Bhwm-7czXvO5L8n1dvuzLw==/lib/arm64/libDMEngineMod.so (main+24)
06-24 19:21:16.846 32035 32054 F pto.dmenginemo: java_vm_ext.cc:542]   native: #16 pc 0000000000220904  /data/app/net.crypto.dmenginemod-Bhwm-7czXvO5L8n1dvuzLw==/lib/arm64/libDMEngineMod.so (_glfwPreMain+224)
06-24 19:21:16.846 32035 32054 F pto.dmenginemo: java_vm_ext.cc:542]   native: #17 pc 00000000000582f4  /data/app/net.crypto.dmenginemod-Bhwm-7czXvO5L8n1dvuzLw==/lib/arm64/libDMEngineMod.so (android_main+20)
06-24 19:21:16.846 32035 32054 F pto.dmenginemo: java_vm_ext.cc:542]   native: #18 pc 000000000022115c  /data/app/net.crypto.dmenginemod-Bhwm-7czXvO5L8n1dvuzLw==/lib/arm64/libDMEngineMod.so (android_app_entry+180)
06-24 19:21:16.927 32035 32054 F pto.dmenginemo: runtime.cc:565]   native: #14 pc 000000000024c430  /data/app/net.crypto.dmenginemod-Bhwm-7czXvO5L8n1dvuzLw==/lib/arm64/libDMEngineMod.so (dmSound::PlatformFinalize()+80)
06-24 19:21:16.927 32035 32054 F pto.dmenginemo: runtime.cc:565]   native: #15 pc 000000000023eb88  /data/app/net.crypto.dmenginemod-Bhwm-7czXvO5L8n1dvuzLw==/lib/arm64/libDMEngineMod.so (dmSound::Finalize()+20)
06-24 19:21:16.927 32035 32054 F pto.dmenginemo: runtime.cc:565]   native: #16 pc 000000000005ed40  /data/app/net.crypto.dmenginemod-Bhwm-7czXvO5L8n1dvuzLw==/lib/arm64/libDMEngineMod.so (dmEngine::Delete(dmEngine::Engine*)+120)
06-24 19:21:16.927 32035 32054 F pto.dmenginemo: runtime.cc:565]   native: #17 pc 000000000005efc4  /data/app/net.crypto.dmenginemod-Bhwm-7czXvO5L8n1dvuzLw==/lib/arm64/libDMEngineMod.so (_ZN8dmEngineL7InitRunEPN15dmEngineService13EngineServiceEiPPcPFvPNS_6EngineEPvES9_S7_+228)
06-24 19:21:16.927 32035 32054 F pto.dmenginemo: runtime.cc:565]   native: #18 pc 000000000005f094  /data/app/net.crypto.dmenginemod-Bhwm-7czXvO5L8n1dvuzLw==/lib/arm64/libDMEngineMod.so (_ZN8dmEngine6LaunchEiPPcPFvPNS_6EngineEPvES6_S4_+160)
06-24 19:21:16.927 32035 32054 F pto.dmenginemo: runtime.cc:565]   native: #19 pc 000000000005b660  /data/app/net.crypto.dmenginemod-Bhwm-7czXvO5L8n1dvuzLw==/lib/arm64/libDMEngineMod.so (engine_main(int, char**)+120)
06-24 19:21:16.927 32035 32054 F pto.dmenginemo: runtime.cc:565]   native: #20 pc 00000000000582cc  /data/app/net.crypto.dmenginemod-Bhwm-7czXvO5L8n1dvuzLw==/lib/arm64/libDMEngineMod.so (main+24)
06-24 19:21:16.927 32035 32054 F pto.dmenginemo: runtime.cc:565]   native: #21 pc 0000000000220904  /data/app/net.crypto.dmenginemod-Bhwm-7czXvO5L8n1dvuzLw==/lib/arm64/libDMEngineMod.so (_glfwPreMain+224)
06-24 19:21:16.927 32035 32054 F pto.dmenginemo: runtime.cc:565]   native: #22 pc 00000000000582f4  /data/app/net.crypto.dmenginemod-Bhwm-7czXvO5L8n1dvuzLw==/lib/arm64/libDMEngineMod.so (android_main+20)
06-24 19:21:16.927 32035 32054 F pto.dmenginemo: runtime.cc:565]   native: #23 pc 000000000022115c  /data/app/net.crypto.dmenginemod-Bhwm-7czXvO5L8n1dvuzLw==/lib/arm64/libDMEngineMod.so (android_app_entry+180)
06-24 19:21:16.945 32035 32054 I defold  : INFO:CRASH: Successfully wrote Crashdump to file: /data/user/0/net.crypto.dmenginemod/files/_crash
06-24 19:21:17.027   876  1538 W InputDispatcher: channel 'dc7d6fa net.crypto.dmenginemod/com.dynamo.android.DefoldActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
06-24 19:21:17.027   876  1538 E InputDispatcher: channel 'dc7d6fa net.crypto.dmenginemod/com.dynamo.android.DefoldActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
06-24 19:21:17.032   876 11606 D EmbryoManager: prepare net.crypto.dmenginemod user 0
06-24 19:21:17.032   876  6143 I WindowManager: WIN DEATH: Window{dc7d6fa u0 net.crypto.dmenginemod/com.dynamo.android.DefoldActivity}
06-24 19:21:17.032   876  6143 W InputDispatcher: Attempted to unregister already unregistered input channel 'dc7d6fa net.crypto.dmenginemod/com.dynamo.android.DefoldActivity (server)'
06-24 19:21:17.032   876 11606 I ActivityManager: Process net.crypto.dmenginemod (pid 32035) has died: fore TOP
06-24 19:21:17.033   876 11606 W ActivityManager: Force removing ActivityRecord{73e0390 u0 net.crypto.dmenginemod/com.dynamo.android.DefoldActivity t1301}: app died, no saved state
06-24 19:21:17.051   762  1078 W SurfaceFlinger: Attempting to destroy on removed layer: AppWindowToken{b902c8e token=Token{bdd9489 ActivityRecord{73e0390 u0 net.crypto.dmenginemod/com.dynamo.android.DefoldActivity t1301}}}#0

Could you check if you have Ipv4 or Ipv6 on your desktop and laptop?

I have them both enabled and working, I tried to disable IPv6 both on the laptop and on the phone but no luck getting it to work. (Just updated to the latest May 2019 release).

I don’t know if this might help but all of the devices are on the same LAN network and the IPs are provided by the same DHCP server.


Update: Disabling the Windows Firewall did the trick. Holy cow.
Thank you guys for the help!