【发布时间】:2020-04-21 03:16:10
【问题描述】:
请帮帮我...
我想创建一个基于 Google 地图的项目。但是在Android Studio中构建gradle后,出现如下错误:
错误:
Failed to resolve: com.google.android.gms:play-services-maps:17.0.0
Install Repository and sync project
Show in Project Structure dialog
Affected Modules: app
当我单击“安装存储库和...”时,会出现以下消息:
找不到依赖项“com.google.android.gms:play-services-maps:17.0.0”
注意: Gradle 在线工作模式。 我去了设置和Android SDK,然后下载了谷歌播放服务..但它不适合我。 我也设置了代理。
编辑:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
根等级:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.31'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
【问题讨论】:
-
添加你的 build.gradle 代码
-
@Android_id 完成了。
标签: android google-maps