当我启动我的应用程序时,如何修复这个不寻常的NoClassDefFoundError

时间:2016-08-26 10:19:33

标签: android noclassdeffounderror

我的Android应用有这种奇怪的崩溃。这就是它的方式:

如果我将应用程序发送到手机(比如说 蓝牙,Xender或通过电子邮件发送给我的朋友)我启动它,应用程序崩溃没有晚上开始。它甚至没有显示启动画面。只需点按启动器图标,应用就会崩溃。但是,如果我从Android Studio启动应用程序(即构建和运行),它不会崩溃。如果我完全卸载应用程序(从Android Studio运行后)并通过蓝牙或Xender发送,它会更长时间崩溃。

到目前为止,我已经能够在Kitkat上重现此错误,但在Lollipop +上没有。

请注意我的应用是在调试版本中。

这是应用生成的崩溃数据:

08-26 05:32:52.865 1630-1630/com.ozuf.poster W/dalvikvm: VFY: unable to resolve static field 20 (applicationId) in Lcom/android/tools/fd/runtime/AppInfo;
08-26 05:32:52.865 1630-1630/com.ozuf.poster D/dalvikvm: VFY: replacing opcode 0x62 at 0x0016
08-26 05:32:52.865 1630-1630/com.ozuf.poster W/dalvikvm: VFY: unable to resolve static field 19 (applicationClass) in Lcom/android/tools/fd/runtime/AppInfo;
08-26 05:32:52.865 1630-1630/com.ozuf.poster D/dalvikvm: VFY: replacing opcode 0x62 at 0x0001
08-26 05:32:52.869 1630-1630/com.ozuf.poster W/dalvikvm: VFY: unable to resolve static field 22 (usingApkSplits) in Lcom/android/tools/fd/runtime/AppInfo;
08-26 05:32:52.869 1630-1630/com.ozuf.poster D/dalvikvm: VFY: replacing opcode 0x63 at 0x0000
08-26 05:32:52.869 1630-1630/com.ozuf.poster W/dalvikvm: VFY: unable to resolve static field 22 (usingApkSplits) in Lcom/android/tools/fd/runtime/AppInfo;
08-26 05:32:52.869 1630-1630/com.ozuf.poster D/dalvikvm: VFY: replacing opcode 0x63 at 0x0002
08-26 05:32:52.869 1630-1630/com.ozuf.poster I/dalvikvm: DexOpt: unable to optimize static field ref 0x0013 at 0x1b in Lcom/android/tools/fd/runtime/BootstrapApplication;.<init>
08-26 05:32:52.869 1630-1630/com.ozuf.poster I/dalvikvm: DexOpt: unable to optimize static field ref 0x0013 at 0x1d in Lcom/android/tools/fd/runtime/BootstrapApplication;.createRealApplication
08-26 05:32:52.869 1630-1630/com.ozuf.poster I/dalvikvm: DexOpt: unable to optimize static field ref 0x0013 at 0x2a in Lcom/android/tools/fd/runtime/BootstrapApplication;.createRealApplication
08-26 05:32:52.869 1630-1630/com.ozuf.poster I/dalvikvm: DexOpt: unable to optimize static field ref 0x0014 at 0x15 in Lcom/android/tools/fd/runtime/BootstrapApplication;.onCreate
08-26 05:32:52.873 1630-1630/com.ozuf.poster I/dalvikvm: DexOpt: unable to optimize static field ref 0x0014 at 0x45 in Lcom/android/tools/fd/runtime/BootstrapApplication;.onCreate
08-26 05:32:52.873 1630-1630/com.ozuf.poster I/dalvikvm: DexOpt: unable to optimize static field ref 0x0014 at 0x6f in Lcom/android/tools/fd/runtime/BootstrapApplication;.onCreate
08-26 05:32:52.873 1630-1630/com.ozuf.poster I/dalvikvm: DexOpt: unable to optimize static field ref 0x0014 at 0x99 in Lcom/android/tools/fd/runtime/BootstrapApplication;.onCreate
08-26 05:32:52.873 1630-1630/com.ozuf.poster D/AndroidRuntime: Shutting down VM
08-26 05:32:52.873 1630-1630/com.ozuf.poster W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0xa4cacb20)
08-26 05:32:52.873 1630-1630/com.ozuf.poster E/AndroidRuntime: FATAL EXCEPTION: main
                                                                   Process: com.ozuf.poster, PID: 1630
                                                                   java.lang.NoClassDefFoundError: com.android.tools.fd.runtime.AppInfo
                                                                       at com.android.tools.fd.runtime.BootstrapApplication.attachBaseContext(BootstrapApplication.java:231)
                                                                       at android.app.Application.attach(Application.java:181)
                                                                       at android.app.Instrumentation.newApplication(Instrumentation.java:991)
                                                                       at android.app.Instrumentation.newApplication(Instrumentation.java:975)
                                                                       at android.app.LoadedApk.makeApplication(LoadedApk.java:502)
                                                                       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4301)
                                                                       at android.app.ActivityThread.access$1500(ActivityThread.java:135)
                                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
                                                                       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.invokeNative(Native Method)
                                                                       at java.lang.reflect.Method.invoke(Method.java:515)
                                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
                                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
                                                                       at dalvik.system.NativeStart.main(Native Method)
08-26 05:33:28.765 1630-1630/com.ozuf.poster I/Process: Sending signal. PID: 1630 SIG: 9

Project gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.3'
        classpath 'com.google.gms:google-services:3.0.0'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}


dependencies {
}

App gradle

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

apply plugin: 'android-apt'

android {
    compileSdkVersion 23
    buildToolsVersion '24.0.0'
    defaultConfig {
        applicationId "com.ozuf.poster"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 17
        versionName '0.17.5 Alpha'
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}


dependencies {
    compile project(':volley')
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    apt 'com.jakewharton:butterknife-compiler:8.2.1'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') {
        transitive = true;
    }
    compile('com.crashlytics.sdk.android:answers:1.3.9@aar') {
        transitive = true;
    }
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    compile 'org.jsoup:jsoup:1.9.2'
    compile 'com.android.support:support-v4:23.4.0'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.android.support:cardview-v7:23.4.0'
    compile 'com.android.support:recyclerview-v7:23.4.0'
    compile 'com.google.firebase:firebase-core:9.0.2'
    compile 'com.google.firebase:firebase-ads:9.0.2'
    compile 'com.jakewharton:butterknife:8.2.1'
    compile 'org.greenrobot:eventbus:3.0.0'
    compile 'com.android.support:customtabs:23.4.0'
} 

apply plugin: 'com.google.gms.google-services'

的AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.ozuf.poster">

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_LOGS"/>

    <application
        android:name=".activities.MyApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <receiver
            android:name=".receivers.MyReceiver"
            android:enabled="true">
        </receiver>

        <provider
            android:name=".utils.SuggestionProvider"
            android:authorities="com.ozuf.poster.utils.SuggestionProvider"/>

        <activity
            android:name=".activities.SplashActivity"
            android:theme="@style/SplashTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW"/>

                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>

                <data
                    android:host="www.ozuflink.com"
                    android:pathPrefix="/20"
                    android:scheme="http"/>
                <data
                    android:host="www.ozuflink.com"
                    android:pathPrefix="/20"
                    android:scheme="https"/>
                <data
                    android:host="ozuflink.com"
                    android:pathPrefix="/20"
                    android:scheme="http"/>
                <data
                    android:host="ozuflink.com"
                    android:pathPrefix="/20"
                    android:scheme="https"/>
                <data
                    android:host="www.ozuflink.com"
                    android:pathPrefix="/rocks"
                    android:scheme="http"/>
                <data
                    android:host="www.ozuflink.com"
                    android:pathPrefix="/rocks"
                    android:scheme="https"/>
                <data
                    android:host="ozuflink.com"
                    android:pathPrefix="/rocks"
                    android:scheme="http"/>
                <data
                    android:host="ozuflink.com"
                    android:pathPrefix="/rocks"
                    android:scheme="https"/>
            </intent-filter>
        </activity>
        <activity
            android:name=".activities.MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar"
            android:windowSoftInputMode="stateHidden">
        </activity>
        <activity
            android:name=".activities.PostActivity"
            android:label="@string/app_name"
            android:parentActivityName=".activities.MainActivity"
            android:windowSoftInputMode="stateHidden">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.ozuf.poster.activities.MainActivity"/>
        </activity>
        <activity
            android:name=".activities.SettingsActivity"
            android:label="@string/title_activity_settings"
            android:parentActivityName=".activities.MainActivity"
            android:theme="@style/AppTheme">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.ozuf.poster.activities.MainActivity"/>

            <intent-filter>
                <action android:name="android.intent.action.MANAGE_NETWORK_USAGE"/>

                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
        </activity>
        <activity
            android:name=".activities.AboutActivity"
            android:label="@string/title_activity_about"
            android:parentActivityName=".activities.MainActivity"
            android:theme="@style/AppTheme">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.ozuf.poster.activities.MainActivity"/>
        </activity>
        <activity
            android:name=".activities.StoreActivity"
            android:label="@string/title_activity_store"
            android:theme="@style/StoreTheme">
        </activity>
        <activity
            android:name=".activities.SearchResultsActivity"
            android:label="@string/app_name"
            android:launchMode="singleTop"
            android:theme="@style/AppTheme">
            <intent-filter>
                <action android:name="android.intent.action.SEARCH"/>
            </intent-filter>

            <meta-data
                android:name="android.app.searchable"
                android:resource="@xml/searchable"/>
        </activity>
        <activity
            android:name=".activities.QSettingsActivity"
            android:label="@string/title_activity_qsettings">
        </activity>
        <activity
            android:name=".activities.fSettingsActivity"
            android:label="@string/title_activity_f_settings">
        </activity>
    </application>

</manifest>

请您知道任何解决方案吗?

2 个答案:

答案 0 :(得分:1)

听起来像是一个即时运行问题。

请停用即时运行并尝试清理构建。

应该有效

答案 1 :(得分:0)

在你的gradle中重新启动库

compile 'com.android.support:support-v4: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:24.0.0-alpha1'
compile 'com.android.support:appcompat-v7:24.0.0-alpha1'
compile 'com.android.support:design:24.0.0-alpha1'