在 Gradle 中加载材料 - 无法下载“android-P" [英] Load Material in Gradle - Failed downloading 'android-P'
问题描述
我对 Android Studio 真的很陌生.
i am really new to Android Studio.
我想将 Material 依赖项添加到我的项目中,但是在 sync
我的 gradle 文件中我收到一条错误消息.
I would like to add the Material dependency to my project but while sync
my gradle file I get an error message.
此线程(link)告诉我使用 compileSdkVersion 'android-P'
但这会导致 android studio 告诉我下载 android-P
失败,当我点击下载时(... android-P 不是可供下载...).
This thread (link) told me to use compileSdkVersion 'android-P'
but this results in android studio telling me to download android-P
which it fails to do, when i click on download (... android-P not avaliable for download..).
所以我按照材料主页上的描述重新尝试它开始.
So I went back to trying it as described on the material homepage get started.
您可以在下面找到我的相应代码和错误消息:
Below you can my find my according code and error message:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.chris.doghelper"
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
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'
}
和错误信息:
Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-24:19 to override.
你有解决我的问题的方法吗?
Do you have a fix for my problem?
推荐答案
这是因为您使用的是带有旧版支持库的新材料库.您必须将 android.support
迁移到 androidx
才能使用 com.google.android.material
.
This is because you are using the new Material library with the legacy Support Library. You have to migrate android.support
to androidx
in order to use com.google.android.material
.
如果您还不想切换到新的 androidx
和 com.google.android.material
包,您可以通过 com.android.support:design:28.0.0
依赖.
If you don't want to switch over to the new androidx
and com.google.android.material
packages yet, you can use Material Components via the com.android.support:design:28.0.0
dependency.
关注链接1和
要切换 androidX,请按照此 Link3.
To switch androidX follow this Link3.
我走得更深入,我为你找到了.
I went to more deeper and I got it for you.
它一定会帮助你.
快乐编码!
这篇关于在 Gradle 中加载材料 - 无法下载“android-P"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!