【问题标题】:Assistance with android studio gradle协助 android studio gradle
【发布时间】:2020-04-15 22:43:52
【问题描述】:

这是我的第一篇文章,但我需要一些帮助, 这是我的错误:

error: package android.support.design.widget does not exist
import android.support.design.widget.FloatingActionButton;

这是我的毕业代码

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion "23.0.0"

    defaultConfig {
        applicationId "com.example.weatherviewerappeliasshahsamand"
        minSdkVersion 23
        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(include: ['*.jar'], dir: 'libs')

    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:gridlayout-v7:28.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.13'
    implementation 'com.google.android.material:material:1.2.0-alpha06'

    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

    implementation 'com.google.android.material:material:1.1.0'
    implementation 'androidx.cardview:cardview:1.0.0'
}

【问题讨论】:

标签: android gradle


【解决方案1】:

您的项目中同时有支持库和 androidx 库...我认为这一定是问题。 您可以使用:

implementation 'androidx.appcompat:appcompat:1.1.0-rc01'

代替:

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

您可以替换您的其他支持库代码并使用 androidx 库

【讨论】:

    【解决方案2】:

    您已将一些依赖项迁移到 AndroidX,但仍有一些依赖项似乎与 android X 不匹配。您必须将一些依赖项替换为最新版本: 替换

    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:gridlayout-v7:28.0.0'
    
    

    与

    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.gridlayout:gridlayout:1.0.0'
    

    现在作为错误消息,请将小部件替换为 androidx 或 Migrate by

    Refactor > Migrate to AndroidX > Migrate
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-12-02
      • 2023-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-09
      • 2017-05-10
      • 2017-11-23
      相关资源
      最近更新 更多