1

我的要求是生成应用程序包,以实现我们需要安装(1)-Android 3.2 Canary 15。(2)-Android gradle 插件版本在 pproject 级别 build.gradle 中应该是 3.2.0+ 所以我有这个:classpath' com.android.tools.build:gradle:3.2.0-alpha15' 和 gradle 版本在 gradle-wrapper.properties 中应该是 4.5+。下面是我的项目级 build.gradle 文件。这里要注意的点是:classpath 'com.android.tools.build:gradle:3.2.0-alpha15'classpath 'com.google.gms:google-services:4.0.1' ext.play_services_version = '14.0.0 ' // 顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项。

buildscript {
    ext.kotlin_version = '1.2.21'
    ext.support_lib_version = '26.1.0'
    ext.build_tool_version = '26.0.2'
    ext.play_services_version = '14.0.0'

    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        maven { url 'https://maven.fabric.io/public' }

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0-alpha15'
        classpath 'com.google.gms:google-services:4.0.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'io.fabric.tools:gradle:1.+'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        maven { url 'https://maven.google.com' }
        jcenter()
        maven { url "http://appboy.github.io/appboy-android-sdk/sdk" }
        maven { url  "http://tokbox.bintray.com/maven" }
        maven { url "https://jitpack.io" }
//        maven {
//            url 'https://maven.google.com/'
//            name 'Google'
//        }
        maven { url 'https://maven.fabric.io/public' }
    }
}

这个 play_services_version 用于我的一个模块中,以保持 firebase 和 google play 服务的一致性。请参阅下面我使用过的模块的 build.gradle 文件依赖项块。

dependencies {
    api fileTree(dir: 'libs', include: ['*.jar'])

    api "com.android.support:appcompat-v7:${support_lib_version}"
    // compile 'com.google.android.gms:play-services:9.4.0'
    implementation "com.google.android.gms:play-services-analytics:${play_services_version}"
    api "com.google.android.gms:play-services-maps:${play_services_version}"
    implementation "com.google.android.gms:play-services-gcm:${play_services_version}"
    api "com.google.android.gms:play-services-location:${play_services_version}"
    // Note : We have added wearable as AppBoy needs it.
    implementation "com.google.android.gms:play-services-wearable:${play_services_version}"

    // compile 'com.google.android.gms:play-services:6.1.+'
    // compile project(':thirdParty:facebook')
    // Note : We have fixed the facebook sdk version to 4.8.2 as latest facebook sdk versions
    //        result in compilation error in care application since care care application's and its sdk's
    //        compile sdk version is 22 and not 23.
    api 'com.facebook.android:facebook-android-sdk:4.8.2'

    api "com.google.firebase:firebase-core:${play_services_version}"
    api "com.google.firebase:firebase-crash:${play_services_version}"
    api "com.google.firebase:firebase-invites:${play_services_version}"
    implementation "com.google.firebase:firebase-config:${play_services_version}"
    implementation project(':thirdParty:NumberPicker')
    api project(':thirdParty:MaterialDialogs')
    implementation project(':thirdParty:viewpagerindicator')
    api project(':thirdParty:CustomRatingBar')

    api 'com.appboy:android-sdk-ui:2.2.+'
    implementation 'com.mikhaellopez:circularprogressbar:1.0.0'
    // Note : Don't use compile 'com.stripe:stripe-android:+' as stripe does not maintain backward compatibility
    implementation 'com.stripe:stripe-android:1.1.1'
    implementation 'org.apmem.tools:layouts:1.10@aar'
    api "com.android.support:recyclerview-v7:${support_lib_version}"

    // compile 'com.fasterxml.jackson.core:jackson-core:2.4.2'
    // compile 'com.fasterxml.jackson.core:jackson-annotations:2.4.0'
    // compile 'com.fasterxml.jackson.core:jackson-databind:2.4.2'
    // compile project(':thirdParty:card.io')
    implementation project(':thirdParty:material-calendarview')
    //compile 'com.rengwuxian.materialedittext:library:2.1.4'
    // compile ('com.rengwuxian.materialedittext:library:2.1.4') {
    //        exclude group: 'com.nineoldandroids'
    //    }
    implementation project(':thirdParty:facncycoverflow')

    api 'io.card:android-sdk:5.4.1'
    api "com.android.support:design:${support_lib_version}"
//    compile 'com.opentok.android:opentok-android-sdk:2.9.+'

    api ('io.socket:socket.io-client:0.8.3')
    android.libraryVariants.all { variant ->
        variant.getCompileConfiguration().exclude group: 'org.json', module: 'json'
        variant.getRuntimeConfiguration().exclude group: 'org.json', module: 'json'
    }
//    implementation ('io.socket:engine.io-client:0.8.3')
//    android.applicationVariants.all { variant ->
//        variant.getCompileConfiguration().exclude group: 'org.json', module: 'json'
//        variant.getRuntimeConfiguration().exclude group: 'org.json', module: 'json'
//    }

    api "android.arch.lifecycle:runtime:1.1.0"
    api "android.arch.lifecycle:extensions:1.1.0"
    annotationProcessor "android.arch.lifecycle:compiler:1.1.0"
    api 'android.arch.persistence.room:runtime:1.1.0-alpha1'
    annotationProcessor 'android.arch.persistence.room:compiler:1.1.0-alpha1'

    api 'com.siftscience:sift-android:0.9.8'
    implementation 'com.amplitude:android-sdk:2.16.0'

    api project(':patternLib-android:PatternLib')
    api('com.crashlytics.sdk.android:crashlytics:2.8.0@aar') {
        transitive = true;
    }
    api 'com.google.maps.android:android-maps-utils:+'

    api project(':thirdParty:material-edittext')
    api project(':thirdParty:custom_edittext')
    implementation 'com.android.support.constraint:constraint-layout:1.1.0-beta1'
    api 'com.google.code.gson:gson:2.8.1'
}

在我的 gradle-wrapper.properties 文件中,我使用的是 gradle 版本 4.6

#Tue May 29 20:39:46 IST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

现在来解决问题:每次使用以下屏幕截图时,gradle 同步失败:无法解决:com.google.android.gms:play-services-*****

在此处输入图像描述

无法解决:com.google.firebase:firebase-*****

在此处输入图像描述

从 play-services 开始:play-services-map、play-services-analytics、play-services-location 等,从 firebase 开始是 firebase-crash、firebase-core、firebase-invite、firebase-config。提前致谢。

4

0 回答 0