在我的Android应用程序中找不到类的类

时间:2017-01-27 07:11:02

标签: java android splash-screen classnotfoundexception

我已经看到许多与此相似的问题并尝试了几乎所有的解决方案。但没有任何工作。在Android模拟器应用程序上运行良好,但是当我在我的设备中尝试它会抛出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>

我想说明这款应用在模拟器和移动设备上运行良好。但是导致我在我的设备上测试的问题[但它在同一台设备上工作了几天]。这可能是因为我的设备可能存在某些问题。

2 个答案:

答案 0 :(得分:1)

许多设备无法使用调试模式进行即时运行,因此请按照以下步骤进行操作

禁用即时运行 -

  1. 单击文件菜单中的设置并搜索即时运行并取消选中所有复选框并再次构建apk。
  2. enter image description here

    在调试模式下也禁用proguard。

    debug {
                minifyEnabled false
                useProguard false 
    
            }
    

答案 1 :(得分:0)

禁用proguard并尝试

在您的app level 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"
    }
}