If I try to run a composable `@Preview` on a devic...
# compose
c
If I try to run a composable
@Preview
on a device, I get an error of the sort: https://stackoverflow.com/q/68554294
I’ve been able to resolve this by adding these overrides in
androidTest/AndroidManifest.xml
Copy code
<activity
            android:name="androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity"
            android:exported="false"
            tools:node="merge"
            tools:overrideLibrary="androidx.test.core"/>
        <activity
            android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity"
            android:exported="false"
            tools:node="merge"
            tools:overrideLibrary="androidx.test.core"/>
        <activity
            android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity"
            android:exported="false"
            tools:node="merge"
            tools:overrideLibrary="androidx.test.core"/>
But it surprises me that the
androidx.test.core
package is not setting
android:exported
on its own.
The reason I raise this in #compose is I only have this problem running the
@Preview
, I don’t have trouble building otherwise
Should I file an issue? Any insight here?
Btw I have set
targetSdk = 33
. If I roll back to
targetSdk = 30
it avoids this whole issue altogether, as expected.
Sorry for the backwards-ness of this thread, but here is the original error, when I build without the manifest overrides
Copy code
/__redacted__/core/build/intermediates/tmp/manifest/androidTest/debug/tempFile2ProcessTestManifest17120162708018707534.xml:27:9-33:20 Error:
	android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity>. 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.
/__redacted__/core/build/intermediates/tmp/manifest/androidTest/debug/tempFile2ProcessTestManifest17120162708018707534.xml:34:9-40:20 Error:
	android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity>. 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.
/__redacted__/core/build/intermediates/tmp/manifest/androidTest/debug/tempFile2ProcessTestManifest17120162708018707534.xml:41:9-47:20 Error:
	android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity>. 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.
i
androidx.test.core
has set those flags for over a year now - as of Test Core 1.4.0. What version are you using?
c
Sorry I forgot to mention this. Initially I was using 1.3.0, but tried 1.4.0 and the 1.5.0 alpha. Next week I'll see if I can isolate a repro
I was able to fix this by updating
androidx.test.ext:junit
from
1.1.2
->
1.1.3
Thanks for responding
123 Views