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

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

Closed
j-mendez opened this issue Apr 11, 2018 · 40 comments
Labels

Comments

@j-mendez
Copy link

j-mendez commented Apr 11, 2018

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

Context

Debug logs

@mauron85
Copy link
Owner

mauron85 commented Apr 11, 2018

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

@shashanksinghal
Copy link

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

@mauron85
Copy link
Owner

@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
Copy link
Owner

mauron85 commented Apr 11, 2018

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
Copy link
Owner

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.

@shashanksinghal
Copy link

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

@mauron85
Copy link
Owner

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

@mauron85
Copy link
Owner

mauron85 commented Apr 11, 2018

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.

@ivosabev
Copy link

ivosabev commented May 9, 2018

Any status on this?

@kruyvanna
Copy link

@ivosabev
Copy link

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

@kruyvanna
Copy link

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

@mauron85
Copy link
Owner

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
Copy link
Owner

mauron85 commented May 25, 2018

@mauron85
Copy link
Owner

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

@kruyvanna
Copy link

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

@equesteo
Copy link

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

@dengue8830
Copy link

@equesteo i used 0.5.0-alpha.34

@duypxd
Copy link

duypxd commented Jun 15, 2018

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

@mauron85
Copy link
Owner

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.

@duypxd
Copy link

duypxd commented Jun 15, 2018

@mauron85 Unfortunately :(

@mauron85
Copy link
Owner

mauron85 commented Jun 15, 2018

@xuanduy96 try using skeleton project https://github.com/mauron85/react-native-mauron85-background-geolocation-skeleton It's using gradle 4.

EDIT: Gradle 4.4 to be exact

https://github.com/mauron85/react-native-mauron85-background-geolocation-skeleton/blob/master/android/gradle/wrapper/gradle-wrapper.properties

@dengue8830
Copy link

@xuanduy96 im using the same stack,
react-native-maps
react-native-firebase
with gralde 4.4 and works fine

@duypxd
Copy link

duypxd commented Jun 17, 2018

@mauron85 thanks, it worked with gradle 4.4.
But when I add your example code to my app, my app is quitting.

  • RN-Firebase
  • RN-Maps
  • react-native-background-geolocation
    image

@duypxd
Copy link

duypxd commented Jun 17, 2018

@dengue8830 Can you show me the config in the project that you have successfully implemented with:
RN-Maps
RN-Firebase
RN-background-geolocation
???
And you are sure that when adding the example code of these three libraries at the same time it still works normally: D Tks

@nguyensythinhk7
Copy link

@mauron85 , @dengue8830 . I install and work ok in gradle 4.4. But when install react-native-firebase v4.2.0 then app crash. I tried doing it again many times but it still does not work. When i run react-native-firebase, no use Background thì it still work.

@nguyensythinhk7
Copy link

this dependencies app/build.gralde config
denpence
comment all config firebase then Background Work. @dengue8830 can you shgw config dependencies. please, help me.

@dengue8830
Copy link

dengue8830 commented Jun 19, 2018

@xuanduy96 @nguyensythinhk7

Sorry for the delay, here is my config:
UPDATE: the post became too long so i put it in this gist. Give it a star if it's useful for you

i'm not fully tested the background location yet, but it sends location to the server on foreground and background mode, i checked that

@nguyensythinhk7
Copy link

@dengue8830 thank you ! Although I have tried config according to you but still not. I configed vs gradle and firebase v3, it's work. I thing i should use this version. thank you for enthusiastic support.

@tecionsdev
Copy link

my build.gradle working file

`// Top-level build file where you can add configuration options common to all sub-projects/modules.
ext {
compileSdkVersion = 26
targetSdkVersion = 26
buildToolsVersion = "27.0.3"
supportLibVersion = "27.1.0"
googlePlayServicesVersion = "11.8.0"
gradle3EXPERIMENTAL = "yes"
}
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}

             maven { url 'https://plugins.gradle.org/m2/' }
              maven { url "https://jitpack.io" }
}
dependencies {
   // classpath 'com.android.tools.build:gradle:2.2.3'

    classpath 'com.android.tools.build:gradle:3.0.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

allprojects {
repositories {
mavenLocal()

       mavenLocal()
                           maven { url 'https://maven.google.com' }

                   maven { url "https://jitpack.io" }
                   maven {
                       url 'https://maven.google.com/'
                       name 'Google'
                   }

                    maven { url 'https://plugins.gradle.org/m2/' }



    jcenter()

    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url "$rootDir/../node_modules/react-native/android"
    }
}

}

subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "26.0.1"
}
}
}

afterEvaluate {
    project -> if (project.hasProperty("android")) {
        android {
            compileSdkVersion 26
            buildToolsVersion '26.0.1'
        }
    }
}

}
`

@mowbell
Copy link

mowbell commented Jul 4, 2018

@rayjadore
Copy link

gradle3EXPERIMENTAL = true
this should solve it

@mauron85
Copy link
Owner

mauron85 commented Jul 16, 2018

Just small warning. You cannot have both GRADLE3 and OREO support enabled (because react-native build script doesn't support specifying build flavor in command line and gradle3 dropped support for flavors in compile declaration).

Sorry for confusion. I was wrong (even though I wrote the gradle scripts myself). Actually OREO support is automatically enabled with GRADLE3.

@rayjadore
Copy link

rayjadore commented Aug 26, 2018 via email

@ancyrweb
Copy link

ancyrweb commented Oct 5, 2018

I've got this happening with Gradle 4.4 :/

@dengue8830
Copy link

dengue8830 commented Oct 5, 2018

@rewieer check this

@ancyrweb
Copy link

ancyrweb commented Oct 5, 2018

@dengue8830 thanks mate, adding gradle3EXPERIMENTAL fixed it for me through

@vishal-km
Copy link

Fixed by downgrading Gradle from 4.4 and linked again.
Don't know which of this fixed my issue (possibly linking issue).

@dengue8830
Copy link

dengue8830 commented Jan 16, 2019

i have a general purpose skeleton project, you could check the config, run it or use it directly (using react-native-rename project)

@godfrednanaowusu
Copy link

godfrednanaowusu commented May 30, 2021

in May 2021, this is impossible to install from expo project to raw react-native, I have tried too many manual configurations from all over the place and nothing seems to work. A new error keeps popping up. Is there anyone using this in 2021 and if so, whats a solution please.

_FAILURE: Build failed with an exception.

  • What went wrong:
    Could not determine the dependencies of task ':app:mergeDebugAssets'.

Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
Could not resolve project :react-native-mauron85-background-geolocation.
Required by:
project :app
> No matching configuration of project :react-native-mauron85-background-geolocation was found. The consumer was configured to find a runtime of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug' but:
- None of the consumable configurations have attributes._

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

No branches or pull requests