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

Android 12 and Java 11 #2899

Closed
d4vidi opened this issue Jul 14, 2021 · 10 comments · Fixed by #3035
Closed

Android 12 and Java 11 #2899

d4vidi opened this issue Jul 14, 2021 · 10 comments · Fixed by #3035

Comments

@d4vidi
Copy link
Collaborator

d4vidi commented Jul 14, 2021

Description

Need to validate compliance with the upcoming release of Android 12

@mikehardy
Copy link
Contributor

Testing on Android 12 today and while I needed to manually set up the adb reverse to hit the bundler (unexpected, maybe not Detox' problem - adb reverse tcp:8081 tcp:8081) everything in the react-native-firebase e2e tests appeared to pass with Detox current-as-of-now - v18.20.4

Note that we are not doing anything fancy with regard to artifacts and dialogs and permissions and such, but it does at least run, vs ios15 which is currently a crash-on-startup per #2895

@d4vidi
Copy link
Collaborator Author

d4vidi commented Sep 29, 2021

Thanks @mikehardy, that's great input.

@d4vidi d4vidi changed the title Android 12 Android 12 and Java 11 Sep 30, 2021
@jonathanmos jonathanmos self-assigned this Oct 18, 2021
@d4vidi d4vidi added this to the Q3/2021 milestone Oct 18, 2021
@FadiAboMsalam
Copy link

Just wanted to highlight am also facing the same issue mention #3031

/android/app/build/intermediates/tmp/manifest/androidTest/debug/manifestMerger13270025334206678700.xml Error: Apps targeting Android 12 and higher are required to specify an explicit value for android:exportedwhen the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
even though I have set the android:exported in AndroidManifest.xml AND was able to run and build android successfully but detox testing fails with the above error

@mikehardy
Copy link
Contributor

mikehardy commented Nov 5, 2021

If you just need to bump your app to targetSdkVersion 31, this diff will work as a patch file named patches/detox+18.23.1.patch in your apps for patch-package, proposed in #3055 and in use now in react-native-firebase's e2e test harness

diff --git a/node_modules/detox/android/detox/build.gradle b/node_modules/detox/android/detox/build.gradle
index 8bef864..3689459 100644
--- a/node_modules/detox/android/detox/build.gradle
+++ b/node_modules/detox/android/detox/build.gradle
@@ -86,12 +86,12 @@ dependencies {
     // Versions are in-sync with the 'androidx-test-1.2.0' release/tag of the android-test github repo,
     // used by the Detox generator. See https://github.com/android/android-test/releases/tag/androidx-test-1.2.0
     // Important: Should remain so when generator tag is replaced!
-    api('androidx.test.espresso:espresso-core:3.3.0') { // Needed all across Detox but also makes Espresso seamlessly provided to Detox users with hybrid apps/E2E-tests.
+    api('androidx.test.espresso:espresso-core:3.4.0') { // Needed all across Detox but also makes Espresso seamlessly provided to Detox users with hybrid apps/E2E-tests.
         exclude group: 'com.google.code.findbugs', module: 'jsr305'
     }
-    api 'androidx.test.espresso:espresso-web:3.3.0' // Web-View testing
-    api 'androidx.test:rules:1.2.0' // Needed because of ActivityTestRule. Needed by users *and* internally used by Detox.
-    api 'androidx.test.ext:junit:1.1.1' // Needed so as to seamlessly provide AndroidJUnit4 to Detox users. Depends on junit core.
+    api 'androidx.test.espresso:espresso-web:3.4.0' // Web-View testing
+    api 'androidx.test:rules:1.4.0' // Needed because of ActivityTestRule. Needed by users *and* internally used by Detox.
+    api 'androidx.test.ext:junit:1.1.3' // Needed so as to seamlessly provide AndroidJUnit4 to Detox users. Depends on junit core.
 
     // Version is the latest; Cannot sync with the Github repo (e.g. android/android-test) because the androidx
     // packaging version of associated classes is simply not there...

merged / successfully in use: invertase/react-native-firebase#5835

@sergiulucaci
Copy link

@mikehardy thanks for you amazing effort here.

Facing the same issue as @FadiAboMsalam: #3031 even though I'm using [email protected].

All the activities, services, provider & receivers have the attribute android:exported.

Message that I get:

Task :app:processDebugAndroidTestManifest FAILED
/Users/macbookpro/Documents/Development/x-mobile/android/app/build/intermediates/tmp/manifest/androidTest/debug/tempFile1ProcessTestManifest4983612996072389481.xml Error:
android:exported needs to be explicitly specified for . 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/macbookpro/Documents/Development/x-mobile/android/app/build/intermediates/tmp/manifest/androidTest/debug/tempFile1ProcessTestManifest4983612996072389481.xml Error:
android:exported needs to be explicitly specified for . 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/macbookpro/Documents/Development/x-mobile/android/app/build/intermediates/tmp/manifest/androidTest/debug/tempFile1ProcessTestManifest4983612996072389481.xml Error:
android:exported needs to be explicitly specified for . 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.

Or, do you have any clue how can I see the temp file the error is complaining about? Or how to see the problematic activity that detox is complaining about? --loglevel trace doesn't help.

Thanks!

@mikehardy
Copy link
Contributor

If you open your android project in AndroidStudio and load the AndroidManifest.xml file, you should have a tab near the bottom that says "Merged Manifest", it is the result of AndroidStudio reading your manifest and all libraries etc manifests and combining them all in to what the system will see at the end.

In that window, you should be able to scan through and investigate to find whichever one is not setting exported correctly

@d4vidi
Copy link
Collaborator Author

d4vidi commented Sep 20, 2022

Currently, the only known Detox issue is this: #3560

@CallumHemsley
Copy link

If you open your android project in AndroidStudio and load the AndroidManifest.xml file, you should have a tab near the bottom that says "Merged Manifest", it is the result of AndroidStudio reading your manifest and all libraries etc manifests and combining them all in to what the system will see at the end.

In that window, you should be able to scan through and investigate to find whichever one is not setting exported correctly

I have ensured that they are all being exported correctly now, but still have the same issue as @sergiulucaci :(

@mikehardy
Copy link
Contributor

@CallumHemsley - this is a statement merely intended to point out inability to help - I will provide the same amount of information you have provided, for reproduction purposes:

I have ensured that mine are all being exported correctly now, and I have no issues

Who's correct and why?

Unknowable --> https://stackoverflow.com/help/how-to-ask + https://stackoverflow.com/help/minimal-reproducible-example

@sergiulucaci
Copy link

@CallumHemsley what I recommend is to make sure you have it set up correctly.

What I was missing was this:

In your root buildscript (i.e. android/build.gradle), register both google() and detox as repository lookup points in all projects:

// Note: add the 'allproject' section if it doesn’t exist
allprojects {
    repositories {
        // ...
        google()
        maven {
            // All of Detox' artifacts are provided via the npm module
            url "$rootDir/../node_modules/detox/Detox-android"
        }
    }
}

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

Successfully merging a pull request may close this issue.

6 participants