我尝试使用react native app并在gradle文件中使用以下代码段
dependencies {
implementation project(':react-native-maps')
implementation project(':react-native-geolocation-service')
implementation project(':react-native-background-timer')
implementation project(':react-native-mauron85-background-geolocation')
implementation project(':react-native-contacts')
implementation project(':react-native-gesture-handler')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
}
我用谷歌搜索并找到解决问题的方法
compile(project(':react-native-maps')) {
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
compile 'com.google.android.gms:play-services-base:11.+'
compile 'com.google.android.gms:play-services-maps:11.+'
compile 'com.google.android.gms:play-services-location:+'
但我没有编译(项目....在我的gradle文件中
我在用
"react": "16.6.3",
"react-native": "0.58.6",
"react-native-geolocation-service": "^2.0.0",
"react-native-gesture-handler": "^1.1.0",
"react-native-maps": "^0.23.0",
如何解决此问题
compile
被弃用以支持implementation
。您可以轻松地将单词compile
的所有实例替换为单词implemenation
。所以你的依赖会变成这样:
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:11.+'
implementation 'com.google.android.gms:play-services-maps:11.+'
implementation 'com.google.android.gms:play-services-location:+'
// implementation project(':react-native-maps') // <- you can remove this as you are using it above
implementation project(':react-native-geolocation-service')
implementation project(':react-native-background-timer')
implementation project(':react-native-mauron85-background-geolocation')
implementation project(':react-native-contacts')
implementation project(':react-native-gesture-handler')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
}
我花了很多钱,最后偶然发现了两件事。这是你的build.gradle
项目(而不是app/build.gradle
):
allprojects {
repositories {
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.google.android.gms') {
details.useVersion '12.0.1'
}
if (requested.group == 'com.google.firebase') {
details.useVersion '12.0.1'
}
}
}
// ... whatever else you have here already
}
}
只需在app/build.gradle
中使用标准的react-native设置,不要尝试在此处排除组 - 这对我不起作用。
这使Android <9.0工作 - 很棒。然而,9.0+坠毁,而不是很酷。我随机偶然发现了这些信息:
If you are using com.google.android.gms:play-services-maps:16.0.0
or below and your app is targeting API level 28 (Android 9.0) or
above, you must include the following declaration within the
<application> element of AndroidManifest.xml.
<uses-library
android:name="org.apache.http.legacy"
android:required="false"
/>
我真的希望这个库很快升级。我希望这可以帮助别人。
你有错误的文件。进入Project / android / app / build.gradle打开构建文件并粘贴依赖项