在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.
该线程(链接)告诉我使用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.
要切换androidX,请遵循以下 Link3 .
To switch androidX follow this Link3.
我走得更深,为你找到了它.
I went to more deeper and I got it for you.
肯定会为您提供帮助.
祝您编程愉快!
这篇关于在Gradle中加载素材-无法下载"android-P"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!