android - 为什么新的 google places api 不与 build.gradle 同步?

标签 android google-places-api

根据 google 的新 places API ( https://developers.google.com/places/android-sdk/start )。我已完成此链接中提到的所有内容并为我的项目启用了计费,但我仍然无法同步项目。 错误是

ERROR: Failed to resolve: com.google.android.libraries.places:1.0.0:
Install Repository and sync project

我已将 android sdkplay servicesgoogle repository 更新到最新版本。 我在 stackoverflow 和其他网站上搜索了很多,但没有任何问题可以解决这个问题。

我的应用级build.gradle文件是

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.prisma.placesapidemo"
        minSdkVersion 21
        targetSdkVersion 28
        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 'androidx.appcompat:appcompat:1.0.0-beta01'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0-beta01'
    implementation 'com.google.android.material:material:1.0.0-beta01'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
    implementation 'com.google.android.libraries.places:1.0.0'
}

我的项目级build.gradle文件是

// 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.3.1'
        classpath 'com.google.gms:google-services:4.0.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

最佳答案

入门指南有错误的依赖关系(尽管它在 Migration guide 上是正确的)。如上所示 maven.google.com ,实际的依赖是:

implementation 'com.google.android.libraries.places:places:1.0.0'

请注意,还有一个 :places-compat 依赖项。

关于android - 为什么新的 google places api 不与 build.gradle 同步?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55036888/

相关文章:

android - 实现一些功能,比如在 Instagram android 应用程序中

android - 如何将带有高亮颜色背景的文本添加到 ImageView

android - 使用 Apache POI 在 Android 中读取 MS Excel 2010 文件

ios - iOS 上的 Google Places API 自动完成

google-maps - 谷歌地点 API : Place Search filter by country

google-maps - 从 Google Places 检索 Google FID

android - 如何从不同的 .apk 连接到远程服务

java - Android加密数据库

javascript - Google Places API 上的 CORS 错误,但 Reddit 上没有

java - 分割googleplacepicker的纬度和经度,place.getLatLng()