为什么在我的项目中找不到 CoordinatorLayout
Why CoordinatorLayout not found on my project
在这里发布之前,我搜索了很多,但找不到解决方案。
为什么在我的项目中找不到 CoordinatorLayout?
截图
gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.salah250.forvo"
minSdkVersion 17
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
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'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:support-vector-drawable:27.1.1'
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'
//Material Design
implementation 'com.android.support:design:27.1.1'
//Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
//GSON
implementation 'com.google.code.gson:gson:2.8.5'
//Event Bus
implementation 'org.greenrobot:eventbus:3.1.1'
//Picasso
implementation 'com.squareup.picasso:picasso:2.71828'
//Butter knife
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
//Circle Image
implementation 'de.hdodenhof:circleimageview:2.2.0'
}
我希望找到解决这个问题的方法................................................
设置 AndroidX 有一些先决条件。您可以在 Using AndroidX section of the documentation as well as in the Migrate an existing project using Android Studio 中找到其中一些。
我从您提供的代码片段中首先注意到的是,您没有将 compileSdkVersion
设置为 28,但请检查我提供给您的链接。可能还有更多内容。
只需将这两行放入您的 gradle.properties -file:
android.useAndroidX=true
android.enableJetifier=true
进行 gradle 同步,您就设置好了:)
如果您检查了依赖项 (com.android.support:appcompat-v7:27.1.1
) 并且在以以下内容开头的布局中:androidx.coordinatorlayout
这意味着 您是仍在使用支持库依赖项 但您正在尝试使用 AndroidX
CoordinatorLayout
.
使用 Refactor
中的 Migrate to AndroidX
或者,使用支持库 CoordinatorLayout
:
<android.support.design.widget.CoordinatorLayout>
</android.support.design.widget.CoordinatorLayout>
在这里发布之前,我搜索了很多,但找不到解决方案。
为什么在我的项目中找不到 CoordinatorLayout?
截图
gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.salah250.forvo"
minSdkVersion 17
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
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'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:support-vector-drawable:27.1.1'
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'
//Material Design
implementation 'com.android.support:design:27.1.1'
//Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
//GSON
implementation 'com.google.code.gson:gson:2.8.5'
//Event Bus
implementation 'org.greenrobot:eventbus:3.1.1'
//Picasso
implementation 'com.squareup.picasso:picasso:2.71828'
//Butter knife
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
//Circle Image
implementation 'de.hdodenhof:circleimageview:2.2.0'
}
我希望找到解决这个问题的方法................................................
设置 AndroidX 有一些先决条件。您可以在 Using AndroidX section of the documentation as well as in the Migrate an existing project using Android Studio 中找到其中一些。
我从您提供的代码片段中首先注意到的是,您没有将 compileSdkVersion
设置为 28,但请检查我提供给您的链接。可能还有更多内容。
只需将这两行放入您的 gradle.properties -file:
android.useAndroidX=true
android.enableJetifier=true
进行 gradle 同步,您就设置好了:)
如果您检查了依赖项 (com.android.support:appcompat-v7:27.1.1
) 并且在以以下内容开头的布局中:androidx.coordinatorlayout
这意味着 您是仍在使用支持库依赖项 但您正在尝试使用 AndroidX
CoordinatorLayout
.
使用 Refactor
中的 Migrate to AndroidX
或者,使用支持库 CoordinatorLayout
:
<android.support.design.widget.CoordinatorLayout>
</android.support.design.widget.CoordinatorLayout>