错误:无法解决:androidx.appcompat:appcompat:1.0.2

时间:2019-06-26 08:07:57

标签: android androidx

错误:无法解决:androidx.appcompat:appcompat:1.0.2 在项目结构对话框中显示 受影响的模块:应用

错误:无法解决:androidx.constraintlayout:constraintlayout:1.1.3 在项目结构对话框中显示 受影响的模块:应用

apply plugin: 'com.android.application'

    android {
        compileSdkVersion 28
        defaultConfig {
            applicationId "com.sulaiman.ecommerce"
            minSdkVersion 25
            targetSdkVersion 28
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'androidx.appcompat:appcompat:1.0.2'
        implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
        implementation 'com.google.firebase:firebase-core:17.0.0'
        testImplementation 'junit:junit:4.12'
    }


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

3 个答案:

答案 0 :(得分:0)

添加依赖项

implementation 'com.android.support:appcompat-v7:28.1.1

答案 1 :(得分:0)

打开gradle.properties并添加以下代码:

android.useAndroidX = true

答案 2 :(得分:0)

有两种方法可以解决此问题。

  1. 将targetSDKVersion和CompilerSDKVersion设置为29。

       apply plugin: 'com.android.application'
          android {
        compileSdkVersion 29
        defaultConfig {
            applicationId "com.sulaiman.ecommerce"
            minSdkVersion 25
            targetSdkVersion 29
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'androidx.appcompat:appcompat:1.0.2'
        implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
        implementation 'com.google.firebase:firebase-core:17.0.0'
        testImplementation 'junit:junit:4.12'
    }
    
    
    apply plugin: 'com.google.gms.google-services'
    
  2. 将依赖项更改为implementation 'com.android.support:appcompat-v7:28.1.1

      apply plugin: 'com.android.application'
          android {
        compileSdkVersion 28
        defaultConfig {
            applicationId "com.sulaiman.ecommerce"
            minSdkVersion 25
            targetSdkVersion 28
            versionCode 1
            versionName "1.0"
        }
        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:28.1.1
        implementation 'com.google.firebase:firebase-core:17.0.0'
        testImplementation 'junit:junit:4.12'
    }
    
    
    apply plugin: 'com.google.gms.google-services'