gradle 未找到类定义错误:失败的解析:Landroid/支持/v4/操作系统/构建兼容性;

9udxz4iz  于 2022-11-24  发布在  Android
关注(0)|答案(1)|浏览(110)

我有一个问题处理这个错误,当我运行我的应用程序停止,并显示在logcat错误:
导致的原因:java.lang.类未找到异常:在以下路径中未找到类“android.support.v4.os.BuildCompat”:“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“
完全错误:

FATAL EXCEPTION: main 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: Process: homeseek.app.android.capstonehomeseek, PID: 1919 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/os/BuildCompat; 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:188) 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:173) 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:511) 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71) 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at homeseek.app.android.capstonehomeseek.MainActivity.onCreate(MainActivity.java:48) 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:6323) 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387) 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494) 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.app.ActivityThread.access$900(ActivityThread.java:153) 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1347) 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102) 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148) 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5451) 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.os.BuildCompat" on path: DexPathList[[zip file "/data/app/homeseek.app.android.capstonehomeseek-1/base.apk"],nativeLibraryDirectories=[/data/app/homeseek.app.android.capstonehomeseek-1/lib/arm64, /vendor/lib64, /system/lib64]] 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:469) 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:188)  11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:173)  11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:511)  11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)  11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at homeseek.app.android.capstonehomeseek.MainActivity.onCreate(MainActivity.java:48)  11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:6323)  11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)  11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)  11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)  11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.app.ActivityThread.access$900(ActivityThread.java:153)  11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1347)  11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)  11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148)  11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5451)  11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)  11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)  11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: Suppressed: java.lang.ClassNotFoundException: android.support.v4.os.BuildCompat 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at java.lang.Class.classForName(Native Method) 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at java.lang.BootClassLoader.findClass(ClassLoader.java:781) 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:504) 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: ... 18 more 11-29 13:00:24.538 1919-1919/? E/AndroidRuntime: Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

这是我房子

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "homeseek.app.android.capstonehomeseek"
        minSdkVersion 20
        targetSdkVersion 23
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }

    dexOptions {
        javaMaxHeapSize "4g"
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile files('libs/PhotoUtil.jar')
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.android.support:recyclerview-v7:23.4.0'
    compile 'com.android.support:cardview-v7:23.4.0'
    compile 'com.android.support:palette-v7:23.4.0'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile ('com.android.support:support-v4:23.4.0'){
        force = true;
    }
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.google.android.gms:play-services:9.8.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
}

我真的不知道怎么解决这个问题请帮帮我

hlswsv35

hlswsv351#

我面临着这个问题。我认为问题是:

compile 'com.google.android.gms:play-services:9.8.0'

你编译了很多包。在某些情况下,这样做会使你的应用程序中的方法数量(包括框架API、库方法和你自己的代码)更难控制在65,536个限制之下。所以这就造成了NoClassDefFoundError。请关注我的帖子:java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/util/ArrayMap

相关问题