Describe the bug
Build failed when I launch react-native run-android
Expected behavior
Should build.
Versions :
Additional context
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:preDebugBuild'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
> Could not resolve project :@react-native-mapbox-gl_maps.
Required by:
project :app
> Unable to find a matching configuration of project :@react-native-mapbox-gl_maps:
- None of the consumable configurations have attributes.
Have you tried manually linking?
I just try manually linking by adding this in settings.gradle file
include ':@react-native-mapbox-gl_maps'
project(':@react-native-mapbox-gl_maps').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-mapbox-gl/maps/android/rctmgl')
and it works!
It's a workaround, there is still a bug with the autolinking
Ok. Can you confirm iOS autolinking works?
@kristfal yes, IOS autolinking works
Ok, feel free to explore why autolinking fails for Android. In the interim, we'll keep this ticket open.
I'll also have a look at updating the example app to RN61 next week and can review things then as well.
@kristfal thanks
@Misioka I don't edit MainApplication.java or build.gradle
I just modify settings.gradle
rootProject.name = 'my_app'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':@react-native-mapbox-gl_maps'
project(':@react-native-mapbox-gl_maps').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-mapbox-gl/maps/android/rctmgl')
include ':app'
@bpouzet thanks a lot. Now I see.
Line order in settings.gradle is important.
When I put apply from... above include. It starts to work.
@bpouzet I had the same problem. I discovered this repo "@react-native-mapbox-gl/maps": "jshearer/maps" It fixes autolinking.
@Alaa-Ben I can't really see any commits in that repo that should fix Android autolinking. Any idea why that one is working and not this main one?
@kristfal Unfortunately no. I would say it's something in this commit:
https://github.com/jshearer/maps/commit/cdeb03231e3c8d53ffeeda7527fd7a715ad5291b
I read that using this repo resolves the:
Could not resolve project :@react-native-mapbox-gl_maps.
I read the commits, didn't believe it, but gave it a try eventually: it works for me.
Bizarrely to get this to work for me all I had to do was add a trailing slash to the include in settings.gradle.
i.e:
```apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':@react-native-mapbox-gl_maps'
project(':@react-native-mapbox-gl_maps').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-mapbox-gl/maps/android/rctmgl/')
```
With the repo I mentionned above, I don't even need to touch the settings.gradle file
Turns out the react native configuration file (react-native.config.js) is named as "react-native-config.js" in the package ! Renaming the file fixed autolinking issues for me. But you'll have to do it everytime you update any package.
@MrScorp thanks for finding this issue. That was a silly typo/oversight from me. Opened a PR and merging this as soon as CI is good.
Most helpful comment
I just try manually linking by adding this in settings.gradle file
and it works!
It's a workaround, there is still a bug with the autolinking