【问题标题】:error when adding compile 'com.google.android.gms:play-services:11.0.1'添加编译时出错 'com.google.android.gms:play-services:11.0.1'
【发布时间】:2017-09-25 13:00:21
【问题描述】:

我放的时候出错了

compile 'com.google.android.gms:play-services:11.0.1'

 apply plugin: 'com.android.application'

    android {
        compileSdkVersion 25
        buildToolsVersion "26.0.1"
        defaultConfig {
            applicationId "eyaa.compsproject"
            minSdkVersion 16
            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(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'
        compile 'com.android.support:cardview-v7:25.3.1'
        compile 'com.android.support.constraint:constraint-layout:1.0.2'
        compile 'com.google.android.gms:play-services:11.0.1'
        compile 'com.google.firebase:firebase-core:10.0.1'
        compile 'com.google.firebase:firebase-database:10.0.1'
        testCompile 'junit:junit:4.12'
    }

    apply plugin: 'com.google.gms.google-services'

为什么要排成红色

compile 'com.android.support:appcompat-v7:25.3.1' 

使用时

 compile 'com.google.android.gms:play-services:11.0.1'

【问题讨论】:

  • 您的 Firebase 版本需要与 Google play 匹配
  • 另外,如果你只需要 GCM,那么只添加那个。您不太可能需要所有 Google Play 服务

标签: android gradle android-gradle-plugin build.gradle android-gradle-3.0


【解决方案1】:

播放服务和firebase版本需要相同, 请替换为以下代码并检查。

compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'

【讨论】:

  • 编译 'com.android.support:appcompat-v7:25.3.1' 编译 'com.android.support:design:25.3.1' 编译 'com.android.support:cardview-v7: 25.3.1' 编译 'com.android.support.constraint:constraint-layout:1.0.2' 编译 'com.google.android.gms:play-services:10.0.1' 编译 'com.google.firebase:firebase- core:10.0.1' compile 'com.google.firebase:firebase-database:10.0.1' 我也有红线 compile 'com.android.support:appcompat-v7:25.3.1'
  • 我也有红线 compile 'com.android.support:appcompat-v7:25.3.1' 我必须使用 compile 'com.google.android.gms:play-services:10.0 .1'
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-11-28
  • 2019-03-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多