簡體   English   中英

在我的android應用中找不到類異常

[英]Class not found exception in my android app

我已經看到許多與此類似的問題,並嘗試了幾乎所有解決方案。 但是沒有任何效果。 在android模擬器上,app運行良好,但是當我嘗試在設備上運行時,它將拋出java.lang.ClassNotFoundException:in.thoughtsmith.jobsmith.SplachScreenActivity。

  java.lang.RuntimeException: Unable to instantiate activity
   ComponentInfo{in.thoughtsmith.jobsmith/in.thoughtsmith.jobsmith.SplachScreenActivity}: java.lang.ClassNotFoundException: in.thoughtsmith.jobsmith.SplachScreenActivity
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2034)                                                                              
 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2143)
 at android.app.ActivityThread.access$700(ActivityThread.java:140)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
 at android.os.Handler.dispatchMessage(Handler.java:99)
 at android.os.Looper.loop(Looper.java:174)
 at android.app.ActivityThread.main(ActivityThread.java:4952)
 at java.lang.reflect.Method.invokeNative(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:511)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
 at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.ClassNotFoundException: in.thoughtsmith.jobsmith.SplachScreenActivity
 at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
 at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2025)
 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2143) 
 at android.app.ActivityThread.access$700(ActivityThread.java:140) 
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237) 
 at android.os.Handler.dispatchMessage(Handler.java:99) 
 at android.os.Looper.loop(Looper.java:174) 
 at android.app.ActivityThread.main(ActivityThread.java:4952) 
 at java.lang.reflect.Method.invokeNative(Native Method) 
 at java.lang.reflect.Method.invoke(Method.java:511) 
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027) 
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794) 
 at dalvik.system.NativeStart.main(Native Method) 

我看過我的清單,一切看起來都很好

<application
    android:name="in.thoughtsmith.jobsmith.JobSmithApplication"
    android:allowBackup="true"
    android:icon="@drawable/logo_only"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <activity
        android:name="in.thoughtsmith.jobsmith.SplachScreenActivity"
        android:noHistory="true"
        android:theme="@android:style/Theme.Light.NoTitleBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="in.thoughtsmith.jobsmith.MapsActivity"
        android:label="@string/title_activity_maps" />
    <activity android:name="in.thoughtsmith.jobsmith.JobSearchResultActivity" />
    <activity
        android:name="in.thoughtsmith.jobsmith.LoginActivity"
        />

    <service
        android:name="in.thoughtsmith.jobsmith.LocationCheckerService"
        android:enabled="true"
        android:exported="true" />

    <activity android:name="in.thoughtsmith.jobsmith.FusedApiTestActivity" />
    <activity android:name="in.thoughtsmith.jobsmith.ProfileUpdateActivity"></activity>
</application>

我想明確指出,此應用在模擬器和移動設備中均能正常運行。 但是會導致我在其中進行測試的設備上出現問題[但是幾天前在同一設備上工作了]。 我的設備可能會帶點東西嗎?

許多設備無法在調試模式下即時運行,因此請執行以下步驟

禁用即時運行-

  1. 在文件菜單中單擊設置,然后搜索即時運行並取消選中所有復選框,然后再次構建apk。

在此處輸入圖片說明

還要在調試模式下禁用proguard。

debug {
            minifyEnabled false
            useProguard false 

        }

禁用proguard並嘗試

在您的應用級別的build.gradle文件中,

android {

    compileSdkVersion 25
    buildToolsVersion '25.0.0'

    defaultConfig {
        applicationId "in.thoughtsmith.jobsmith"
        minSdkVersion 21
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }

    buildTypes {
        debug {
            minifyEnabled false
            useProguard false <-------------------------------
            applicationIdSuffix ".debug"
            versionNameSuffix "-debug"
        }
        release {
            minifyEnabled true
            useProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM