Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to build android with react native 0.71.1, got error android:exported needs to be explicitly specified for element #3867

Closed
2 tasks done
xiongemi opened this issue Jan 23, 2023 · 18 comments

Comments

@xiongemi
Copy link

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?

  • I have tested this issue on the latest Detox release and it still reproduces.

Did your test throw out a timeout?

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

@noomorph
Copy link
Collaborator

Our only Android developer is on his vacation, so we can't help earlier than the next week, sorry.

@d4vidi
Copy link
Collaborator

d4vidi commented Jan 29, 2023

I'm keeping this open but we largely expect this to be resolved via #3884.

@shadydealer
Copy link

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

@d4vidi
Copy link
Collaborator

d4vidi commented Feb 22, 2023

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

@PayamRF
Copy link

PayamRF commented Feb 24, 2023

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.

@arcln
Copy link

arcln commented Mar 7, 2023

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'
    }
}

@professorkolik
Copy link

professorkolik commented Apr 3, 2023

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"
      />

@stale
Copy link

stale bot commented May 3, 2023

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.

@d4vidi
Copy link
Collaborator

d4vidi commented May 9, 2023

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'
    }
}

@arcln That's a great find 💪🏻 Please try to see whether this can be removed with Detox 20.9.0

@d4vidi
Copy link
Collaborator

d4vidi commented May 28, 2023

@arcln ping

@stale
Copy link

stale bot commented Jul 15, 2023

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.

@stale stale bot added the 🏚 stale label Jul 15, 2023
@Wahsner
Copy link

Wahsner commented Jul 20, 2023

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.

@stale stale bot removed the 🏚 stale label Jul 31, 2023
@krini
Copy link

krini commented Aug 28, 2023

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"

@d4vidi
Copy link
Collaborator

d4vidi commented Aug 28, 2023

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).

@krini
Copy link

krini commented Aug 28, 2023

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).

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.

Copy link

stale bot commented Dec 15, 2023

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.

@stale stale bot added the 🏚 stale label Dec 15, 2023
@phoet
Copy link

phoet commented Jan 17, 2024

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.

@stale stale bot removed the 🏚 stale label Jan 17, 2024
@d4vidi
Copy link
Collaborator

d4vidi commented Feb 25, 2024

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

@d4vidi d4vidi closed this as completed Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants