简体   繁体   中英

Unable to instantiate application java.lang.ClassNotFoundException

I am trying to run my app in device or emulator. But it's not even allowing to open the main activity. After installing, it throws this exception. I have checked almost every solution that are present on StackOverflow, but none of them is working. Efforts that I have made:

  1. Tried to run by removing application name from Manifest.xml
  2. Changed the Activity name with . as well as with the full path
  3. Made lots of changes in build path order and export.

I guess I have tried most of the solutions that are available on StackOverflow. Here is my Manifest.xml file

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="19" />
<supports-screens
    android:anyDensity="true"
    android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:xlargeScreens="true" />

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

    android:allowBackup="false"
    android:icon="@drawable/ic_launcher"
    android:theme="@drawable/android_bg"
    android:label="@string/app_name" >
    <activity
        android:name=".MainActivity"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="adjustPan"
        android:theme="@android:style/Theme.NoTitleBar"
        android:configChanges="keyboardHidden|orientation|screenSize" >
        <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" />
            <action android:name="android.intent.action.EDIT" />
            <action android:name="android.intent.action.PICK" />
            <action android:name="android.intent.action.GET_CONTENT" />

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

            <data android:host="*" />
            <data android:mimeType="application/octet-stream" />
            <data android:mimeType="application/ccsecure" />
            <data android:mimeType="document/ccsecure" />
            <data android:pathPattern=".*\\.ccsecure" />
            <data android:pathPattern=".*\\..*\\.ccsecure" />
            <data android:pathPattern=".*\\..*\\..*\\.ccsecure" />
            <data android:pathPattern=".*\\..*\\..*\\..*\\.ccsecure" />
            <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.ccsecure" />
            <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.ccsecure" />
            <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.ccsecure" />
            <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.ccsecure" />
            <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.ccsecure" />
            <data android:pathPattern=".*.ccsecure" />
            <data android:pathPattern=".*..*.ccsecure" />
            <data android:pathPattern=".*..*..*.ccsecure" />
            <data android:pathPattern=".*..*..*..*.ccsecure" />
            <data android:pathPattern=".*..*..*..*..*.ccsecure" />
            <data android:pathPattern=".*..*..*..*..*..*.ccsecure" />
            <data android:pathPattern=".*..*..*..*..*..*..*.ccsecure" />
            <data android:pathPattern=".*..*..*..*..*..*..*..*.ccsecure" />
            <data android:pathPattern=".*..*..*..*..*..*..*..*..*.ccsecure" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <action android:name="android.intent.action.EDIT" />
            <action android:name="android.intent.action.PICK" />
            <action android:name="android.intent.action.GET_CONTENT" />

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

            <data android:host="*" />
            <data android:mimeType="*/*" />
            <data android:mimeType="application/octet-stream" />
            <data android:mimeType="application/ccsecure" />
            <data android:mimeType="document/ccsecure" />
            <data android:scheme="file" />
            <data android:pathPattern=".*\\.ccsecure" />
            <data android:pathPattern=".*\\..*\\.ccsecure" />
            <data android:pathPattern=".*\\..*\\..*\\.ccsecure" />
            <data android:pathPattern=".*\\..*\\..*\\..*\\.ccsecure" />
            <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.ccsecure" />
            <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.ccsecure" />
            <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.ccsecure" />
            <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.ccsecure" />
            <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.ccsecure" />
            <data android:pathPattern=".*.ccsecure" />
            <data android:pathPattern=".*..*.ccsecure" />
            <data android:pathPattern=".*..*..*.ccsecure" />
            <data android:pathPattern=".*..*..*..*.ccsecure" />
            <data android:pathPattern=".*..*..*..*..*.ccsecure" />
            <data android:pathPattern=".*..*..*..*..*..*.ccsecure" />
            <data android:pathPattern=".*..*..*..*..*..*..*.ccsecure" />
            <data android:pathPattern=".*..*..*..*..*..*..*..*.ccsecure" />
            <data android:pathPattern=".*..*..*..*..*..*..*..*..*.ccsecure" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <action android:name="android.intent.action.EDIT" />
            <action android:name="android.intent.action.PICK" />
            <action android:name="android.intent.action.GET_CONTENT" />

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

            <data android:host="*" />
            <data android:mimeType="*/*" />
            <data android:mimeType="application/octet-stream" />
            <data android:mimeType="application/ccsecure" />
            <data android:mimeType="document/ccsecure" />
            <data android:scheme="content" />
            <data android:pathPattern=".*\\.ccsecure" />
            <data android:pathPattern=".*\\..*\\.ccsecure" />
            <data android:pathPattern=".*\\..*\\..*\\.ccsecure" />
            <data android:pathPattern=".*\\..*\\..*\\..*\\.ccsecure" />
            <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.ccsecure" />
            <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.ccsecure" />
            <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.ccsecure" />
            <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.ccsecure" />
            <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.ccsecure" />
            <data android:pathPattern=".*.ccsecure" />
            <data android:pathPattern=".*..*.ccsecure" />
            <data android:pathPattern=".*..*..*.ccsecure" />
            <data android:pathPattern=".*..*..*..*.ccsecure" />
            <data android:pathPattern=".*..*..*..*..*.ccsecure" />
            <data android:pathPattern=".*..*..*..*..*..*.ccsecure" />
            <data android:pathPattern=".*..*..*..*..*..*..*.ccsecure" />
            <data android:pathPattern=".*..*..*..*..*..*..*..*.ccsecure" />
            <data android:pathPattern=".*..*..*..*..*..*..*..*..*.ccsecure" />
        </intent-filter>
    </activity>
</application>

The most surprising thing for me is app is already uploaded by another developer on play store and it's working as expected if I download it from play store. But, it's not allowing me to open the MainActivity after downloading.

Thank you in advance. Your help will be highly appreciated.

Below is the error log from my logcat:

06-24 14:45:13.498: E/AndroidRuntime(19619): FATAL EXCEPTION: main
06-24 14:45:13.498: E/AndroidRuntime(19619): Process: com.cipher.Shield, PID: 19619
06-24 14:45:13.498: E/AndroidRuntime(19619): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.cipher.Shield/com.cipher.Shield.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.cipher.Shield.MainActivity" on path: DexPathList[[zip file "/data/app/com.cipher.Shield-10.apk"],nativeLibraryDirectories=[/data/app-lib/com.cipher.Shield-10, /vendor/lib, /system/lib]]
06-24 14:45:13.498: E/AndroidRuntime(19619):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2308)
06-24 14:45:13.498: E/AndroidRuntime(19619):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2495)
06-24 14:45:13.498: E/AndroidRuntime(19619):    at android.app.ActivityThread.access$900(ActivityThread.java:170)
06-24 14:45:13.498: E/AndroidRuntime(19619):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1304)
06-24 14:45:13.498: E/AndroidRuntime(19619):    at android.os.Handler.dispatchMessage(Handler.java:102)
06-24 14:45:13.498: E/AndroidRuntime(19619):    at android.os.Looper.loop(Looper.java:146)
06-24 14:45:13.498: E/AndroidRuntime(19619):    at android.app.ActivityThread.main(ActivityThread.java:5635)
06-24 14:45:13.498: E/AndroidRuntime(19619):    at java.lang.reflect.Method.invokeNative(Native Method)
06-24 14:45:13.498: E/AndroidRuntime(19619):    at java.lang.reflect.Method.invoke(Method.java:515)
06-24 14:45:13.498: E/AndroidRuntime(19619):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
06-24 14:45:13.498: E/AndroidRuntime(19619):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
06-24 14:45:13.498: E/AndroidRuntime(19619):    at dalvik.system.NativeStart.main(Native Method)
06-24 14:45:13.498: E/AndroidRuntime(19619): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.cipher.Shield.MainActivity" on path: DexPathList[[zip file "/data/app/com.cipher.Shield-10.apk"],nativeLibraryDirectories=[/data/app-lib/com.cipher.Shield-10, /vendor/lib, /system/lib]]

Eclipse does not include support libraries (i suppose you are using them) into dex file. So.

To fix this, right-click your project, properties, build path and go to export tab. There make sure "Android private libraries" are checked. A clean and rebuild should put you on track ...

And make sure you doesn't included both support-v4 and support-v7 . It will make a conflict.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM