20. September 2017

SDL2 Android application crash on device rotation

If SDL2 application should support rotation it is necessary to add the following line to AndroidManifest.xml activity:

android:configChanges="orientation"

The XML will look like this:

<activity
    android:name="rocks.georgik.sdlapp.MainActivity"
    android:label="@string/title_activity_main"
    android:configChanges="orientation">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

The rotation of the application now works without problem:

Thanks to José Luis Pereira for the hint how to solve the issue.

The source code of the sample SDL2 application is stored at GitHub.