Android Studio项目中未解决的依赖项

时间:2019-12-18 14:50:35

标签: android gradle dependencies

问题:我最近更新/安装了最新版本的Android Studio,并导入了一个旧项目。 同步项目时出现以下错误:

enter image description here

错误如下:

  

无法解决:com.google.android.gms:play-services-ads-identifier:12.0.1   在项目结构对话框中显示   受影响的模块:应用

     

无法解决:com.google.firebase:firebase-measurement-connector:12.0.1   在项目结构对话框中显示   受影响的模块:应用

我尝试将所有必需的元素添加到gradle中,并尝试在SDK中安装Google Play服务。我的项目是从桌面导入的。

这是我的app / build.gradle:

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' }

    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.0'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

repositories {
    maven { url 'https://maven.google.com' }
}

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29

    defaultConfig {
        applicationId "com.albetaqasite"

        manifestPlaceholders = [
                onesignal_app_id               : 'cc95bb51-0699-4309-9322-be8793d5e564',
                // Project number pulled from dashboard, local value is ignored.
                onesignal_google_project_number: 'REMOTE']


        minSdkVersion 15
        targetSdkVersion 29
        versionCode 55
        versionName "3.4.1"
        multiDexEnabled true
        dexOptions {
            javaMaxHeapSize "4g"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }

    useLibrary 'org.apache.http.legacy'
}
repositories {
    maven {
        url "https://jitpack.io"
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation files('libs/android-async-http-1.4.4.jar')
    implementation project(':ColorDialog')
    implementation files('libs/universal-image-loader-1.9.4.jar')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    //implementation 'cn.pedant.sweetalert:library:1.3'
    implementation 'com.github.f0ris.sweetalert:library:1.5.1'
    implementation 'com.google.code.gson:gson:2.3.1'
    implementation 'com.google.android.gms:play-services:8.4.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.squareup.okhttp:okhttp:2.+'
    implementation 'com.squareup.okhttp:okhttp-urlconnection:2.+'
    implementation 'com.google.android.gms:play-services-ads:8.4.0'
    implementation 'com.google.android.gms:play-services-identity:8.4.0'
    //compile 'com.google.android.gms:play-services-gcm:8.4.0'
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.7'
    implementation 'com.onesignal:OneSignal:[3.8.3, 3.99.99]'
   // compile 'com.google.firebase:firebase-core:8.4.0'

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

这是我的Project / build.gradle:

buildscript {
    repositories {
        google()
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'
        classpath 'com.google.gms:google-services:4.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven {
            url "https://maven.google.com" // Google's Maven repository
        }    }
}

dependencies {
}

PS:我知道android.com.support依赖项中的问题,当我将compileSdkVersiontargetSdkVersion更改为27时,它可以工作,但是gradle却不能不能解决,如果您曾经遇到过或有任何解决方法的想法,请分享您的知识和经验。

1 个答案:

答案 0 :(得分:0)

我认为您需要在这些条目附近的部分中为这些依赖项添加条目:

    implementation 'com.google.android.gms:play-services:8.4.0'
    implementation 'com.google.android.gms:play-services-ads:8.4.0'
    implementation 'com.google.android.gms:play-services-identity:8.4.0'

但是,如果尝试引入一个库的12.0.1版本和另一个相关库的8.4.0版本,则可能会遇到问题。看看是否可以将这三个版本的版本号提高到12.0.1