我正在开发一个使用 ActionBarSherlock 库项目的应用程序,当前项目使用 androidx 依赖项。
如果出现Make Project android.support.v4.app 不存在错误。 错误:找不到符号 符号:FragmentActivity 类 错误:包 mFragments 不存在 等等...
我的问题是 1.如何兼容androidx中之前的android.support包? 2.如何正确迁移到使用旧的android支持库的androidx?
我的模块中的build.gradle如下:
1. Module:ActionBarSherlock 中的 build.gradle 是模块 app
的 lib 项目
应用插件:'com.android.library'
android {
compileSdkVersion 29
defaultConfig {
minSdkVersion 4
targetSdkVersion 29
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
}
app
中的 build.gradle 使用上述ActionBarSherlock
作为 lib 项目
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.app"
minSdkVersion 15
targetSdkVersion 29
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
compile project(':ActionBarSherlock')
configurations.compile.exclude module: 'support-v4'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
implementation 'com.actionbarsherlock:library:4.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
最佳答案
ActionBarSherlock is deprecated. No more development will be taking place.
正如其 official repository 中所述
所以我提醒你不要使用那个库。
关于java - 如何修复 androidx 项目中不存在的包 android.support.v4.app ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59427204/