Can't able to solve Class Not Found Exception

2019-09-16 08:59发布

问题:

I am trying to solve the error of class not found. I googling from last 2 weeks but cant solve this error.. I try all stackoverflow questions but cant help any to me.

06-18 17:42:32.171: E/AndroidRuntime(17161): FATAL EXCEPTION: main
06-18 17:42:32.171: E/AndroidRuntime(17161): java.lang.RuntimeException: Unableto      instantiate activity ComponentInfo{com.quickblox.sample.chat/com.quickblox.sample.chat.ui.activities.SplashActivity}: java.lang.ClassNotFoundException: Didn't find class "com.quickblox.sample.chat.ui.activities.SplashActivity" on path: /data/app/com.quickblox.sample.chat-1.apk
06-18 17:42:32.171: E/AndroidRuntime(17161):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2171)
06-18 17:42:32.171: E/AndroidRuntime(17161):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2295)
06-18 17:42:32.171: E/AndroidRuntime(17161):    at android.app.ActivityThread.access$700(ActivityThread.java:150)
06-18 17:42:32.171: E/AndroidRuntime(17161):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
06-18 17:42:32.171: E/AndroidRuntime(17161):    at android.os.Handler.dispatchMessage(Handler.java:99)
06-18 17:42:32.171: E/AndroidRuntime(17161):    at android.os.Looper.loop(Looper.java:137)
06-18 17:42:32.171: E/AndroidRuntime(17161):    at android.app.ActivityThread.main(ActivityThread.java:5279)
06-18 17:42:32.171: E/AndroidRuntime(17161):    at java.lang.reflect.Method.invokeNative(Native Method)
06-18 17:42:32.171: E/AndroidRuntime(17161):    at java.lang.reflect.Method.invoke(Method.java:511)
06-18 17:42:32.171: E/AndroidRuntime(17161):    at   com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
06-18 17:42:32.171: E/AndroidRuntime(17161):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
06-18 17:42:32.171: E/AndroidRuntime(17161):    at dalvik.system.NativeStart.main(Native Method)
06-18 17:42:32.171: E/AndroidRuntime(17161): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.quickblox.sample.chat.ui.activities.SplashActivity" on path: /data/app/com.quickblox.sample.chat-1.apk
06-18 17:42:32.171: E/AndroidRuntime(17161):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
06-18 17:42:32.171: E/AndroidRuntime(17161):    at  java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-18 17:42:32.171: E/AndroidRuntime(17161):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-18 17:42:32.171: E/AndroidRuntime(17161):    at android.app.Instrumentation.newActivity(Instrumentation.java:1071)
06-18 17:42:32.171: E/AndroidRuntime(17161):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
06-18 17:42:32.171: E/AndroidRuntime(17161):    ... 11 more

Menifest File is a bellow.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.quickblox.sample.chat"
    android:versionCode="1"
    android:versionName="1.0">

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="19" />

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

    <application
        android:name=".App"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"

        android:theme="@style/AppTheme">
        <activity
            android:name=".ui.activities.SplashActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:label="@string/app_name"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.activities.MainActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:screenOrientation="portrait" />
        <activity
            android:name=".ui.activities.ChatActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="adjustResize" />
        <activity
            android:name=".ui.activities.LoginActivity"
            android:label="Login" />
        <activity
            android:name=".ui.activities.RegistrationActivity"
            android:label="Registration" />
    </application>

</manifest>

I add that Acitivity inside Manifest also

回答1:

Replace your package name with

package="com.quickblox.sample.chat.ui.activities"

and

<activity
            android:name=".SplashActivity"

  ..... 
  .....

thats it...



回答2:

Trying to solve the problem with the answer but after changing the package name , I had errors with import com.quickblox.sample.chat.R