代码之家  ›  专栏  ›  技术社区  ›  Ghasem

无法解析com.android。支持:appcompat-v7:28.0.0

  •  1
  • Ghasem  · 技术社区  · 7 年前

    关于这一点有很多不同的问题,但是关于使用 v7.28.0 , v7.28.+ , v7.28.0.0-rc02

    无法解析“”的依赖项:app@debug/compileClasspath:无法 不解析com.android.support:appcompat-v7:28.0.0。

    我查过了 Support library setup

    这是我的模块应用程序

    buildscript {
        repositories {
            maven { url 'https://plugins.gradle.org/m2/'}
        }
        dependencies {
            classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.1'
        }
    }
    apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
    
    repositories {
        maven { url 'https://maven.google.com' }
    }
    
    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 28
        buildToolsVersion '28.0.3'
    
        defaultConfig {
            applicationId "com.mobaleghan.nasimnoor"
            manifestPlaceholders = [
                    onesignal_app_id: 'b1ced87b-48d1-4857-a68b-9c287aa4003f',
                    // Project number pulled from dashboard, local value is ignored.
                    onesignal_google_project_number: 'REMOTE'
            ]
            minSdkVersion 16
            targetSdkVersion 28
            versionCode 8
            versionName "1.6.3"
            vectorDrawables.useSupportLibrary = true
        }
    
        buildTypes {
            release {
                minifyEnabled true
                proguardFiles getDefaultProguardFile('proguard-android.txt'),
                        'proguard-rules.pro'
            }
            debug {
                debuggable true
            }
        }
    
        lintOptions {
            abortOnError false
        }
    }
    
    dependencies {
        implementation 'com.android.support:appcompat-v7:28.0.0'
        implementation 'com.android.support:design:28.0.0'
        implementation 'com.android.support:preference-v7:28.0.0'
        implementation 'com.android.support:recyclerview-v7:28.0.0'
        implementation 'com.android.support:support-annotations:27.1.1'
        implementation 'com.android.support:support-v4:28.0.0'
        implementation 'com.android.support:cardview-v7:28.0.0'
        implementation 'com.google.android.apps.dashclock:dashclock-api:2.0.0'
        implementation 'com.android.support.constraint:constraint-layout:1.1.0'
        implementation "com.android.support:support-core-utils:28.0.0"
        implementation 'com.onesignal:OneSignal:3.10.3'
    }
    

    和gradle项目:

    buildscript {
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.2.1'
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            google()
            jcenter()
        }
    }
    

    我甚至在AS 3.2.1中创建了一个新项目,但我得到了相同的错误。 我不知道为什么 this happens every time I update AS

    5 回复  |  直到 7 年前
        1
  •  8
  •   Ghasem    7 年前

    我相信其他答案都是好的,而且有效。但我的问题通过设置代理解决了 Freedom of Developers .

    enter image description here

    这个解决方案适用于像我这样的波斯人,他们受到谷歌对伊朗人的严格限制。

    现在我的应用程序gradle如下所示:

    buildscript {
        repositories {
            maven { url 'https://plugins.gradle.org/m2/'}
        }
        dependencies {
            classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.1'
        }
    }
    apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
    
    repositories {
        maven { url 'https://maven.google.com' }
    }
    
    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 28
        buildToolsVersion '28.0.3'
    
        defaultConfig {
            applicationId "com.mobaleghan.nasimnoor"
            manifestPlaceholders = [
                    onesignal_app_id: 'b1ced87b-48d1-4857-a68b-9c287aa4003f',
                    // Project number pulled from dashboard, local value is ignored.
                    onesignal_google_project_number: 'REMOTE'
            ]
            minSdkVersion 16
            targetSdkVersion 28
            versionCode 9
            versionName "1.6.4"
            vectorDrawables.useSupportLibrary = true
        }
    
        buildTypes {
            release {
                minifyEnabled true
                proguardFiles getDefaultProguardFile('proguard-android.txt'),
                        'proguard-rules.pro'
            }
            debug {
                debuggable true
            }
        }
    
        lintOptions {
            abortOnError false
        }
    }
    
    dependencies {
        implementation 'com.android.support:appcompat-v7:28.0.0'
        implementation 'com.android.support:design:28.0.0'
        implementation 'com.android.support:preference-v7:28.0.0'
        implementation 'com.android.support:recyclerview-v7:28.0.0'
        implementation 'com.android.support:support-annotations:28.0.0'
        implementation 'com.android.support:support-v4:28.0.0'
        implementation 'com.android.support:cardview-v7:28.0.0'
        implementation 'com.google.android.apps.dashclock:dashclock-api:2.0.0'
        implementation 'com.android.support.constraint:constraint-layout:1.1.3'
        implementation "com.android.support:support-core-utils:28.0.0"
        implementation 'com.onesignal:OneSignal:3.10.3'
    }
    

    这些存储库是基于 OneSignal documentations .

    buildscript {
        repositories {
            google()
            jcenter()
            maven {
                url 'https://maven.google.com/'
                name 'Google'
            }
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.2.1'
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            google()
            jcenter()
            maven {
                url 'https://maven.google.com/'
                name 'Google'
            }
        }
    }
    

    一切正常。

        2
  •  3
  •   hqt    7 年前

    Android项目有两个gradle文件:一个存储在项目范围内,另一个存储在应用范围内。(请注意,一个项目中可以有许多应用程序,但通常只有一个)。因此,您只需要交换这两个gradle文件中定义的存储库url。

    步骤1:删除您的应用程序中的这些代码行 build.gradle (应用程序)

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

    步骤2:将此添加到您的 格雷德尔先生 (项目)

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

    有一件事你必须意识到 28.0.0 是的最后一个稳定版本 android.support . 所以,您可能希望降级版本或将所有内容迁移到 androidX .

    28.0.0的稳定版本将是打包为android.support的最终功能版本。所有后续的特性版本将仅作为androidx打包的工件提供。

    link 欢迎来到我们的新时代 安卓利德

        3
  •  0
  •   HaroldSer    7 年前

    文件->其他设置->默认设置->构建、执行、部署->构建工具->渐变->取消选中脱机工作选项。

    2) 如果上述方法不起作用,请转到项目的build gradle并在存储库下添加以下内容:

    allprojects {
         repositories {
             jcenter()
             maven {
                 url "https://maven.google.com"
             }
         }
    }
    
        4
  •  0
  •   Martin Zeitler    7 年前

    将此部分从模块的 build.gradle 格雷德尔先生

    buildscript {
        repositories {
            maven { url 'https://plugins.gradle.org/m2/'}
        }
        dependencies {
            classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.1'
        }
    }
    
    repositories {
        maven { url 'https://maven.google.com' }
    }
    

    仅将这些线保留在模块的 :

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

    格雷德尔先生 应该是这样的:

    buildscript {
        repositories {
            google()
            jcenter()
            maven { url 'https://plugins.gradle.org/m2/' }
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.2.1'
            classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.1'
        }
    }
    
    allprojects {
        repositories {
            google()
            jcenter()
        }
    }
    
        5
  •  0
  •   VSB    7 年前

    是时候迁移到Android X了

    根据 Support Library Documentation :

    注意:随着Android 9.0(API级别28)的发布,有一个新的 名为AndroidX的支持库的版本,它是

    您可以继续使用支持库。历史文物 (版本为27及更早,打包为android.support.*) 将在谷歌Maven上保持可用。然而,所有的新图书馆 开发将在AndroidX库中进行。

    还应该考虑将现有项目迁移到AndroidX。

    推荐文章