Could not find method flavorDimensions() for arguments [tier] on object of type org.gradle.api.internal.initialization.DefaultScriptHandler.
Your Environment
- Plugin version: latest
- Platform: Android
- OS version: build tools 3.1.0
- Device manufacturer and model:
- React Native version: 43
- Plugin configuration options:
- Link to your project:
Context
Cant install onto my project with simple react-native link 'name'
Expected Behavior
project should be linked.
Actual Behavior
Got a flavor issue with the build gradle. Added a flavorDimension as specified and it does not work.
Possible Fix
Steps to Reproduce
1. 2. 3. 4.
Context
Debug logs
Can you please try create it on new project:
- react-native init tmpProject
- yarn add react-native-mauron85-background-geolocation
- react-native link react-native-mauron85-background-geolocation
I think this issue comes if you try to compile with com.android.tools.build:gradle 3+. I am also facing this as my project uses both react-native-maps and your plugin. Latest version of react-native-maps wants gradle 3+ but not able to compile. Following is the log of run-android:
> Configure project :react-native-mauron85-background-geolocation
Configuration 'releaseCompile' in project ':react-native-mauron85-background-geolocation' is deprecated. Use 'releaseImplementation' instead.
Configuration 'debugCompile' in project ':react-native-mauron85-background-geolocation' is deprecated. Use 'debugImplementation' instead.
Configuration 'compile' in project ':react-native-mauron85-background-geolocation' is deprecated. Use 'implementation' instead.
WARNING: The specified Android SDK Build Tools version (23.0.1) is ignored, as it is below the minimum supported version (26.0.2) for Android Gradle Plugin 3.0.1.
Android SDK Build Tools 26.0.2 will be used.
To suppress this warning, remove "buildToolsVersion '23.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
> Configure project :react-native-mauron85-background-geolocation-common
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
Configuration 'androidTestCompile' in project ':react-native-mauron85-background-geolocation-common' is deprecated. Use 'androidTestImplementation' instead.
Configuration 'compile' in project ':react-native-mauron85-background-geolocation-common' is deprecated. Use 'implementation' instead.
Configuration 'testCompile' in project ':react-native-mauron85-background-geolocation-common' is deprecated. Use 'testImplementation' instead.
Configuration 'oreoCompile' in project ':react-native-mauron85-background-geolocation-common' is deprecated. Use 'oreoImplementation' instead.
WARNING: The specified Android SDK Build Tools version (26.0.1) is ignored, as it is below the minimum supported version (26.0.2) for Android Gradle Plugin 3.0.1.
Android SDK Build Tools 26.0.2 will be used.
To suppress this warning, remove "buildToolsVersion '26.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':react-native-mauron85-background-geolocation-common'.
> All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com/r/tools/flavorDimensions-missing-error-message.html
* 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 49s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
Thanks
@shashanksinghal this was helpful. I will try to reproduce with gradle 3+. Till it's fixed you can use older react-native-maps. I'm using version 0.20.1 in example https://github.com/mauron85/react-native-background-geolocation-example/blob/master/package.json.
Just realized you can already fix this by adding following into root build.gradle
ext {
buildToolsVersion = "25.0.2"
}
Edit: This will fix probably the warning only and not flavor error.
What are your version of com.android.tools.build:gradle gradle and buildTools?
I have tried com.android.tools.build:gradle:2.3.0, gradle-3.5 and buildToolsVersion "25.0.2" and those are working.
In build.gradle:
com.android.tools.build:gradle:3.1.0
In gradle-wrapper.properties:
distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip
buildToolsVersion 25.0.2 will be ignored anyways as minimum required for gradle plugin 3.1.0 is 27 and gradle plugin 3.0.1 is 26. I tried both but same error
Please also refer Declare flavor dimensions section in Gradle 3 migration
@shashanksinghal ok I can reproduce it now with those versions.
After reading Gradle 3 migration and some testing I have bad feeling that making this work on gradle3 will require more work that I expected. Gradle 3 dropped option to specify build flavor via configuration for local modules
// This is the old method and no longer works for local // library modules: // debugImplementation project(path: ':library', configuration: 'debug') // releaseImplementation project(path: ':library', configuration: 'release')
which this plugin is using to create oreo and normal flavors. But will try to finding replacement that would be be still easy to use.
Any status on this?
Try this one https://github.com/kruyvanna/react-native-background-geolocation
@kruyvanna Thanks for you work, maybe you can submit it as a pull request here?
@ivosabev I regard it as a temporary workaround since I drop support for pre-oreo build. If that's ok with @mauron85 , I can prepare a PR. @mauron85 what do you think?
Just published 0.5.0-alpha.31 with experimental gradle3 support.
- To enable it you would need to add following into your root build.gradle:
ext {
compileSdkVersion = 26
targetSdkVersion = 26
buildToolsVersion = "27.0.3"
supportLibVersion = "27.1.0"
googlePlayServicesVersion = "11.8.0"
gradle3EXPERIMENTAL = "yes"
}
- Add google maven repository
maven { url 'https://maven.google.com' }into allprojects -> repositories - Edit
android/app/build.gradle
android {
...
compileSdkVersion 26
buildToolsVersion "27.0.3"
...
}
Example project using gradle3 https://github.com/mauron85/react-native-mauron85-background-geolocation-skeleton
@kruyvanna sorry I somehow missed your comment. Thank you for your effort, but I would like to keep support for preoreo builds and react-native project template defaults.
@mauron85 No problem. thanks for the great work :)
@mauron85 I'm not seeing the release 0.5.0-alpha.31, am I missing something?
@equesteo i used 0.5.0-alpha.34
@mauron85 @dengue8830 I use react native firebase and React-native-Maps with gralde 4.4, these two libraries are important in my project, and now I want to use them with native native background locations mauron85, but here it does not support 4 .x. This is the problem I encountered! Your link fix gradle will only 3.x. Is there a better way? thank you 😃
Your link fix gradle will only 3.x. Is there a better way? thank you
no it should work with gradle4. Actually gradle3 is just tag name for the issue and gradle3 in my experience is not working with Android.