【问题标题】:'ERROR: Failed to resolve: com.android.support:appcompat-v7:29.0.1' [duplicate]'错误:无法解决:com.android.support:appcompat-v7:29.0.1' [重复]
【发布时间】:2019-07-25 09:42:51
【问题描述】:

我想尝试使用 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

【问题讨论】:

  • 尝试用最新版本更新类路径 'com.android.tools.build:gradle:3.1.0'
  • 你试过我的答案了吗?
  • 我尝试将 gradle 更新到 3.4.2,但现在它显示不同的错误错误:支持的最低 Gradle 版本是 5.1.1。当前版本是 4.10.1。请修复项目的 Gradle 设置。修复 Gradle 包装器并重新导入项目 Gradle 设置 @roshanposakya
  • 是的@SumitShukla
  • 检查我的更新答案

标签: android gradle intellij-idea build-tools appcompatactivity


【解决方案1】:

通过以下方式迁移到androidX

Refactor->Migrate to androidX

【讨论】:

  • 我应该在哪里写? ...我完全是菜鸟
  • 是的,没有 android 选项 .... 只有 JavaFX、JUnit 和 Swing
  • 是的,我明白了...我选择了迁移到 android x,现在它显示了我需要更改行的参考
  • 是的,也更新 gradle 版本!
  • 当你将创建一个新项目时勾选在 android studio 中使用 androidx artifacts 的复选框。
猜你喜欢
  • 2023-03-16
  • 1970-01-01
  • 2017-01-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-03
相关资源
最近更新 更多