【问题标题】:'Cannot resolve symbol' (design + v7 + annotation)“无法解析符号”(设计 + v7 + 注释)
【发布时间】:2020-01-10 13:03:07
【问题描述】:

我的一个朋友通过他的应用向我发送了一些活动。我为每个活动创建了一个新活动,并将代码复制粘贴到新的空活动中。现在我在导入时遇到了一些问题:

    import android.support.design.widget.TextInputEditText;
    import android.support.design.widget.TextInputLayout;
    import android.support.v7.widget.RecyclerView;
    import android.support.annotation.Nullable;

这里有我的 Gradle - 应用程序:

    apply plugin: 'com.android.application'

    android {
        compileSdkVersion 28
        buildToolsVersion "28.0.3"
        defaultConfig {
    applicationId "com.example.progand"
    minSdkVersion 26
    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.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.3.0-alpha02'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha02'
    }

我尝试添加我在网上找到的所有依赖项,但没有解决问题,它仍然给我错误“无法解析符号'design/v7/annotation'”并且我无法运行我的应用程序来测试活动。 我真的不知道我做错了什么,对不起,如果它看起来很幼稚,但这是我第一次尝试 android studio 3.4.2,SDK 版本 29.0.2。

【问题讨论】:

    标签: android gradle dependencies


    【解决方案1】:

    不要混合com.android.supportandroidx 工件。您应该只使用 androidx 的所有依赖项。
    代替 implementation 'com.android.support:design:28.0.0'implementation 'com.google.android.material:material:1.1.0-alpha08'.

    删除implementation 'com.android.support:recyclerview-v7:28.0.0',因为您已经拥有RecyclerView 的androidx 依赖项。

    现在请参阅Artifact mapping.. 对所有 androidx 库使用相同的最新版本。

    查看Class mapping

    1. android.support.design.widget.TextInputEditText =====> com.google.android.material.textfield.TextInputEditText

    2. android.support.design.widget.TextInputLayout ======> com.google.android.material.textfield.TextInputLayout

    【讨论】:

    • 感谢您的回答!确实是这个问题,谢谢!
    猜你喜欢
    • 1970-01-01
    • 2021-06-23
    • 2020-04-21
    • 1970-01-01
    • 2015-08-28
    • 1970-01-01
    • 1970-01-01
    • 2018-11-11
    • 1970-01-01
    相关资源
    最近更新 更多