【发布时间】:2020-01-14 21:39:32
【问题描述】:
我做了什么:
- 我正在使用 this 库并通过 gradle 导入。导入时没有问题。
- 我正在尝试使用它的片段之一。
问题:
尝试解决:
有什么办法可以摆脱这个错误吗?为什么会这样?
~谢谢~
Gradle 文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.test3"
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
repositories {
jcenter()
maven {
url "http://dl.bintray.com/shimmerengineering/Shimmer"
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'ShimmerAndroidInstrumentDriver:ShimmerAndroidInstrumentDriver:AA-227-1test'
}
gradle.properties 文件:
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
【问题讨论】:
-
如果您的项目不使用 androidx,请从菜单栏中尝试
Refactor > Migrate to AndroidX。 -
谢谢@MohammedAlaa,我试过这个并在下面的讨论中回复。似乎工作项目已经使用 android,但导入的库不是,通过尝试
Refactor > Migrate to AndroidX仅影响项目而不影响库。
标签: android api android-studio android-fragments androidx