无法实例化应用程序java.lang.ClassNotFoundException

时间:2015-06-24 21:37:51

标签: java android

我正在尝试在设备或模拟器中运行我的应用。但它甚至不允许打开主要活动。安装后,它会抛出此异常。我已经检查了StackOverflow上几乎所有的解决方案,但它们都没有工作。 我所做的努力:

  1. 尝试通过从Manifest.xml中删除应用程序名称来运行
  2. 更改了活动名称。以及完整路径
  3. 在构建路径顺序和导出中进行了大量更改。
  4. 我想我已经尝试过StackOverflow上可用的大部分解决方案。 这是我的Manifest.xml文件

    <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>
    

    对我来说最令人惊讶的是app已经被其他开发者在Play商店上传,如果我从Play商店下载它,它会按预期工作。但是,下载后它不允许我打开MainActivity。

    提前谢谢你。我们将非常感谢您的帮助。

    以下是我的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]]
    

1 个答案:

答案 0 :(得分:1)

Eclipse不将支持库(我想你正在使用它们)包含在dex文件中。如此。

  

要解决此问题,请右键单击项目,属性,构建路径并转到导出选项卡。确保&#34; Android私人图书馆&#34;检查。清洁和重建应该让你走上正轨......

并确保您不包括support-v4support-v7。它会发生冲突。