简体   繁体   中英

how to fix package android.support.v4.app not exist in androidx projects?

I am developing on an app that uses the ActionBarSherlock library project, and the current project uses androidx dependences.

If Make Project will appear android.support.v4.app not exist error. error: can't find symbol symbol: class FragmentActivity error: package mFragments not exist and so on...

My question is 1.How to be compatible with the previous android.support package in androidx? 2.How to migrate to androidx correctly which using the old android support library?

My build.gradle in module as follws: 1. build.gradle in Module:ActionBarSherlock which is a lib project of module app apply plugin: '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'])
}
  1. build.gradle in app which using the above ActionBarSherlock as lib project
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.

As it says in its official repository

So I remind you not to use that library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM