Android Studio运行时错误:使用引导类加载器找不到类

时间:2015-07-14 18:39:51

标签: java android

我是Android Studio新手,我一直试图运行我的应用程序" EV515"但它并没有在我的平板电脑上运行,而logcat向我显示以下消息:

引起:java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

到目前为止,我的 MainActivity

public class MainActivity extends Activity {

private final String TAG = "EV515";
private int SAMPLERATE;
private int energy;
private int amplitude;
private int buffer[];
private Button statusbutton;
private Button inputinfobutton;
private Button argsbutton;
private Button loadbutton;
private Button recbutton;
private Button runbutton;
private Button plotbutton;
private Button resetbutton;
private TextView status;
private TextView info;
private TextView args;
private float time = 0.0F;
private double elapsed = 0.0D;
private String filename;
private String filepath;
private double F0MIN;
private double F0MAX;
private double FRAMELENGTH;
private double TIMESTEP;
private double EVTHREADS;
private double PTHR1;
private double FFTTHREADS;
private double FFTPOWER;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.menu.menu_main);
    ActionBar actionBar = getActionBar();
    actionBar.setBackgroundDrawable(new ColorDrawable(Color.BLUE));
    actionBar.show();
} // when the app opens

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return super.onCreateOptionsMenu(menu);
} // inflates the action bar (menu)

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    Intent intent;
    switch (item.getItemId()) {
        case R.id.action_settings: // when settings button is clicked
            intent = new Intent(this, SettingsActivity.class);
            return true;
        case R.id.action_information: // when info button is clicked
            intent = new Intent(this, InfoActivity.class);
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
} // assigns tasks to the buttons on the actions bars

protected void onStart() {
  super.onStart();
    SharedPreferences EVSettings = this.getSharedPreferences("ev_settings", 0);
    if(EVSettings.getBoolean("usedefaults", true)) {
        this.F0MIN = 50.0D;
        this.F0MAX = 600.0D;
        this.FRAMELENGTH = 0.06D;
        this.TIMESTEP = 0.01D;
        this.PTHR1 = 2.0D;
    } else {
        this.F0MIN = Double.parseDouble(EVSettings.getString("f0min", "50"));
        this.F0MAX = Double.parseDouble(EVSettings.getString("f0max", "600"));
        this.FRAMELENGTH = Double.parseDouble(EVSettings.getString("framelength", "0.06"));
        this.TIMESTEP = Double.parseDouble(EVSettings.getString("timestep", "0.01"));
        this.PTHR1 = Double.parseDouble(EVSettings.getString("pthr1", "2"));
    }

    if(EVSettings.getBoolean("usebest", true)) {
        double intent = (double)Runtime.getRuntime().availableProcessors();
        this.EVTHREADS = 2.0D * Math.floor(Math.sqrt(intent));
        this.FFTTHREADS = 2.0D * Math.floor(2.0D * intent / this.EVTHREADS);
        this.FFTPOWER = 13.0D;
    } else {
        this.EVTHREADS = Double.parseDouble(EVSettings.getString("evThreads", "2"));
        this.FFTTHREADS = Double.parseDouble(EVSettings.getString("fftThreads", "2"));
        this.FFTPOWER = Double.parseDouble(EVSettings.getString("fftpower", "13"));
    }

    this.args.setText("f0 Min = " + String.format("%.0f", new Object[]{Double.valueOf(this.F0MIN)}) + " Hz\n" + "f0 Max = "
            + String.format("%.0f", new Object[]{Double.valueOf(this.F0MAX)}) + " Hz\n" + "Frame Length = "
            + String.format("%.2f", new Object[]{Double.valueOf(this.FRAMELENGTH)}) + " seconds\n" + "Time Step = "
            + String.format("%.2f", new Object[]{Double.valueOf(this.TIMESTEP)}) + " seconds\n" + "Pthr1 = "
            + String.format("%.2f", new Object[]{Double.valueOf(this.PTHR1)}) + "\n" + "Number of EV Threads = "
            + String.format("%.0f", new Object[]{Double.valueOf(this.EVTHREADS)}) + "\n" + "Number of FFT Threads = "
            + String.format("%.0f", new Object[]{Double.valueOf(this.FFTTHREADS)}) + "\n" + "Total Number of Threads = "
            + String.format("%.0f", new Object[]{Double.valueOf(this.EVTHREADS * this.FFTTHREADS)}) + "\n" + "FFT Size = "
            + String.format("%.0f", new Object[]{Double.valueOf(Math.pow(2.0D, this.FFTPOWER))}) + "\n");
    if(this.time != 0.0F & this.FRAMELENGTH > (double)this.time) {
        Toast.makeText(this, "Error: EV frame length argument is greater than audio total duration, please choose " +
                "a value smaller than " + String.format("%.2f", new Object[]{Float.valueOf(this.time)})
                + " seconds.", 1).show();
        Intent intent1 = new Intent(this, SettingsActivity.class);
        this.startActivity(intent1);
    }

} // sets the preferences according to the user's inputs in "settings activity"

protected void onDestroy() {
    super.onStop();
    File tempfile = new File(this.getCacheDir() + "/temp.pcm");
    File inputfile = new File(this.getCacheDir() + "/temp.txt");

    if(tempfile.exists()) {
        tempfile.delete();
    }

    if(inputfile.exists()) {
        inputfile.delete();
    }
} // deletes the temp text files when the app is stopped

public void onClick_load(View view) {
    Intent i = new Intent(this, FileBrowser.class);
    this.startActivityForResult(i, 1);
} // opens FileBrowser when LOAD button is clicked

public void onClick_rec(View view) {
    Intent i = new Intent(this, RecordActivity.class);
    this.startActivityForResult(i, 1);
} // opens RecordActivity when RECORD button is clicked
}

这是我的 logcat

07-14 14:37:37.329    4900-4900/? I/art﹕ Late-enabling -Xcheck:jni
07-14 14:37:37.356    4900-4910/? I/art﹕ Debugger is no longer active
07-14 14:37:37.414    4900-4900/? D/AndroidRuntime﹕ Shutting down VM
    --------- beginning of crash
07-14 14:37:37.417    4900-4900/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: edu.rochester.ece.ev515, PID: 4900
    java.lang.RuntimeException: Unable to start activity ComponentInfo{edu.rochester.ece.ev515/edu.rochester.ece.ev515.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class menu
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
            at android.app.ActivityThread.access$800(ActivityThread.java:151)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5254)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
     Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class menu
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:378)
            at android.app.Activity.setContentView(Activity.java:2145)
            at edu.rochester.ece.ev515.MainActivity.onCreate(MainActivity.java:85)
            at android.app.Activity.performCreate(Activity.java:5990)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
            at android.app.ActivityThread.access$800(ActivityThread.java:151)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5254)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.menu" on path: DexPathList[[zip file "/data/app/edu.rochester.ece.ev515-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
            at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
            at android.view.LayoutInflater.createView(LayoutInflater.java:571)
            at android.view.LayoutInflater.onCreateView(LayoutInflater.java:665)
            at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:65)
            at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:378)
            at android.app.Activity.setContentView(Activity.java:2145)
            at edu.rochester.ece.ev515.MainActivity.onCreate(MainActivity.java:85)
            at android.app.Activity.performCreate(Activity.java:5990)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
            at android.app.ActivityThread.access$800(ActivityThread.java:151)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5254)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
    Suppressed: java.lang.ClassNotFoundException: android.view.menu
            at java.lang.Class.classForName(Native Method)
            at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
            at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
            ... 25 more
     Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

最后,我的清单

<?xml version="1.0" encoding="utf-8"?>

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

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

    <activity
        android:name=".FileBrowser"
        android:label="@string/title_file_chooser" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

    <activity
        android:name=".InfoActivity"
        android:label="@string/action_info" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

    <activity
        android:name=".RecordActivity"
        android:label="@string/title_activity_record" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

    <activity
        android:name=".SettingsActivity"
        android:label="@string/action_settings" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

0 个答案:

没有答案