React Native Maps

Asked

Viewed 502 times

0

I am trying to implement the React-Native-maps library in my project, when running React-Native run-android I get this error in CMD:

* Where:
Build file 'C:\Users\Henrique\Documents\New folder\NoExpo\AwesomeProject\node_modules\react-native-maps\lib\android\build.gradle' line: 46

* What went wrong:
A problem occurred evaluating project ':react-native-maps'.
> Could not find method compileOnly() for arguments [com.facebook.react:react-native:+] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 7.449 secs
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

I set up the build.Radle file like this:

dependencies {
    compile project(':react-native-maps')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
}
  • What version of Gradle ?

  • classpath 'com.android.tools.build:Gradle:2.2.3'

  • Change to classpath 'com.android.tools.build:gradle:3.0.1' and see if it works.

1 answer

1

If you don’t have defined properties for the entire project defined and have a different version of playback services than the one included in that library, use the following (toggle 10.0.1 for the desired version):

... dependencies { ... implementation(project(':react-native-maps')){ exclude group: 'com.google.android.gms', module: 'play-services-base' exclude group: 'com.google.android.gms', module: 'play-services-maps' } implementation 'com.google.android.gms:play-services-base:10.0.1' implementation 'com.google.android.gms:play-services-maps:10.0.1' }

On your android/Settings.Radle:

include ':react-native-maps' project(':react-native-maps').projectDir = new File(rootProject.projectDir,'../node_modules/react-native-maps/lib/android')

Browser other questions tagged

You are not signed in. Login or sign up in order to post.