Search code examples
androidandroid-activitygoogle-imaima

The Google IMA Android SDK v3.33.0 issue with Android Single-Task Activities


I've recenty migrated to the Google IMA Android SDK v3.33.0 and I learned that all my activities which has launch mode "single-task" are opening as a separate task in the task manager!

Android Task manager

The testing is very easy, you just need to add this dependency to your an app:

implementation ("com.google.ads.interactivemedia.v3:interactivemedia:3.33.0")

that has two activities and one opens the other one which is single task:

        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name=".SubActivity"
            android:exported="false"
            android:launchMode="singleTask" />

This won't happen on v3.31.0 and bellow, but from v3.32.0 above there is an Android 14 runtime crash fix which I need to have it.


Solution

  • Meanwhile, I found this bug reported on the IMA SDK group: https://groups.google.com/g/ima-sdk/c/PfAnye3Hhww/m/08N6YyFsBAAJ

    and therefore I managed to find a workaround after understanding that it is playing around with the Android application's affinity.

    It can be fixed temporarily by adding tools:remove="android:taskAffinity" to the application's tag in the manifest file or if you have already declared a taskAffinity in the application tag, you can use tools:replace="taskAffinity" instead.

    Looking forward to a fix from Google so we get rid of this hack.