如何解决无法解决Android Studio中库的错误?

时间:2018-10-24 08:57:18

标签: android android-studio android-studio-3.0

我开发了一个Android应用程序,过了几天,我在logcat不同步项目中看到以下错误!

我开发了一个Android应用程序,过了几天,我在logcat不同步项目中看到以下错误!

我开发了一个Android应用程序,过了几天,我在logcat不同步项目中看到以下错误!

在错误下方显示我:

app/build.gradle    
Failed to resolve: design   
Failed to resolve: appcompat-v7 
Failed to resolve: cardview-v7  
Failed to resolve: support-vector-drawable  
Failed to resolve: play-services-base-license   

我的build.gradle文件:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }

    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.25.4'

    }
}
plugins {
    id 'com.onesignal.androidsdk.onesignal-gradle-plugin' version '0.8.1'
}

apply plugin: 'com.android.application'
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

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

apply plugin: 'io.fabric'


android {
    compileSdkVersion 27
    buildToolsVersion '28.0.2'
    defaultConfig {
        applicationId "com.app.android"
        minSdkVersion 16
        targetSdkVersion 25

        versionCode 30
        versionName "1.3.1"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true

        manifestPlaceholders = [onesignal_app_id: "48ce7653-3dd1-4aef-8439-b159ae8d4fad", onesignal_google_project_number: "REMOTE"]

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    configurations {
        all {
            exclude module: 'httpclient'
            exclude module: 'json'
            exclude group: 'org.apache.httpcomponents'
        }
    }

}

dependencies {
    implementation 'com.android.support:support-v4:27.0.2'
    api fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    api 'com.android.support:appcompat-v7:27.0.2'
    api 'com.android.support:design:27.0.2'
    api 'com.android.support:cardview-v7:27.0.2'
    api 'com.android.support.constraint:constraint-layout:1.0.2'
    api 'com.roughike:bottom-bar:2.+'
    testImplementation 'junit:junit:4.12'
    api 'com.android.support:support-v13:+'
    api 'uk.co.chrisjenx:calligraphy:2.3.0'
    api 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
    api 'com.squareup.retrofit2:retrofit:2.3.0'
    api 'com.squareup.retrofit2:converter-gson:2.3.0'
    api 'com.google.code.gson:gson:2.8.1'
    api 'com.squareup.okhttp3:logging-interceptor:3.9.1'
    api 'com.github.bumptech.glide:glide:3.7.0'
    api 'com.github.nkzawa:socket.io-client:0.5.2'
    api 'com.auth0.android:jwtdecode:1.1.1'
    api 'com.airbnb.android:lottie:2.5.0-beta1'
    api 'com.auth0:java-jwt:3.3.0'
    api 'com.github.faruktoptas:FancyShowCaseView:1.0.0'

    api 'com.google.firebase:firebase-core:12.0.1'
    api 'com.google.firebase:firebase-crash:12.0.1'
    api 'com.google.firebase:firebase-messaging:12.0.1'
    api 'com.google.android.gms:play-services-analytics:12.0.1'
    api 'com.google.android.gms:play-services-location:12.0.1'

    api 'com.adjust.sdk:adjust-android:4.12.2'
    api 'com.github.chrisbanes:PhotoView:2.0.0'
    api 'com.dlazaro66.qrcodereaderview:qrcodereaderview:2.0.3'
    api 'com.google.zxing:core:3.2.1'

    api('com.crashlytics.sdk.android:crashlytics:2.9.4@aar') {
        transitive = true
    }
    api('com.crashlytics.sdk.android:answers:1.4.1@aar') {
        transitive = true
    }
    api 'com.onesignal:OneSignal:[3.7.1, 3.99.99]'
    api 'com.afollestad.material-dialogs:core:0.9.4.5'
    api 'id.zelory:compressor:2.1.0'
    api 'com.android.support:multidex:1.0.3'
    api 'com.android.support:multidex-instrumentation:1.0.3'
    api 'org.greenrobot:eventbus:3.1.1'
    api 'com.codemybrainsout.onboarding:onboarder:1.0.4'
    api "com.mikepenz:itemanimators:1.0.2"
    api 'jp.wasabeef:recyclerview-animators:2.3.0'
    api 'android.arch.persistence.room:runtime:1.1.1'
    annotationProcessor 'android.arch.persistence.room:compiler:1.1.1'

}

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

项目级别gradle:

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.google.gms:google-services:4.1.0'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

task clean(type: Delete) {
    delete rootProject.buildDir
}

我确定我的互联网已连接。

我该如何解决?

3 个答案:

答案 0 :(得分:1)

更改顺序并将google()放在jcenter()的{​​{1}}之前

为什么? here

您的最终项目级别build.gradle应该看起来像这样

build.gradle

答案 1 :(得分:0)

尝试将此存储库添加到allprojects项目的build.gradlejcenter() mavenCentral() google()

int

我希望这会对您有所帮助。

答案 2 :(得分:0)

请单击突出显示按钮(与gradle文件同步项目)

https://i.stack.imgur.com/hwNAa.png