react-native-background-geolocation icon indicating copy to clipboard operation
react-native-background-geolocation copied to clipboard

Could not find method flavorDimensions() for arguments [tier] on object of type org.gradle.api.internal.initialization.DefaultScriptHandler.

Open j-mendez opened this issue 8 years ago • 40 comments

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

j-mendez avatar Apr 11 '18 00:04 j-mendez

Can you please try create it on new project:

  1. react-native init tmpProject
  2. yarn add react-native-mauron85-background-geolocation
  3. react-native link react-native-mauron85-background-geolocation

mauron85 avatar Apr 11 '18 04:04 mauron85

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 avatar Apr 11 '18 05:04 shashanksinghal

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

mauron85 avatar Apr 11 '18 06:04 mauron85

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.

mauron85 avatar Apr 11 '18 12:04 mauron85

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.

mauron85 avatar Apr 11 '18 12:04 mauron85

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 avatar Apr 11 '18 12:04 shashanksinghal

@shashanksinghal ok I can reproduce it now with those versions.

mauron85 avatar Apr 11 '18 13:04 mauron85

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.

mauron85 avatar Apr 11 '18 14:04 mauron85

Any status on this?

ivosabev avatar May 09 '18 12:05 ivosabev

Try this one https://github.com/kruyvanna/react-native-background-geolocation

kruyvanna avatar May 18 '18 03:05 kruyvanna

@kruyvanna Thanks for you work, maybe you can submit it as a pull request here?

ivosabev avatar May 18 '18 07:05 ivosabev

@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?

kruyvanna avatar May 22 '18 02:05 kruyvanna

Just published 0.5.0-alpha.31 with experimental gradle3 support.

  1. 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"
}
  1. Add google maven repository maven { url 'https://maven.google.com' } into allprojects -> repositories
  2. Edit android/app/build.gradle
android {
...
    compileSdkVersion 26
    buildToolsVersion "27.0.3"
...
}

mauron85 avatar May 25 '18 10:05 mauron85

Example project using gradle3 https://github.com/mauron85/react-native-mauron85-background-geolocation-skeleton

mauron85 avatar May 25 '18 10:05 mauron85

@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 avatar May 25 '18 13:05 mauron85

@mauron85 No problem. thanks for the great work :)

kruyvanna avatar May 26 '18 02:05 kruyvanna

@mauron85 I'm not seeing the release 0.5.0-alpha.31, am I missing something?

equesteo avatar Jun 11 '18 15:06 equesteo

@equesteo i used 0.5.0-alpha.34

dengue8830 avatar Jun 14 '18 23:06 dengue8830

@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 😃

duypxd avatar Jun 15 '18 04:06 duypxd

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.

mauron85 avatar Jun 15 '18 08:06 mauron85