unable to build android with react native 0.71.1, got error `android:exported needs to be explicitly specified for element `
What happened?
setup android test on a react native (version 0.71.1) app following the instructions. when building the android app regularly, it does not throw this error. ios test works fine as well. keep getting 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.
What was the expected behaviour?
should not throw above error
Was it tested on latest Detox?
- [X] I have tested this issue on the latest Detox release and it still reproduces.
Did your test throw out a timeout?
- [X] I have followed the instructions under Identifying which synchronization mechanism causes us to wait too much.
Help us reproduce this issue!
No response
In what environment did this happen?
Detox version: 20.1.2 React Native version: 0.71.1 Has Fabric (React Native's new rendering system) enabled: (yes/no) Node version: 18.11.0 Device model: Android version: Test-runner (select one): jest
Detox logs
Detox logs
npx detox build --configuration android.emu.debug --loglevel trace
cd android ; ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug ; cd -
> Task :app:processDebugAndroidTestManifest FAILED
/Users/emilyxiong/Code/tmp/reactNative711/android/app/build/intermediates/tmp/manifest/androidTest/debug/tempFile1ProcessTestManifest17853538679311875052.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.
/Users/emilyxiong/Code/tmp/reactNative711/android/app/build/intermediates/tmp/manifest/androidTest/debug/tempFile1ProcessTestManifest17853538679311875052.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.
/Users/emilyxiong/Code/tmp/reactNative711/android/app/build/intermediates/tmp/manifest/androidTest/debug/tempFile1ProcessTestManifest17853538679311875052.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.
See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:processDebugAndroidTestManifest'.
> Manifest merger failed with multiple errors, see logs
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
java.lang.StackOverflowError (no error message)
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================
* Get more help at https://help.gradle.org
BUILD FAILED in 9s
37 actionable tasks: 6 executed, 31 up-to-date
Device logs
Device logs
npx detox build --configuration android.emu.debug --record-logs all
cd android ; ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug ; cd -
Starting a Gradle Daemon, 1 stopped Daemon could not be reused, use --status for details
> Task :app:processDebugAndroidTestManifest FAILED
/Users/emilyxiong/Code/tmp/reactNative711/android/app/build/intermediates/tmp/manifest/androidTest/debug/tempFile1ProcessTestManifest12150465681108452725.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.
/Users/emilyxiong/Code/tmp/reactNative711/android/app/build/intermediates/tmp/manifest/androidTest/debug/tempFile1ProcessTestManifest12150465681108452725.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.
/Users/emilyxiong/Code/tmp/reactNative711/android/app/build/intermediates/tmp/manifest/androidTest/debug/tempFile1ProcessTestManifest12150465681108452725.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.
See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:processDebugAndroidTestManifest'.
> Manifest merger failed with multiple errors, see logs
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
java.lang.StackOverflowError (no error message)
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================
* Get more help at https://help.gradle.org
BUILD FAILED in 20s
38 actionable tasks: 3 executed, 35 up-to-date
More data, please!
No response
Our only Android developer is on his vacation, so we can't help earlier than the next week, sorry.
I'm keeping this open but we largely expect this to be resolved via #3884.
I seem to be running into the same issue. I followed the guide from https://wix.github.io/Detox/docs/introduction/project-setup/#step-4-additional-android-configuration
What happened?
tried to build the android app with
detox build --configuration android.emu.debug
but got the following errors:
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.
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.
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.
Was it tested on latest Detox?
Yes, I have tested this issue on the latest Detox release and it still reproduces.
In what environment did this happen?
Detox version: 20.1.5 React Native version: 0.70.7 (tried 0.70.0 as well) Has Fabric (React Native's new rendering system) enabled: (yes/no) Node version: v19.3.0 Device model: Android version: Test-runner (select one): jest
The error is very likely not related to Detox. Try this reference. Also, mind the current issues with Android 12 and 13 (SDK 32, 33): #3762
I have the same problem. The main project that I am working on, is a react native library. There is a demo app inside this library and I added detox to that demo app. This error (android:exported needs to...) shows a location from the library, which has no activity (or services, etc...) that needs android:exported. If I remove the library dependency, Then the demo app itself has no problem with detox and the build is successful.
This is caused by android.test:core < v1.4.0.
Adding this to android/app/build.gradle fixes for me :
configurations.all {
resolutionStrategy {
force 'androidx.test:core:1.5.0'
}
}
Another way of solving that is to find out the package activity name causing that and overwriting it in your own AndroidManifest.xml i.e.
<activity
android:name="com.surveymonkey.surveymonkeyandroidsdk.SMFeedbackActivity"
android:exported="false"
tools:replace="exported"
/>
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.
Thank you for your contributions!
For more information on bots in this repository, read this discussion.
This is caused by
android.test:core< v1.4.0.Adding this to
android/app/build.gradlefixes for me :configurations.all { resolutionStrategy { force 'androidx.test:core:1.5.0' } }
@arcln That's a great find 💪🏻 Please try to see whether this can be removed with Detox 20.9.0
@arcln ping
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.
Thank you for your contributions!
For more information on bots in this repository, read this discussion.
This is still an issue 20.11.1
edit: I cannot see it stated I the original description, however we had Fabric and the new RN Arch enabled. We disabled it and for us this issue then stopped.
A workaround for me was to add this to app/build.gradle
androidTestImplementation "androidx.test.ext:junit:1.1.3"
androidTestImplementation "androidx.fragment:fragment-testing:1.4.1"
androidTestImplementation "androidx.test:core:1.4.0"
A workaround for me was to add this to app/build.gradle
androidTestImplementation "androidx.test.ext:junit:1.1.3" androidTestImplementation "androidx.fragment:fragment-testing:1.4.1" androidTestImplementation "androidx.test:core:1.4.0"
@krini have you tried the latest Detox version? As I mentioned, this should have been fixed in Detox 20.9.x (i.e. by bumping Detox to take androidx.test:core:1.5.0).
A workaround for me was to add this to app/build.gradle
androidTestImplementation "androidx.test.ext:junit:1.1.3" androidTestImplementation "androidx.fragment:fragment-testing:1.4.1" androidTestImplementation "androidx.test:core:1.4.0"@krini have you tried the latest Detox version? As I mentioned, this should have been fixed in Detox
20.9.x(i.e. by bumping Detox to takeandroidx.test:core:1.5.0).
You are right. It seems to work. I did actually update detox to version 20.11.4, but maybe it was in the wrong order. I removed the packages again and it still builds.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.
Thank you for your contributions!
For more information on bots in this repository, read this discussion.
reactivating a stale detox installation, i ran into this error. i walked through the setup-guides and checked everything was in place. looks like there were some changes in the meantime:
diff --git a/android/app/build.gradle b/android/app/build.gradle
index d5b67d7a4..1ed7f5d4c 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -81,6 +81,8 @@ android {
versionCode 55
versionName "5.1.0"
missingDimensionStrategy "store", "play"
+ testBuildType System.getProperty('testBuildType', 'debug')
+ testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
signingConfigs {
debug {
@@ -112,9 +114,7 @@ proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/prog
}
dependencies {
- androidTestImplementation('com.wix:detox:+') {
- exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
- }
+ androidTestImplementation('com.wix:detox:+')
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation "com.facebook.android:facebook-android-sdk:9.1.0"
It compiles given those changes.
Closing this in favor of more recent upgrades (RN72 in Detox 20.17.0, RN73 in 20.18.1) Please report whichever issues accordingly 🙏 Sorry for the hassle, but it helps managing things more clearly