【问题标题】:com.android.support:appcompat-v7 vs com.google.android.gms:play-servicescom.android.support:appcompat-v7 与 com.google.android.gms:play-services
【发布时间】:2017-07-17 22:06:02
【问题描述】:

在我的项目中,我想在导航绘制活动中使用 mapview,但是 我的项目 gradle 中的 com.android.support:appcompat-v7:25.0.3 和 com.google.android.gms:play-services:10.2.1 是对立的。 哪个版本可以?

     apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.3'
    defaultConfig {
        applicationId ".....my project name......."
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.0.3'
    compile 'com.android.support:design:25.0.3'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.android.gms:play-services-plus:10.2.1'
    compile 'com.google.android.gms:play-services-maps:10.2.1'
    testCompile 'junit:junit:4.12'
    compile 'com.google.android.gms:play-services:10.2.1'
}

【问题讨论】:

    标签: android google-maps android-gradle-plugin google-play-services android-mapview


    【解决方案1】:

    尝试在app/build.gradle file底部添加apply plugin: 'com.google.gms.google-services'line。

    The Google Services Gradle Plugin 中所述,作为在您的Android 应用程序中启用Google API 或Firebase 服务的一部分,您可能需要将google-services 插件添加到您的build.gradle 文件中:

    dependencies {
        classpath 'com.google.gms:google-services:3.0.0'
        // ...
    }
    

    此外,google-services 插件有两个主要功能:

    1. 处理 google-services.json 文件并生成可在您的应用程序代码中使用的 Android 资源。
    2. 为您启用的服务所需的基本库添加依赖项。此步骤要求apply plugin: 'com.google.gms.google-services' 行位于您的app/build.gradle 文件的底部,这样就不会引入依赖冲突。您可以通过运行./gradlew :app:dependencies 查看此步骤的结果。

    查看此相关SO post 和此documentation 以获得更多见解

    【讨论】:

    • 这是我的更改,但它没有工作依赖项 { ..... compile 'com.android.support:appcompat-v7:25.0.3' compile 'com.android.support:design:25.0 .3' 编译 'com.android.support.constraint:constraint-layout:1.0.2' 编译 'com.google.android.gms:play-services-plus:10.2.1' 编译 'com.google.android.gms :play-services-maps:10.2.1' testCompile 'junit:junit:4.12' compile 'com.android.support:multidex:1.0.1' } apply plugin: 'com.google.gms.google-services'跨度>
    • 错误:(33, 0) 未找到 ID 为“com.google.gms.google-services”的插件。 打开文件它的错误。
    • 您是否在项目的build.gradle 中也添加了classpath 'com.google.gms:google-services:3.0.0'
    • 我不这样做:---> 依赖项 { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso :espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:25.3.1' compile 'com .android.support:design:25.3.1' 编译 'com.android.support.constraint:constraint-layout:1.0.2' testCompile 'junit:junit:4.12' 编译 'com.google.android.gms:play-services :10.2.1' 类路径 'com.google.gms:google-services:3.0.0' }
    • 这是错误----> Error:(32, 0) Gradle DSL method not found: 'classpath()' 可能原因:
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-03-05
    • 2019-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-28
    相关资源
    最近更新 更多