Android App crashes when compiling in VS2019 SDL2.0.10


I’ve been using this project code found here: for a template app for android.
Compilation and setup goes relatively painlessly, but the app crashes in GradleApp section in when calling SDLActivity.nativeSetupJNI()

public static void setupJNI() 
SDLActivity.nativeSetupJNI();  // CRASH HERE!

IDE: VS2019 Community (C++)
SDL2.0.10 on Win10
AndroidSDK 26
AndroidNDK r20 x86_64

Logcat output:

Force stopping com.SDL2_GradleApp appid=10085 user=-1: set debug app
START u0 {flg=0x10000000 cmp=com.SDL2_GradleApp/.SDL2_GradleApp} from uid 2000
Start proc 4606:com.SDL2_GradleApp/u0a85 for activity com.SDL2_GradleApp/.SDL2_GradleApp
Application com.SDL2_GradleApp is waiting for the debugger on port 8100...
Device: generic_x86
Model: Android SDK built for x86
Force finishing activity com.SDL2_GradleApp/.SDL2_GradleApp
Showing crash dialog for package com.SDL2_GradleApp u0
Process com.SDL2_GradleApp (pid 4606) has died: vis  +99TOP 

Java Callstack to crash

> Line 15 Java savedInstanceState) Line 237 Java
com.SDL2_GradleApp.SDL2_GradleApp.onCreate(android.os.Bundle savedInstanceState) Line 13 Java icicle) Line 6975 Java activity, android.os.Bundle icicle) Line 1213 Java$ActivityClientRecord r, android.content.Intent customIntent) Line 2770 Java$ActivityClientRecord r, android.content.Intent customIntent, java.lang.String reason) Line 2892 Java -this,$ActivityClientRecord r, android.content.Intent customIntent, java.lang.String reason) Java$H.handleMessage(android.os.Message msg) Line 1593 Java
android.os.Handler.dispatchMessage(android.os.Message msg) Line 105 Java
android.os.Looper.loop Line 164 Java[] args) Line 6541 Java
java.lang.reflect.Method.invoke Java$ Line 240 Java[] argv) Line 767 Java

Relevant Debug output:

Loaded 'android.view.View$OnSystemUiVisibilityChangeListener'
Loaded ''
Loaded 'com.SDL2_GradleApp.SDL2_GradleApp'
Loaded '$SDLCommandHandler'
Loaded '$7'
Loaded ''
Exception thrown: java.lang.NullPointerException
Exception thrown: java.lang.NullPointerException

I can confirm that SDL2.0.5 on Ant works fine.
This happens to me only on gradle on VS2019 and VS2017. It happens on ARM and x86 builds. Emulated and physical device. I also tried all the combinations of Android SDK and NDK and app always crashes at this point.

Can anyone confirm this is happening to them? The link to the github project should work if VS and AndroidSDK and NDK are installed. I’ve been on this and other Android issues for 20 hours now and I’m going insane. It’s just a never ending stream of problem after problem after problem. I’ve never seen anything like it in 20 years…


Probably something with default VS gradle project where you need to create new package inheriting SDLActivity and using that package instead of default SDLActivity in build.gradle “applicationId” property. Whatever.

I ported my project to Android Studio and I’m now using shared project code until VS team fix their NDK stuff.

So probably never.