错误:无法解析:com.android.support:appcompat-v7:29.0.1

5

我想尝试使用Intellij平台进行Android开发,但即使是全新的安装也会显示gradle失败。请帮忙解决。

我已经尝试修改行

implementation 'com.android.support:appcompat-v7:29.+'

我曾尝试升级到其他版本,但无济于事。

这是我的模块级别的gradle文件:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.1"
    defaultConfig {
        applicationId "com.example.myapplication"
        minSdkVersion 23
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:29.+'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

这是我的项目级别Gradle配置文件

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

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'

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

allprojects {
    repositories {
        google()
        jcenter()

    }
}

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

我在Intellij构建gradles过程中遇到的错误有:
ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not find any version that matches com.android.support:appcompat-v7:29.+.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not find any version that matches com.android.support:appcompat-v7:29.+.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not find any version that matches com.android.support:appcompat-v7:29.+.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not find any version that matches com.android.support:appcompat-v7:29.+.
Show Details
Affected Modules: app


ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not find any version that matches com.android.support:appcompat-v7:29.+.
Show Details
Affected Modules: app


ERROR: Failed to resolve: com.android.support:appcompat-v7:29.0.1
Affected Modules: app

尝试将classpath 'com.android.tools.build:gradle:3.1.0'更新为最新版本。 - roshan posakya
你试过我的答案了吗? - Sumit Shukla
我尝试将Gradle更新到3.4.2,但现在它显示了一个不同的错误错误:最低支持的Gradle版本为5.1.1。当前版本为4.10.1。请修复项目的Gradle设置。 修复Gradle包装器并重新导入项目 Gradle设置 - Sandipan Majhi
是的 @SumitShukla - Sandipan Majhi
请检查我的更新答案。 - Sumit Shukla
1个回答

4

前往以下位置进行迁移到androidX:

Refactor->Migrate to androidX

IMAGE


我应该在哪里写它?...我是个完全的新手。 - Sandipan Majhi
更改后,它显示最低Gradle版本应为4.1.1。 - Sandipan Majhi
1
是的,也要更新Gradle版本! - Sumit Shukla
终于解决了,谢谢! :D 谢谢兄弟。 - Sandipan Majhi
1
在创建新项目时,请在Android Studio中勾选使用androidx工件复选框。 - Sumit Shukla
显示剩余5条评论

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