Skip to content

Test manifest additions should include android:exported #896

Closed

Description

@nic0lette

Description

The AndroidManifest.xml additions included in the test libraries need to include explicit values for "android:exported" or apps targeting 'S' (Android 12) cannot properly run lint/tests.

Steps to Reproduce

Create an empty project in Android Studio (with test dependencies). Change the targetSdkVersion to 'S' and the compileSdkVersion to 'android-S'. On the command line, run ./gradlew lintDebug.

Expected Results

Lint runs

Actual Results

Multiple instance of:

<<project path>>/app/build/intermediates/tmp/manifest/androidTest/debug/manifestMerger17421330438388203262.xml Error:
        Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

AndroidX Test and Android OS Versions

Android version: 12 DP1
AndroidX Test:

testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

Activity

  1. brettchabot commented on Mar 11, 2021

    @brettchabot
    Collaborator

    This should already be fixed in the latest release.
    dd6df4a

    Please reopen if there are still issues

  2. TedHopp commented on Dec 5, 2021

    @TedHopp

    A fix for this problem was described in this comment to a similar issue, based on this StackOverflow answer. Add the following to the module dependencies:

    androidTestImplementation "androidx.test.ext:junit:1.1.3"

  3. Gesugao-san commented on Jan 13, 2022

    @Gesugao-san

    @TedHopp You saved my day!!!

  4. galacticappster04 commented on Sep 28, 2022

    @galacticappster04

    This is still happening on

        androidTestImplementation "androidx.test:core:1.4.0"
        // Kotlin extensions for androidx.test.core
        androidTestImplementation "androidx.test:core-ktx:1.4.0"
    

    Using build:gradle 7.2.2 and compileSdk 32

    Someone opened a ticket already here but not sure if this belong here as well:
    https://issuetracker.google.com/issues/182098106

    The workaround stated there is to redeclare in the main manifest the ff:

        <activity
            android:name="androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity"
            android:theme="@android:style/Theme"
            android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
            </intent-filter>
        </activity>
        <activity
            android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity"
            android:theme="@android:style/Theme"
            android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
            </intent-filter>
        </activity>
        <activity
            android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity"
            android:theme="@android:style/Theme.Dialog"
            android:exported="false">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
            </intent-filter>
        </activity>
    

    Which seem to work in our case. Requesting to reopen this ticket if this issue belongs here.

  5. castroreyrobert commented on Sep 28, 2022

    @castroreyrobert

    this also fixed my issue. Thanks

  6. brettchabot commented on Sep 29, 2022

    @brettchabot
    Collaborator

    Can you try androidTestImplementation "androidx.test:core:1.5.0-alpha02". We'll be pushing out a 1.5.0-beta01 shortly hopefully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions