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

Fix assembleAndroidTest builds #466

Merged
merged 1 commit into from Nov 13, 2021

Conversation

mrbrentkelly
Copy link
Contributor

Overview

Fixes an issue when building and running instrumented tests (e.g. Detox) for a React Native project on Android, the following build error was occurring:

Execution failed for task ':react-native-community_netinfo:mergeExtDexDebugAndroidTest'.
> Could not resolve all files for configuration ':react-native-community_netinfo:debugAndroidTestRuntimeClasspath'.
   > Failed to transform core-1.6.0-alpha03.aar (androidx.core:core:1.6.0-alpha03) to match attributes {artifactType=android-dex, dexing-enable-desugaring=false, dexing-is-debuggable=true, dexing-min-sdk=23, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}.

If an Android library uses Java 8 language features then it must declare compileOptions in its build.gradle.

...each module that uses Java 8 language features (either in its source code or through dependencies), update the module's build.gradle file, as shown below:

https://developer.android.com/studio/write/java8-support#supported_features

Fix is simple to add Java 8 compileOptions to the build.gradle. I've seen and fixed similar issues in other projects as well:

negativetwelve/react-native-ux-cam#104
snowplow/snowplow-react-native-tracker#117

Test Plan

Made the change locally in my projects node_modules, then rebuilt the app, and it was successful 🎉 .

Copy link
Contributor

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

irony: android gradle plugin 4.2.0 defaults to java 8 so this is unnecessary for builds using current stable build tool chains as of...this week. But everyone won't upgrade immediately of course.

I don't see any reason why this wouldn't work - it's a best practice anyway. Interesting it hasn't popped up before actually?

@mrbrentkelly
Copy link
Contributor Author

Yeah I only tend to see it in projects that have instrumented Android tests, so perhaps not enough projects are writing tests 😆

@mrbrentkelly
Copy link
Contributor Author

Just following up on this. Anything else you need me to change or answer before this PR is merged?

@mikehardy
Copy link
Contributor

Nope I think we're just waiting on @matt-oakes to whack the merge button, until then patch-package 🤷

Copy link
Contributor

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still needed for some old projects, no reason not to merge, and I can merge now

@mikehardy mikehardy merged commit 48d4364 into react-native-netinfo:master Nov 13, 2021
github-actions bot pushed a commit that referenced this pull request Nov 13, 2021
## [6.1.1](v6.1.0...v6.1.1) (2021-11-13)

### Bug Fixes

* **android:** declare java 1.8 feature usage so assembleInstrumentedTest builds work ([#466](#466)) ([48d4364](48d4364))
@matt-oakes
Copy link
Collaborator

🎉 This PR is included in version 6.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

None yet

3 participants