当前位置: 首页 > 知识库问答 >
问题:

NoClassDefoundError仅适用于API 22

闽阳州
2023-03-14

我正在开发一个项目,它以前在API23和22上都能很好地工作,然而,当应用程序一启动它就会崩溃(甚至连activity都无法加载)--只在API22上,在API23上它能很好地工作。日志对我没有太大帮助,我已经不知道是什么导致了这个错误的发生。它抱怨的类是清单中定义的App类。下面是一些可能有助于分析的代码:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="br.com.gogame">

<application
    android:name=".commons.infra.App"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:installLocation="preferExternal"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:theme="@style/AppTheme">

    <meta-data
        android:name="DATABASE"
        android:value="gogame.db" />
    <meta-data
        android:name="VERSION"
        android:value="27" />

    <meta-data
        android:name="QUERY_LOG"
        android:value="false" />
    <meta-data
        android:name="DOMAIN_PACKAGE_NAME"
        android:value="br.com.gogame.model" />

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

    <activity
        android:name=".view.activities.ActivityLogin"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

null

public class App扩展com.orm.sugarapp{

private static App mApp = null;
private static MainComponent component;
private static RestTemplate mRequestService = new RestTemplate();

@Override
public void onCreate() {
    super.onCreate();
    mApp = this;
    component = DaggerMainComponent
            .builder()
            .utilModule(new UtilModule(this))
            .postmanModule(new PostmanModule(mRequestService))
            .controllerModule(new ControllerModule())
            .build();

    Intent intent = new Intent(this, EventListener.class);
    startService(intent);
}

public static Application getApplication() {
    return mApp;
}

public static Context getContext() {
    if (mApp == null) {
        return new Application();
    }
    return mApp.getApplicationContext();
}

public static MainComponent getComponent() {
    return component;
}

public static boolean isApplicationInBackground() {
    boolean isInBackground = true;
    ActivityManager am = (ActivityManager) mApp.getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT_WATCH) {
        List<ActivityManager.RunningAppProcessInfo> runningProcesses = am.getRunningAppProcesses();
        for (ActivityManager.RunningAppProcessInfo processInfo : runningProcesses) {
            if (processInfo.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
                for (String activeProcess : processInfo.pkgList) {
                    if (activeProcess.equals(mApp.getApplicationContext().getPackageName())) {
                        isInBackground = false;
                    }
                }
            }
        }
    } else {
        List<ActivityManager.RunningTaskInfo> taskInfo = am.getRunningTasks(1);
        ComponentName componentInfo = taskInfo.get(0).topActivity;
        if (componentInfo.getPackageName().equals(mApp.getApplicationContext().getPackageName())) {
            isInBackground = false;
        }
    }

    return isInBackground;
}

}

 FATAL EXCEPTION: main
 Process: br.com.gogame, PID: 31071             java.lang.RuntimeException: Unable to instantiate application br.com.gogame.commons.infra.App: java.lang.ClassNotFoundException: Didn't find class "br.com.gogame.commons.infra.App" on path: DexPathList[[zip file "/data/app/br.com.gogame-1/base.apk"],nativeLibraryDirectories=[/data/app/br.com.gogame-1/lib/arm, /vendor/lib, /system/lib]]
                                                               at android.app.LoadedApk.makeApplication(LoadedApk.java:563)
                                                               at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4611)
                                                               at android.app.ActivityThread.access$1500(ActivityThread.java:155)
                                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1378)
                                                               at android.os.Handler.dispatchMessage(Handler.java:102)
                                                               at android.os.Looper.loop(Looper.java:135)
                                                               at android.app.ActivityThread.main(ActivityThread.java:5343)
                                                               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:905)
                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
                                                            Caused by: java.lang.ClassNotFoundException: Didn't find class "br.com.gogame.commons.infra.App" on path: DexPathList[[zip file "/data/app/br.com.gogame-1/base.apk"],nativeLibraryDirectories=[/data/app/br.com.gogame-1/lib/arm, /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)
                                                               at android.app.Instrumentation.newApplication(Instrumentation.java:1003)
                                                               at android.app.LoadedApk.makeApplication(LoadedApk.java:558)
                                                               at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4611) 
                                                               at android.app.ActivityThread.access$1500(ActivityThread.java:155) 
                                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1378) 
                                                               at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                               at android.os.Looper.loop(Looper.java:135) 
                                                               at android.app.ActivityThread.main(ActivityThread.java:5343) 
                                                               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:905) 
                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700) 
                                                            Suppressed: java.lang.ClassNotFoundException: br.com.gogame.commons.infra.App
                                                               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)
                                                                    ... 13 more
                                                            Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
apply plugin: 'com.android.application'

应用插件:'kotlin-android'应用插件:'kotlin-android-extensions'应用插件:'com.neenbedankt.android-apt'

android{compileSdkVersion 24 buildToolsVersion“23.0.2”CompileOptions.Incremental=false

sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
}

dexOptions {
    javaMaxHeapSize "4g"
}

defaultConfig {
    applicationId "br.com.gogame"
    minSdkVersion 21
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
    renderscriptTargetApi 23
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

依赖项{compile fileTree(include:['*.jar'],dir:'libs')testCompile“junit:junit:4.12”testCompile“org.mockito:mockito-core:1.10.19”

// GOOGLE LIBRARIES
compile "com.android.support:appcompat-v7:$support_version"
compile "com.android.support:recyclerview-v7:$support_version"
compile "com.android.support:cardview-v7:$support_version"
compile "com.android.support:design:$support_version"
compile 'com.google.firebase:firebase-messaging:9.4.0'
compile 'com.google.guava:guava:18.0'
compile 'com.google.code.gson:gson:2.4'
compile 'com.google.dagger:dagger:2.1'
provided 'com.google.dagger:dagger-compiler:2.1'
provided 'org.glassfish:javax.annotation:10.0-b28'
compile 'com.android.volley:volley:1.0.0'

// KOTLIN
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

// ANKO
compile "org.jetbrains.anko:anko-common:$anko_version"
compile "org.jetbrains.anko:anko-sdk15:$anko_version"
compile "org.jetbrains.anko:anko-support-v4:$anko_version"
compile "org.jetbrains.anko:anko-appcompat-v7:$anko_version"

// APACHE LIBRARIES
compile 'org.apache.httpcomponents:httpmime:4.0-alpha3'

// OWN THIRD LIBRARIES
compile 'br.com.instachat:emoji-library:1.0.8'
compile 'br.com.edsilfer:kiwi:1.0.16'


// THIRD PART LIBRARIES
compile 'com.mikhaellopez:circularimageview:2.0.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.vajro:MaterialDesignLibrary:1.6'
compile 'com.ogaclejapan.smarttablayout:library:1.6.0@aar'
compile 'com.github.rey5137:material:1.2.2'
compile 'com.appyvet:materialrangebar:1.3'
compile 'com.github.afollestad.material-dialogs:core:0.8.5.6@aar'
compile 'com.wang.avi:library:1.0.5'
compile 'com.nineoldandroids:library:2.4.0'
compile "com.mikepenz:iconics-core:2.6.6@aar"
compile 'com.mikepenz:fastadapter:1.5.6@aar'
compile 'com.mikepenz:aboutlibraries:5.6.6@aar'
compile 'com.wdullaer:materialdatetimepicker:2.3.0'
compile 'javax.inject:javax.inject:1'
compile 'com.github.satyan:sugar:1.5'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.15'
compile 'com.yalantis:ucrop:1.5.0'
compile 'com.melnykov:floatingactionbutton:1.3.0'
compile 'org.adw.library:discrete-seekbar:1.0.1'
compile 'com.wang.avi:library:1.0.5'
compile 'jp.wasabeef:blurry:2.0.2'
compile 'com.ToxicBakery.viewpager.transforms:view-pager-transforms:1.2.32@aar'
compile 'com.github.d-max:spots-dialog:0.4@aar'

provided 'javax.annotation:jsr250-api:1.0'

}

buildscript{repositories{jcenter()}dependencies{classpath“org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version”}}

应用插件:'com.google.gms.google-services'

共有1个答案

山高峰
2023-03-14

你要踢自己..

清单包名称中缺少开头的br,它应该是:br.com.gogame.commons.infra.app

相反,您将其设置为.com.gogame.commons.infra.app,这将不起作用,因此类未找到错误

 类似资料:
  • 问题内容: 我正在使用Hibernate3.3.1,我想在人员和指定公司之间建立关系。他们应该松耦合,但我想安排通过级联创建公司,而不是显式调用saveOrUpdate(newCompany)。 我定义了以下实体: 在我的小岛内,我正在执行以下操作: 我得到一个例外 org.hibernate.TransientObjectException:对象引用了一个未保存的瞬态实例- 在刷新之前保存该瞬态

  • 我正在使用连接到web服务 这仅适用于AsyncTask。我无法在普通活动上执行上述语句(没有AsyncTask) 这是故意的行为,还是我错过了什么。 顺便提一下,这是我的第一个问题

  • 我正在尝试实现一个类似问题的系统。这些问题应该根据数据属性“投票”重新排序。因此,每次从套接字接收到like事件时,都会调用sort函数。当一个问题第一次被喜欢时,所有的事情都很好,列表也被排序了。但它会停止排序。我已经检查了数据值。 下面是我的js功能:

  • 我将nginx设置为一种静态文件服务器。出于某种原因,只有当我去123.123.123.123/或123.123.123.123时,它才会起作用。然而,当我去123.123.123.123/static/content/或123.123.123.123/static/content/another.mp3它返回404未找到。下面是位于中并链接到的配置文件。我真的很困惑为什么它不起作用。 如有任何指

  • 在为Android设置了Affdex SDK后,它在ARMv7设备中运行良好,但每当我试图在ARMv8设备中运行该应用程序时,它就不工作了,并出现了以下错误: 致命异常:java.lang.UnsatifiedLinkError dalvik.system.PathClassLoader[DexpathList[[zip文件“/data/app/myprojec-1/base.apk”],nati

  • 问题内容: 假设我有这个模型: 现在,如果我想高效地查看相册中的一部分照片。我这样做是这样的: 这只会执行两个查询,这正是我所期望的(一个查询得到相册,然后一个查询,例如“ SELECT * IN photos WHERE photoalbum_id IN()”。 一切都很棒。 但是,如果我这样做: 然后用!进行大量查询!我是在做错什么,还是django不够聪明,以至于它已经获取了所有照片并可以在