java - 如何修复 androidx 项目中不存在的包 android.support.v4.app ?

标签 java android

我正在开发一个使用 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/

    相关文章:

    java - 尝试向 Grizzly+Jersey 应用程序添加过滤器时出现问题

    java - 带有 OneToMany 的 Spring Data Projection 返回太多结果

    JPanel 上的 Java mouseListener 不起作用

    android - 如何使用 fragment 内的实时数据更新 Recycler View ?

    android - 带正则表达式的过滤器适配器

    java - 从 getCursorName 函数读取数据时出现异常 "positioned update not supported"

    java - java中的repaint()不调用paintComponent()

    Android:在应用程序的设备中管理多个推送通知

    java - 调整屏幕亮度时出现 WRITE_SETTINGS 权限的 SecurityException

    android - 如何在没有可写和可执行段的情况下为Android O编译.so?如何设置特定的ELF权限?