将支持库更新到 23.2.1 后选项卡布局崩溃

2022-09-03 16:44:37

一切正常,直到我更新了我的gradle文件,现在我的选项卡布局由于错误而崩溃:

Java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/widget/TintManager;at android.support.design.widget.TabLayout$TabView.(TabLayout.java:1185) at android.support.design.widget.TabLayout.createTabView(TabLayout.java:656) at android.support.design.widget.TabLayout.addTabView(TabLayout.java:695) at android.support.design.widget.TabLayout.addTab(TabLayout.java:386) at android.support.design.widget.widget.TabLayout.addTab(TabLayout.java:361) at android.support.design.widget.TabLayout.setTabsFromPagerAdapter(TabLayout.java:645) at android.support.design.widget.TabLayout.setupWithViewPager(TabLayout.java:616) at com.example.ScrollableTabsActivity.onCreate(ScrollableTabsActivity.java:307) at android.app.Activity.performCreate(Activity.java:6033) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2288) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2397) at android.app.ActivityThread.access$800(ActivityThread.java:151) atandroid.app.ActivityThread$H.handleMessage(ActivityThread.java:1310) at android.os.handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5268) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697) Caused by: java.lang.ClassNotFoundException: Didn't find class “android.support.v7.widget.TintManager” on path: DexPathList[[zip file “/data/app/com.example-1/base.apk”],nativeLibraryDirectories=[/vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) atandroid.support.design.widget.TabLayout$TabView.(TabLayout.java:1185) at android.support.design.widget.TabLayout.createTabView(TabLayout.java:656) at android.support.design.widget.TabLayout.addTabView(TabLayout.java:695) at android.support.design.widget.TabLayout.addTab(TabLayout.java:386) at android.support.design.widget.widget.TabLayout.addTab(TabLayout.java:361) at android.support.design.widget.TabLayout.setTabsFromPagerAdapter(TabLayout.java:645) at android.support.design.widget.TabLayout.setupWithViewPager(选项卡布局.java:616)

 

这是我的文件gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.example"
    minSdkVersion 11
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:cardview-v7:23.2.1'
compile 'com.android.support:recyclerview-v7:23.2.1'
compile 'com.mcxiaoke.volley:library:1.0.+@aar'
compile 'com.github.hotchemi:stringpicker:0.0.2'
compile files('libs/devsmartlib.jar')
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.1@aar'
compile 'com.daimajia.androidanimations:library:1.1.3@aar'
compile project(':lib')
}

请帮帮我哪里错了


答案 1

更改依赖项确实做到了这一点,只需添加com.android.support:support-v4:23.2.0并将构建工具版本更新为23.0.2

compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:recyclerview-v7:23.2.0'
compile 'com.android.support:support-v4:23.2.0'
compile 'com.android.support:cardview-v7:23.2.0'

我不知道为什么有些人将我的问题标记为负面,无论如何,这可能会帮助某人


答案 2

所有支持库必须具有相同的版本。23.2.1或23.1.1或其他,但你不能混合版本。

ext.supportLibVersion = "23.2.1"
// design includes recyclerview-v7 and appcompat-v7, which includes support-v4
compile "com.android.support:design:$supportLibVersion"
compile "com.android.support:cardview-v7:$supportLibVersion"

推荐