我想用一个库取该用户的日期。
我使用的项目需要从AndroidX库添加库和类。
有一次,我通过添加模块或添加一个直接命令gradle这个添加这个项目,给出了以下错误:
链接所使用的项目:https://github.com/wdullaer/MaterialDateTimePicker
错误:
Failed to resolve: androidx.appcompat:appcompat:1.0.2
Failed to resolve: androidx.recyclerview:recyclerview:1.0.0
的build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.**********"
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildToolsVersion '28.0.3'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
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.0.2'
implementation 'com.android.support:support-vector-drawable:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:gridlayout-v7:28.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.12'
implementation 'com.wdullaer:materialdatetimepicker:4.1.2'
}
如果下面的命令添加到摇篮,下面的错误将被视为
dependencies {
...
implementation 'com.wdullaer:materialdatetimepicker:4.1.2'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
}
错误:
Failed to resolve: androidx.appcompat:appcompat:1.0.2
Failed to resolve: androidx.recyclerview:recyclerview:1.0.0
我没有关于AndroidX库多的信息,但我不认为有这样的图书馆。
我怎样才能解决这个问题?
是否有一个解决这个问题?
您可以轻松地迁移使用下面的步骤来AndroidX:
1 - 首先你的Android Studio版本必须是3.2 +
2-从菜单中选择重构 - >迁移到AndroidX
Android的工作室会告诉你引用改变。选择Do Refactor
并等待几秒钟,我希望这能解决你的问题。
如果您想在新项目中使用AndroidX,你需要编译SDK设置到Android 9.0(API级别28)或更高版本
android.enableJetifier=true
android.useAndroidX=true
从docs
android.useAndroidX:当设置为true时,Android插件使用适当的AndroidX库,而不是支持库。如果不指定该标志默认为false。
android.enableJetifier:当设置为true时,Android插件自动迁移现有的第三方库,通过重写他们的二进制文件使用AndroidX。如果不指定该标志默认为false。