【发布时间】:2018-05-19 14:10:17
【问题描述】:
我正在使用 Android Studio 开发一个谷歌地图应用程序。当我将项目与 Gradle 文件同步时(在 Android Studio 上使用 Gradle 文件选择工具/Android/同步项目),我收到以下错误:
无法解析 com.google.android.gms:play-services-maps:11.6.2。 无法获取资源'https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-maps/11.62./play-services-maps-11.6.2.pom
这是我正在使用的软件:
- Android Studio 3.0.1
- Android 版本 7.1.1
- Google Play 服务 46
- Google 存储库 58(在支持存储库下)
我已经尝试使用谷歌地图项目模板和空活动项目,但我得到了同样的错误。
我正在使用我在早期项目中使用的 http 代理设置。我能够安装 play-services-maps 和 google 存储库。
我还在所有项目/存储库部分的 Gradle 项目文件中添加了 maven url。
我已经尝试过 Stack Overflow 的建议,但没有一个奏效。
有什么想法吗?
Gradle Project Build file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle 应用构建文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "hansen.scott.googlemaps"
minSdkVersion 25
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.android.gms:play-services-maps:11.6.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
错误在以下行: 实施 'com.google.android.gms:play-services-maps:11.6.2'
【问题讨论】:
-
你添加了这个 maven url 吗?行家{网址“maven.google.com”}
-
尝试从 1) 右键单击您的包 2) 新建 3) google 4) 谷歌地图活动添加活动,它将自动配置所有设置和依赖项。
-
请分享您的 build.grable
-
感谢您的建议。我已经尝试了前两个:
-
我将 maven url 添加到 Gradle 项目构建文件中。我仍然遇到同样的错误。
标签: android google-maps