ModuleVersionNotFoundException 安卓工作室

11

当我点击运行按钮时,出现以下错误:

Error:org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':app:_debugApkCopy'.

Error:org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find com.android.support:appcompat-v7:27.0.1.

请查看下面的屏幕截图:

enter image description here

当我尝试进行 gradle 同步时,出现以下问题:

请查看下面的屏幕截图:

enter image description here

这是我的 build.gradle 文件:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }

}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}
android {
    signingConfigs {
        config {
        }
    }
    repositories {
        mavenCentral()
    }
    compileSdkVersion 25
    buildToolsVersion '26.0.0'
    useLibrary 'org.apache.http.legacy'
    defaultConfig {
        applicationId "com.hechat"
        minSdkVersion 18
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true

    }
    dexOptions {
        javaMaxHeapSize "2048M"
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
        exclude 'project.properties'
        exclude 'META-INF/INDEX.LIST'

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

    repositories {
        maven { url "https://dl.bintray.com/hani-momanii/maven" }
    }
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'
        exclude group: 'com.google.code.findbugs'
    })
    compile('com.twitter.sdk.android:twitter:2.3.1@aar') { transitive = true; }
    compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') { transitive = true; }
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile 'com.theartofdev.edmodo:android-image-cropper:2.3.1'
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.android.support:cardview-v7:25.0.0'
    compile 'com.android.support:design:25.0.0'
    compile 'net.gotev:uploadservice:2.1'
    compile 'com.android.support:recyclerview-v7:25.0.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'hani.momanii.supernova_emoji_library:supernova-emoji-library:0.0.2'
    compile 'com.google.android.gms:play-services:11.0.4'
    compile 'com.google.firebase:firebase-core:10.2.1'
    compile 'com.google.code.gson:gson:2.3'
    compile 'org.apache.httpcomponents:httpcore:4.3.2'
    compile 'org.apache.httpcomponents:httpmime:4.3.3'
    compile 'com.mcxiaoke.volley:library:1.0.17'
    compile 'com.github.clans:fab:1.6.2'
    compile 'org.jsoup:jsoup:1.8.1'
    compile 'com.parse.bolts:bolts-tasks:1.4.0'
    compile 'com.commit451:PhotoView:1.2.4'
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.splitwise:tokenautocomplete:1.3.3'
    compile 'com.tubb.smrv:swipemenu-recyclerview:5.2.1'
    compile 'com.github.bumptech.glide:glide:3.5.2'
    compile 'se.emilsjolander:stickylistheaders:2.7.0'
    compile 'com.mindorks:placeholderview:0.6.4'
    compile 'org.twitter4j:twitter4j-core:4.0.2'
    compile 'jp.wasabeef:fresco-processors:2.1.0'
    compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.3.0'
    compile 'com.google.firebase:firebase-messaging:10.2.1'
    compile 'com.android.billingclient:billing:1.0'

    testCompile 'junit:junit:4.12'
    compile project(':cometchat_platinum-sdk')

}


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

我之前没有使用过v-27,为什么会出现v7的问题呢?谢谢提前帮助。


请添加您的CometChat应用程序build.gradle文件。 - Pavya
请查看以下答案。 - Ratilal Chopda
使用 buildToolsVersion "25.0.2"。我认为这可能是问题所在。 - Dharmishtha
它不起作用,我已经使用了compileSdkVersion 25和compile 'com.android.support:appcompat-v7:25.0.0',为什么它显示v7:27。 - gaurav gupta
你尝试过使用 buildToolsVersion "25.0.2" 吗? - Dharmishtha
1
是的,我尝试过但没有任何作用。 - gaurav gupta
4个回答

4
在您的应用级别构建文件中添加allprojects块。

1.

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

2. 使用 Android Studio 3.0 及更高版本创建的新项目还包括:

allprojects {
repositories {
    jcenter()
    google()
}}

将编译版本(compileSdkVersion)更改为 26,同时将构建工具版本(buildToolsVersion)更改为 "26.0.1",然后同步您的项目。

希望这可以帮助您。


我添加了Maven {..},然后出现了以下问题:Error:(15, 21) No resource found that matches the given name: attr 'android:keyboardNavigationCluster'。 - gaurav gupta
将您的compileSdkVersion更改为26,同时将buildToolsVersion更改为“26.0.1”,然后同步您的项目。 - Vishal Chauhan
你能告诉我这个错误信息的意思吗?错误信息为:org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find com.android.support:appcompat-v7:27.0.1。 - gaurav gupta
你更新了你的compileSdkVersion和buildToolsVersion吗? - Vishal Chauhan
编译SDK版本26 构建工具版本'26.0.0' 它可以正常工作 - gaurav gupta

0

尝试使用以下 Facebook 的 dependencies,我曾经遇到同样的问题,并通过以下方法解决了它。

请使用这个

compile 'com.facebook.android:facebook-android-sdk:4.26.0'

用这个代替

compile 'com.facebook.android:facebook-android-sdk:[4,5)'

0
在我的情况下,我使用的是旧插件,所以需要添加。
jcenter()

之后

mavenCentral()

0

有一些依赖需要整个模块层次结构包括存储库。

使用 Kotlin DSL

build.gradle.kts(项目)

allprojects {
    repositories {
        // ...
        
        maven(url = "<YOUR-URL>")
    }
}

使用Groovy

build.gradle(项目)

allprojects {
    repositories {
        // ...
        
        maven {
            url '<YOUR-URL>'
        }
    }
}

GL


你在说哪个URL?请解释一下YOUR-URL是什么意思。 - user2357113

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接