如何避免在Android Gradle依赖项中发生冲突

问题描述 投票:1回答:2

我是android的新手,正在从事旧的Android项目。它具有Google地方信息自动完成功能,该功能目前不起作用,因为它已弃用了所用的Android版SDK。没有此功能,一切工作正常,但是当我尝试添加此位置sdk implementation 'com.google.android.libraries.places:places:1.0.0'以实现自动完成位置功能时,gradle同步成功,但是当尝试运行该应用程序时,它在所有xml文件上显示错误为资源链接失败或资源'attr / font'的值与配置'etc等的重复值。我的问题是如何在不打扰他人的情况下使用此SDK。以下是我的应用级别Gradle文件

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
//buildToolsVersion "25.0.2"
defaultConfig {
    applicationId "com.example.myappo"
    minSdkVersion 16
    targetSdkVersion 25
    versionCode 27
    versionName "1.5"
    manifestPlaceholders = [HOCKEYAPP_APP_ID: "51a9c4471559421b8d53a07cbb3e3fa0"]
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
}
lintOptions { checkReleaseBuilds false }
buildTypes {

    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }

dexOptions {
    javaMaxHeapSize "4g"
    preDexLibraries = false
    //incremental true
}

repositories {
    jcenter()
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}
useLibrary 'org.apache.http.legacy'
}
   allprojects {
repositories {
    google()
}
repositories {
    maven {
        url 'https://maven.google.com'
    }
}
repositories {
    jcenter()
    maven { url "https://jitpack.io" }
}
}

dependencies {


implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:25.3.1'
implementation 'com.android.support:design:25.1.0'
implementation 'com.google.maps.android:android-maps-utils:0.4'
implementation 'com.google.android.gms:play-services:10.0.1'
implementation 'com.android.support:multidex:1.0.1'
implementation 'com.hbb20:ccp:1.7.2'
implementation 'de.hdodenhof:circleimageview:2.1.0'
implementation 'net.hockeyapp.android:HockeySDK:4.1.3'
implementation 'com.android.support:recyclerview-v7:25.1.1'
implementation 'com.android.support:cardview-v7:25.1.1'
implementation 'com.android.volley:volley:1.0.0'
implementation 'com.facebook.android:facebook-android-sdk:4.0.0'
implementation 'com.google.firebase:firebase-messaging:9.6.0'
implementation 'com.google.code.gson:gson:2.7'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.github.krtkush:LinearTimer:v2.1.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.github.bumptech.glide:glide:3.6.1'
implementation 'com.iarcuschin:simpleratingbar:0.1.5'
implementation 'com.paypal.sdk:paypal-android-sdk:2.15.3'
testImplementation 'junit:junit:4.12'

implementation 'com.google.android.libraries.places:places:1.0.0' // this is creating problem
}
apply plugin: 'com.google.gms.google-services'

这是Project level Gradle文件

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
    jcenter()
    maven { url 'https://maven.google.com' }
    google()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.5.0'
    classpath 'com.google.gms:google-services:3.0.0'
     // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    jcenter()
    maven { url 'https://maven.google.com' }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
android gradle google-places
2个回答
-1
投票

从此实现中删除括号(“ com.google.android.libraries.places:places:1.0.0”)


-1
投票

将您的项目迁移到Android X,这是防止依赖冲突的最佳解决方案Migrate to AndroidX

© www.soinside.com 2019 - 2024. All rights reserved.