我的应用程序始终崩溃:无法实例化活动

时间:2014-08-08 08:38:50

标签: android path crash

帮助!当我运行我的应用程序时它会崩溃并给我那个

    java.lang.RuntimeException: Unable to instantiate activity
  ComponentInfo{com.spinhaxo.consoleapp/com.spinhaxo.consoleapp.Console}:
  java.lang.ClassNotFoundException: Didn't find class 
  "com.spinhaxo.consoleapp.Console" on path: /data/app/com.spinhaxo.consoleapp-1.apk
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2171)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2295)
  at android.app.ActivityThread.access$700(ActivityThread.java:150)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:176)
  at android.app.ActivityThread.main(ActivityThread.java:5279)
  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:1102)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
  at dalvik.system.NativeStart.main(Native Method)
  Caused by: java.lang.ClassNotFoundException: Didn't find class   
  "com.spinhaxo.consoleapp.Console" on path: /data/app/com.spinhaxo.consoleapp-1.apk
  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
  at android.app.Instrumentation.newActivity(Instrumentation.java:1071)
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)

我不知道该怎么做:(在我的Pc上的虚拟设备上工作正常,但在我的手机和平板电脑上崩溃......

我的Manifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.spinhaxo.consoleapp"
android:versionCode="5"
android:versionName="2.1.0" >

<uses-sdk 
    android:minSdkVersion="8" 
    android:targetSdkVersion="11" />

<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>

<application
    android:icon="@drawable/icon"
    android:label="@string/app_name" >
     <activity
        android:label="@string/app_name"
        android:name=".Console"
            >
        <intent-filter >
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name="com.startapp.android.publish.list3d.List3DActivity"
      android:theme="@android:style/Theme" />

<activity android:name="com.startapp.android.publish.AppWallActivity"
      android:theme="@android:style/Theme.Translucent"
      android:configChanges="orientation|keyboardHidden|screenSize" />

    <activity
        android:icon="@drawable/frages"
        android:label="BatteryInfo"
        android:name=".BatteryInfo"
        android:theme="@android:style/Theme.Dialog">
        <intent-filter >
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

我的MainActivity的onCreate(Consolejar):

package com.spinhaxo.console;

import android.app.*;
import android.view.*;
import android.widget.TextView;
import android.content.DialogInterface;
import android.widget.Toast;
import android.view.Menu;
import android.net.wifi.*;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.os.BatteryManager;
import android.os.Bundle;
import android.os.Environment;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import android.view.View;
import android.widget.EditText;

import java.io.BufferedInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;

import com.spinhaxo.consoleapp.R;
import com.startapp.android.publish.StartAppAd;
import com.startapp.android.publish.StartAppAd.AdMode;
import com.startapp.android.publish.StartAppSDK;
import com.startapp.android.publish.splash.SplashConfig;
import com.startapp.*;

import android.app.Dialog;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.util.Log;

import com.google.analytics.tracking.android.EasyTracker;
import com.google.analytics.tracking.android.Fields;
import com.google.analytics.tracking.android.GoogleAnalytics;
import com.google.analytics.tracking.android.MapBuilder;
import com.google.analytics.tracking.android.Tracker;




public class Console extends Activity 
{
private static Context context;
EditText console;
String folderPath;
File folder;
TextView output, stat_set, stat_devset, Zwischenablage_set;
private WifiManager wifiManager; 
TextView invText, invtext2, invtext3, invtext4;
public static final int DIALOG_DOWNLOAD_PROGRESS = 0;
private ProgressDialog mProgressDialog;

String FILENAME = "Output.console";
String FILENAMEset = "Set_Autosave.set";
String FILENAMEdevset = "Set_DeveloperView.set";
String FileDownload = "Minecraft Pe.apk";

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{


    super.onCreate(savedInstanceState);
    StartAppSDK.init(this, "108083436", "208381016", false);
    setContentView(R.layout.main);
    StartAppAd.showSplash(this, savedInstanceState, 
             new SplashConfig()
                    .setTheme(SplashConfig.Theme.OCEAN)
                    .setCustomScreen(R.layout.splash)
        );



    Zwischenablage_set = (TextView) findViewById(R.id.zwischenablage);
    stat_set = (TextView) findViewById(R.id.stat_set);
    stat_devset = (TextView) findViewById(R.id.stat_devset);
    console = (EditText) findViewById(R.id.Console);
    output = (TextView) findViewById(R.id.output);
    invText = (TextView) findViewById(R.id.InvisibleText);
    invtext2 = (TextView) findViewById(R.id.InvisibleText2);
    invtext3 = (TextView) findViewById(R.id.InvisibleText3);
    GoogleAnalytics.getInstance(this).getTracker("UA-53616112-1");
    Tracker tracker = GoogleAnalytics.getInstance(this).getTracker("UA-53616112-1");

    HashMap<String, String> hitParameters = new HashMap<String, String>();
    hitParameters.put(Fields.HIT_TYPE, "appview");
    hitParameters.put(Fields.SCREEN_NAME, "Home Screen");

    tracker.send(hitParameters);


    loaddevset(invtext3);
    checkdevset();
    createDir();


    wifiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE);

    this.registerReceiver(this.batteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));

    String read_data = null;

    try {
        File myFile = new File("/sdcard/Console/"+FILENAME);  
        FileInputStream fis = new FileInputStream(myFile);  

        byte[] dataArray = new byte[fis.available()];
        while (fis.read(dataArray) != -1) {
            read_data = new String(dataArray);
        }
        fis.close();

        output.setText(read_data);
    } catch (FileNotFoundException e) {
    Toastmessage("Filenotfound");
        e.printStackTrace();
    } catch (IOException e) {
    Toastmessage("IOException");
        e.printStackTrace();
    }
    String vorheriges = output.getText().toString();
    output.setText(vorheriges +"\n[System] Starting Console...\n[System] fetching data... \n[System] Console ready to work!");
    loadset(invtext2);

我希望有人能帮忙......

1 个答案:

答案 0 :(得分:1)

您在清单和活动中使用了不同的包。您还有多个活动被设置为启动器,因此请删除

        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />

来自不是你主要活动的那个。

这是一个应该有效的示例清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.spinhaxo.console"
android:versionCode="5"
android:versionName="2.1.0" >

<uses-sdk 
    android:minSdkVersion="8" 
    android:targetSdkVersion="11" />

<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>

<application
    android:icon="@drawable/icon"
    android:label="@string/app_name" >
     <activity
        android:label="@string/app_name"
        android:name=".Console">
        <intent-filter >
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name="com.startapp.android.publish.list3d.List3DActivity"
      android:theme="@android:style/Theme" />

<activity android:name="com.startapp.android.publish.AppWallActivity"
      android:theme="@android:style/Theme.Translucent"
      android:configChanges="orientation|keyboardHidden|screenSize" />

    <activity
        android:icon="@drawable/frages"
        android:label="BatteryInfo"
        android:name=".BatteryInfo"
        android:theme="@android:style/Theme.Dialog">
    </activity>
</application>