简体   繁体   English

Gradle构建有一些错误

[英]Gradle build have some errors

Gradle errors: 摇篮错误:

Error:(63, 13) Failed to resolve: com.google.android.gms:play-services-gcm:11.0.2 错误:(63,13)无法解决:com.google.android.gms:play-services-gcm:11.0.2

Error:(66, 13) Failed to resolve: com.google.android.gms:play-services-maps:11.0.2 错误:(66,13)无法解决:com.google.android.gms:play-services-maps:11.0.2

Error:(65, 13) Failed to resolve: com.google.android.gms:play-services-analytics:11.0.2 错误:(65,13)无法解决:com.google.android.gms:play-services-analytics:11.0.2

Error:(62, 13) Failed to resolve: com.google.android.gms:play-services-places:11.0.2 错误:(62、13)无法解决:com.google.android.gms:play-services-places:11.0.2

Error:(64, 13) Failed to resolve: com.google.android.gms:play-services-location:11.0.2 错误:(64,13)无法解决:com.google.android.gms:play-services-location:11.0.2

Error:(55, 13) Failed to resolve: com.android.support.constraint:constraint-layout:1.0.2 错误:(55,13)无法解决:com.android.support.constraint:constraint-layout:1.0.2

apply plugin: 'com.android.application'

android {
    signingConfigs {
        config {
            keyPassword keyPassword
            storeFile filestoreFile
            storePassword storePassword
            keyAlias keyAlias
        }
    }
    compileSdkVersion 25
    buildToolsVersion '25.0.2'
    defaultConfig {
        applicationId applicationId
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"

        manifestPlaceholders = [onesignal_app_id: manifestPlaceholders , onesignal_google_project_number: "REMOTE"]
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
        }
    }
    packagingOptions {
        exclude 'libs/jackson-core-asl-1.9.13.jar'
        exclude 'libs/jackson-mapper-asl-1.9.13.jar'
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }
    useLibrary 'org.apache.http.legacy'
}

allprojects {
    repositories {
        maven { url "https://jitpack.io" }
        mavenCentral()
    }
}
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.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support:support-annotations:25.3.1'
    compile 'com.android.support:support-compat:25.3.1'
    compile 'com.android.support:recyclerview-v7:25.3.1'
    compile 'com.android.support:cardview-v7:25.3.1'
    compile 'com.google.android.gms:play-services-places:11.0.2'
    compile 'com.google.android.gms:play-services-gcm:11.0.2'
    compile 'com.google.android.gms:play-services-location:11.0.2'
    compile 'com.google.android.gms:play-services-analytics:11.0.2'
    compile 'com.google.android.gms:play-services-maps:11.0.2'
    compile 'com.fasterxml.jackson.core:jackson-core:2.8.8'
    compile 'com.fasterxml.jackson.core:jackson-annotations:2.8.8'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.8.8'
    compile 'com.loopj.android:android-async-http:1.4.8'
    compile 'com.squareup.okhttp3:okhttp:3.8.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.daimajia.swipelayout:library:1.2.0@aar'
    compile 'com.github.hamsaadev:Persian-Date-Picker-Dialog:V1.0'
    compile 'com.onesignal:OneSignal:3.5.8@aar'
    compile 'com.android.support:support-v4:25.3.1'
    testCompile 'junit:junit:4.12'
}

I try : 我尝试:

  1. gradle setting offline work is unchecked gradle设置离线工作未选中
  2. http proxy http代理
  3. remove http proxy 删除http代理

proxy but problem has remind. 代理,但问题已提醒。

android studio version : 2.3.3 android studio版本:2.3.3

gradle.build(Module:app) : gradle.build(模块:应用程序):

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.3.3'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    classpath 'com.google.gms:google-services:3.1.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

Add below code to bottom of app level build.gradle 将以下代码添加到app级别build.gradle底部

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

Then Sync your project. 然后同步您的项目。 Maybe it will fix your problem 也许它将解决您的问题

EDIT: Considering Moonbloom's suggestion, 编辑:考虑到Moonbloom的建议,

Update app level build.gradle with: 使用以下命令更新应用程序级别build.gradle

repositories {
    maven { url "https://jitpack.io" }
    mavenCentral()
}

instead of 代替

allprojects {
    repositories {
        maven { url "https://jitpack.io" }
        mavenCentral()
    }
}

Hope it helps! 希望能帮助到你!

Any place where it says either mavenCentral() or jcenter() , you should add the following: 它说mavenCentral()jcenter()任何地方,您都应该添加以下内容:

maven { url "https://maven.google.com" }

You should also add both mavenCentral() and jcenter() if they're missing from any of the blocks. 如果任何块中都缺少mavenCentral()jcenter()则还应该添加它们。

These lines basically tell Gradle where to look for libraries that you're trying to include. 这些行基本上告诉Gradle在哪里寻找要包含的库。 The maven.google.com one is new, and is the only place the absolutely newest Google Play libraries are hosted. maven.google.com是一个新的文件,并且是唯一托管绝对最新的Google Play库的地方。

将SDK更新到26.0.2解决了我的问题。

add below code in the botton of app level build.gradle 在应用程序级别build.gradle的botton中添加以下代码

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

change all the versions from 11.0.2 to 11.0.1 将所有版本从11.0.2更改为11.0.1

compile 'com.google.android.gms:play-services-maps:11.0.1'
compile 'com.google.android.gms:play-services-location:11.0.1'
compile 'com.google.android.gms:play-services-places:11.0.1'
compile 'com.google.firebase:firebase-messaging:11.0.1'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM