gpt4 book ai didi

java - NoClassDefFoundError : Failed resolution of: Lcom/parse/ui/R$layout; on pre-Lollipop

转载 作者:行者123 更新时间:2023-11-29 20:31:16 25 4
gpt4 key购买 nike

我是一名尝试使用 Parse's 开发 Android 应用程序的新开发人员服务。我的应用程序使用了 Github 上可用的 ParseUI它工作正常。

但是,最近在运行应用程序时,我在应用程序启动时遇到了这个错误:

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/parse/ui/R$layout;
at com.parse.ui.ParseLoginFragment.onCreateView(ParseLoginFragment.java:212)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1789)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:955)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:551)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
at android.app.Activity.performStart(Activity.java:5241)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2157)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.parse.ui.R$layout" on path: DexPathList[[zip file "/data/app/com.udrink-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.udrink-1, /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)
at com.parse.ui.ParseLoginFragment.onCreateView(ParseLoginFragment.java:212)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1789)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:955)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:551)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
at android.app.Activity.performStart(Activity.java:5241)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2157)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
Suppressed: java.lang.ClassNotFoundException: com.parse.ui.R$layout
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 20 more
Caused by: java.lang.NoClassDefFoundError: Class "Lcom/parse/ui/R$layout;" not found
... 24 more

我知道之前有几个关于这个问题的问题。但这有点不同,因为此错误发生在运行 Android KitKat 及之前版本 (API <=19) 的设备上。当我在运行 Android Lollipop (API >=21) 的设备上执行相同的代码时 - NO 没有任何修改,它运行得非常好。

有人能指出这里的问题是什么以及如何解决吗?

这是我项目的build.gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId 'com.udrink'
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
renderscriptTargetApi 22
renderscriptSupportModeEnabled true
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
// Module dependency on ParseLoginUI library sources
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:recyclerview-v7:22.2.1'
compile 'com.android.support:cardview-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.tonicartos:superslim:0.4.13'
compile 'com.makeramen:roundedimageview:2.1.0'
compile 'com.daimajia.swipelayout:library:1.2.0'
compile 'com.github.gabrielemariotti.cards:cardslib-core:2.1.0'
compile 'com.github.gabrielemariotti.cards:cardslib-cards:2.1.0'
compile 'com.github.gabrielemariotti.cards:cardslib-recyclerview:2.1.0'
compile('com.mikepenz:actionitembadge:3.0.1@aar') {
transitive = true
}
compile 'com.github.jd-alexander:library:1.0.5'
compile 'com.github.castorflex.smoothprogressbar:library:1.1.0'
compile 'com.github.castorflex.smoothprogressbar:library-circular:1.1.0'
compile project(':ParseLoginUI')
compile project(':crop')
}

我正在运行 Android Studio 1.3。

编辑

这里是一些额外的信息:

导致这个错误的具体代码是这样的:

at com.parse.ui.ParseLoginFragment.onCreateView(ParseLoginFragment.java:212)

在 ParseUI 中指向 ParseLoginFragment.java 中的这一行:

View v = inflater.inflate(R.layout.com_parse_ui_parse_login_fragment, parent, false);

如您所见,这只是简单的布局 inflate 代码,没有任何特定于 API 的函数。

此外,消息指定错误是:

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/parse/ui/R$layout;

据我了解,这意味着未找到 ParseUIR 类。

最佳答案

您应该先检查 API 级别,然后再调用比您的最小级别更高的代码 (API)。例如你的 minSdkVersion 是 16,而你使用的是 22 出生的 API,那么你需要

if (android.os.Build.VERSION.SDK_INT >=22)
{
//the specify code.
}

关于java - NoClassDefFoundError : Failed resolution of: Lcom/parse/ui/R$layout; on pre-Lollipop,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31915939/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com