Wit Ai for Android - 该应用程序崩溃

时间:2015-01-13 12:12:38

标签: java android wit.ai

好吧,我只想到尝试Android的Wit Ai,当我在手机上运行它时应用程序崩溃了。

所以这是我的代码,

布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context=".MyActivity">

    <fragment
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:name="ai.wit.eval.wit_eval.MyActivity$PlaceholderFragment"
        android:layout_centerHorizontal="true"
        tools:layout="@layout/wit_button"
        />

    <TextView
        android:id="@+id/txtText"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textStyle="italic"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="120dp"
        android:background="#e4e4e4"
        android:text="The spoken text will show up here"
        />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="220dp"
        android:text="The semantic results will show up here"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:id="@+id/jsonView"
        android:background="#e4e4e4"
        android:maxLines = "100"
        android:scrollbars = "vertical"
        />



</RelativeLayout>

MainActivity.java

 package com.wit;

import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.io.IOException;
import java.util.ArrayList;

import ai.wit.sdk.IWitListener;
import ai.wit.sdk.Wit;
import ai.wit.sdk.model.WitOutcome;


public class MainActivity extends ActionBarActivity implements IWitListener {

    Wit _wit;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        String accessToken = "ZO`enter code here`IUNDZJD4HZTHYU6GP4GENQFIKDH4BX";
        _wit = new Wit(accessToken, this);

    }


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

    @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.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    public void toggle(View v) {
        try {
            _wit.toggleListening();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void witDidGraspIntent(ArrayList<WitOutcome> witOutcomes, String messageId, Error error) {
        TextView jsonView = (TextView) findViewById(R.id.jsonView);
        jsonView.setMovementMethod(new ScrollingMovementMethod());
        Gson gson = new GsonBuilder().setPrettyPrinting().create();

        if (error != null) {
            jsonView.setText(error.getLocalizedMessage());
            return ;
        }
        String jsonOutput = gson.toJson(witOutcomes);
        jsonView.setText(jsonOutput);
        ((TextView) findViewById(R.id.txtText)).setText("Done!");
    }

    @Override
    public void witDidStartListening() {
        ((TextView) findViewById(R.id.txtText)).setText("Witting...");
    }

    @Override
    public void witDidStopListening() {
        ((TextView) findViewById(R.id.txtText)).setText("Processing...");
    }

    @Override
    public void witActivityDetectorStarted() {
        ((TextView) findViewById(R.id.txtText)).setText("Listening");
    }

    @Override
    public String witGenerateMessageId() {
        return null;
    }

    public static class PlaceholderFragment extends Fragment {
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
            // Inflate the layout for this fragment
            return inflater.inflate(R.layout.wit_button, container, false);
        }
    }

}

LOGCAT消息:

01-13 17:20:35.381: D/dalvikvm(2379): Late-enabling CheckJNI
01-13 17:20:35.466: E/dalvikvm(2379): Could not find class 'com.google.gson.GsonBuilder', referenced from method com.wit.MainActivity.witDidGraspIntent
01-13 17:20:35.466: W/dalvikvm(2379): VFY: unable to resolve new-instance 1468 (Lcom/google/gson/GsonBuilder;) in Lcom/wit/MainActivity;
01-13 17:20:35.466: D/dalvikvm(2379): VFY: replacing opcode 0x22 at 0x0011
01-13 17:20:35.468: D/dalvikvm(2379): DexOpt: unable to opt direct call 0x2efe at 0x13 in Lcom/wit/MainActivity;.witDidGraspIntent
01-13 17:20:35.514: I/dalvikvm(2379): Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted
01-13 17:20:35.514: W/dalvikvm(2379): VFY: unable to resolve virtual method 11425: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V
01-13 17:20:35.514: D/dalvikvm(2379): VFY: replacing opcode 0x6f at 0x0000
01-13 17:20:35.514: I/dalvikvm(2379): Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
01-13 17:20:35.514: W/dalvikvm(2379): VFY: unable to resolve virtual method 11431: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
01-13 17:20:35.514: D/dalvikvm(2379): VFY: replacing opcode 0x6f at 0x0000
01-13 17:20:35.515: I/dalvikvm(2379): Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
01-13 17:20:35.515: W/dalvikvm(2379): VFY: unable to resolve virtual method 9118: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V
01-13 17:20:35.515: D/dalvikvm(2379): VFY: replacing opcode 0x6e at 0x000e
01-13 17:20:35.521: I/dalvikvm(2379): Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
01-13 17:20:35.521: W/dalvikvm(2379): VFY: unable to resolve virtual method 441: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
01-13 17:20:35.521: D/dalvikvm(2379): VFY: replacing opcode 0x6e at 0x0002
01-13 17:20:35.522: I/dalvikvm(2379): Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
01-13 17:20:35.522: W/dalvikvm(2379): VFY: unable to resolve virtual method 463: Landroid/content/res/TypedArray;.getType (I)I
01-13 17:20:35.522: D/dalvikvm(2379): VFY: replacing opcode 0x6e at 0x0002
01-13 17:20:35.565: D/AndroidRuntime(2379): Shutting down VM
01-13 17:20:35.565: W/dalvikvm(2379): threadid=1: thread exiting with uncaught exception (group=0x41683d40)
01-13 17:20:35.571: E/AndroidRuntime(2379): FATAL EXCEPTION: main
01-13 17:20:35.571: E/AndroidRuntime(2379): Process: com.wit, PID: 2379
01-13 17:20:35.571: E/AndroidRuntime(2379): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.wit/com.wit.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
01-13 17:20:35.571: E/AndroidRuntime(2379):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2198)
01-13 17:20:35.571: E/AndroidRuntime(2379):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
01-13 17:20:35.571: E/AndroidRuntime(2379):     at android.app.ActivityThread.access$800(ActivityThread.java:139)
01-13 17:20:35.571: E/AndroidRuntime(2379):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
01-13 17:20:35.571: E/AndroidRuntime(2379):     at android.os.Handler.dispatchMessage(Handler.java:102)
01-13 17:20:35.571: E/AndroidRuntime(2379):     at android.os.Looper.loop(Looper.java:136)
01-13 17:20:35.571: E/AndroidRuntime(2379):     at android.app.ActivityThread.main(ActivityThread.java:5086)
01-13 17:20:35.571: E/AndroidRuntime(2379):     at java.lang.reflect.Method.invokeNative(Native Method)
01-13 17:20:35.571: E/AndroidRuntime(2379):     at java.lang.reflect.Method.invoke(Method.java:515)
01-13 17:20:35.571: E/AndroidRuntime(2379):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
01-13 17:20:35.571: E/AndroidRuntime(2379):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
01-13 17:20:35.571: E/AndroidRuntime(2379):     at dalvik.system.NativeStart.main(Native Method)
01-13 17:20:35.571: E/AndroidRuntime(2379): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
01-13 17:20:35.571: E/AndroidRuntime(2379):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
01-13 17:20:35.571: E/AndroidRuntime(2379):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
01-13 17:20:35.571: E/AndroidRuntime(2379):     at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
01-13 17:20:35.571: E/AndroidRuntime(2379):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
01-13 17:20:35.571: E/AndroidRuntime(2379):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
01-13 17:20:35.571: E/AndroidRuntime(2379):     at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:228)
01-13 17:20:35.571: E/AndroidRuntime(2379):     at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
01-13 17:20:35.571: E/AndroidRuntime(2379):     at com.wit.MainActivity.onCreate(MainActivity.java:32)
01-13 17:20:35.571: E/AndroidRuntime(2379):     at android.app.Activity.performCreate(Activity.java:5248)
01-13 17:20:35.571: E/AndroidRuntime(2379):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
01-13 17:20:35.571: E/AndroidRuntime(2379):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
01-13 17:20:35.571: E/AndroidRuntime(2379):     ... 11 more
01-13 17:20:35.571: E/AndroidRuntime(2379): Caused by: java.lang.IllegalArgumentException: Binary XML file line #11: Must specify unique android:id, android:tag, or have a parent with an id for ai.wit.eval.wit_eval.MyActivity$PlaceholderFragment
01-13 17:20:35.571: E/AndroidRuntime(2379):     at android.app.Activity.onCreateView(Activity.java:4776)
01-13 17:20:35.571: E/AndroidRuntime(2379):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
01-13 17:20:35.571: E/AndroidRuntime(2379):     ... 21 more
01-13 17:20:37.055: I/Process(2379): Sending signal. PID: 2379 SIG: 9
01-13 17:29:22.562: E/dalvikvm(3449): Could not find class 'com.google.gson.GsonBuilder', referenced from method com.wit.MainActivity.witDidGraspIntent
01-13 17:29:22.562: W/dalvikvm(3449): VFY: unable to resolve new-instance 1468 (Lcom/google/gson/GsonBuilder;) in Lcom/wit/MainActivity;
01-13 17:29:22.562: D/dalvikvm(3449): VFY: replacing opcode 0x22 at 0x0011
01-13 17:29:22.563: D/dalvikvm(3449): DexOpt: unable to opt direct call 0x2efe at 0x13 in Lcom/wit/MainActivity;.witDidGraspIntent
01-13 17:29:22.595: I/dalvikvm(3449): Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted
01-13 17:29:22.595: W/dalvikvm(3449): VFY: unable to resolve virtual method 11425: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V
01-13 17:29:22.595: D/dalvikvm(3449): VFY: replacing opcode 0x6f at 0x0000
01-13 17:29:22.596: I/dalvikvm(3449): Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
01-13 17:29:22.596: W/dalvikvm(3449): VFY: unable to resolve virtual method 11431: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
01-13 17:29:22.596: D/dalvikvm(3449): VFY: replacing opcode 0x6f at 0x0000
01-13 17:29:22.600: I/dalvikvm(3449): Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
01-13 17:29:22.600: W/dalvikvm(3449): VFY: unable to resolve virtual method 9118: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V
01-13 17:29:22.600: D/dalvikvm(3449): VFY: replacing opcode 0x6e at 0x000e
01-13 17:29:22.609: I/dalvikvm(3449): Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
01-13 17:29:22.609: W/dalvikvm(3449): VFY: unable to resolve virtual method 441: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
01-13 17:29:22.609: D/dalvikvm(3449): VFY: replacing opcode 0x6e at 0x0002
01-13 17:29:22.613: I/dalvikvm(3449): Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
01-13 17:29:22.613: W/dalvikvm(3449): VFY: unable to resolve virtual method 463: Landroid/content/res/TypedArray;.getType (I)I
01-13 17:29:22.613: D/dalvikvm(3449): VFY: replacing opcode 0x6e at 0x0002
01-13 17:29:22.638: D/AndroidRuntime(3449): Shutting down VM
01-13 17:29:22.639: W/dalvikvm(3449): threadid=1: thread exiting with uncaught exception (group=0x41683d40)
01-13 17:29:33.742: E/dalvikvm(3994): Could not find class 'com.google.gson.GsonBuilder', referenced from method com.wit.MainActivity.witDidGraspIntent
01-13 17:29:33.742: W/dalvikvm(3994): VFY: unable to resolve new-instance 1468 (Lcom/google/gson/GsonBuilder;) in Lcom/wit/MainActivity;
01-13 17:29:33.742: D/dalvikvm(3994): VFY: replacing opcode 0x22 at 0x0011
01-13 17:29:33.742: D/dalvikvm(3994): DexOpt: unable to opt direct call 0x2efe at 0x13 in Lcom/wit/MainActivity;.witDidGraspIntent
01-13 17:29:33.788: I/dalvikvm(3994): Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted
01-13 17:29:33.788: W/dalvikvm(3994): VFY: unable to resolve virtual method 11425: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V
01-13 17:29:33.788: D/dalvikvm(3994): VFY: replacing opcode 0x6f at 0x0000
01-13 17:29:33.789: I/dalvikvm(3994): Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
01-13 17:29:33.789: W/dalvikvm(3994): VFY: unable to resolve virtual method 11431: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
01-13 17:29:33.790: D/dalvikvm(3994): VFY: replacing opcode 0x6f at 0x0000
01-13 17:29:33.791: I/dalvikvm(3994): Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
01-13 17:29:33.791: W/dalvikvm(3994): VFY: unable to resolve virtual method 9118: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V
01-13 17:29:33.791: D/dalvikvm(3994): VFY: replacing opcode 0x6e at 0x000e
01-13 17:29:33.800: I/dalvikvm(3994): Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
01-13 17:29:33.801: W/dalvikvm(3994): VFY: unable to resolve virtual method 441: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
01-13 17:29:33.801: D/dalvikvm(3994): VFY: replacing opcode 0x6e at 0x0002
01-13 17:29:33.803: I/dalvikvm(3994): Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
01-13 17:29:33.804: W/dalvikvm(3994): VFY: unable to resolve virtual method 463: Landroid/content/res/TypedArray;.getType (I)I
01-13 17:29:33.804: D/dalvikvm(3994): VFY: replacing opcode 0x6e at 0x0002
01-13 17:29:33.845: D/AndroidRuntime(3994): Shutting down VM
01-13 17:29:33.845: W/dalvikvm(3994): threadid=1: thread exiting with uncaught exception (group=0x41683d40)
01-13 17:29:33.853: E/AndroidRuntime(3994): FATAL EXCEPTION: main
01-13 17:29:33.853: E/AndroidRuntime(3994): Process: com.wit, PID: 3994
01-13 17:29:33.853: E/AndroidRuntime(3994): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.wit/com.wit.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
01-13 17:29:33.853: E/AndroidRuntime(3994):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2198)
01-13 17:29:33.853: E/AndroidRuntime(3994):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
01-13 17:29:33.853: E/AndroidRuntime(3994):     at android.app.ActivityThread.access$800(ActivityThread.java:139)
01-13 17:29:33.853: E/AndroidRuntime(3994):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
01-13 17:29:33.853: E/AndroidRuntime(3994):     at android.os.Handler.dispatchMessage(Handler.java:102)
01-13 17:29:33.853: E/AndroidRuntime(3994):     at android.os.Looper.loop(Looper.java:136)
01-13 17:29:33.853: E/AndroidRuntime(3994):     at android.app.ActivityThread.main(ActivityThread.java:5086)
01-13 17:29:33.853: E/AndroidRuntime(3994):     at java.lang.reflect.Method.invokeNative(Native Method)
01-13 17:29:33.853: E/AndroidRuntime(3994):     at java.lang.reflect.Method.invoke(Method.java:515)
01-13 17:29:33.853: E/AndroidRuntime(3994):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
01-13 17:29:33.853: E/AndroidRuntime(3994):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
01-13 17:29:33.853: E/AndroidRuntime(3994):     at dalvik.system.NativeStart.main(Native Method)
01-13 17:29:33.853: E/AndroidRuntime(3994): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
01-13 17:29:33.853: E/AndroidRuntime(3994):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
01-13 17:29:33.853: E/AndroidRuntime(3994):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
01-13 17:29:33.853: E/AndroidRuntime(3994):     at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
01-13 17:29:33.853: E/AndroidRuntime(3994):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
01-13 17:29:33.853: E/AndroidRuntime(3994):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
01-13 17:29:33.853: E/AndroidRuntime(3994):     at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:228)
01-13 17:29:33.853: E/AndroidRuntime(3994):     at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
01-13 17:29:33.853: E/AndroidRuntime(3994):     at com.wit.MainActivity.onCreate(MainActivity.java:32)
01-13 17:29:33.853: E/AndroidRuntime(3994):     at android.app.Activity.performCreate(Activity.java:5248)
01-13 17:29:33.853: E/AndroidRuntime(3994):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
01-13 17:29:33.853: E/AndroidRuntime(3994):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
01-13 17:29:33.853: E/AndroidRuntime(3994):     ... 11 more
01-13 17:29:33.853: E/AndroidRuntime(3994): Caused by: java.lang.IllegalArgumentException: Binary XML file line #11: Must specify unique android:id, android:tag, or have a parent with an id for ai.wit.eval.wit_eval.MyActivity$PlaceholderFragment
01-13 17:29:33.853: E/AndroidRuntime(3994):     at android.app.Activity.onCreateView(Activity.java:4776)
01-13 17:29:33.853: E/AndroidRuntime(3994):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
01-13 17:29:33.853: E/AndroidRuntime(3994):     ... 21 more
01-13 17:34:24.137: E/dalvikvm(4632): Could not find class 'com.google.gson.GsonBuilder', referenced from method com.wit.MainActivity.witDidGraspIntent
01-13 17:34:24.137: W/dalvikvm(4632): VFY: unable to resolve new-instance 1468 (Lcom/google/gson/GsonBuilder;) in Lcom/wit/MainActivity;
01-13 17:34:24.137: D/dalvikvm(4632): VFY: replacing opcode 0x22 at 0x0011
01-13 17:34:24.137: D/dalvikvm(4632): DexOpt: unable to opt direct call 0x2efe at 0x13 in Lcom/wit/MainActivity;.witDidGraspIntent
01-13 17:34:24.186: I/dalvikvm(4632): Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted
01-13 17:34:24.186: W/dalvikvm(4632): VFY: unable to resolve virtual method 11425: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V
01-13 17:34:24.186: D/dalvikvm(4632): VFY: replacing opcode 0x6f at 0x0000
01-13 17:34:24.187: I/dalvikvm(4632): Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
01-13 17:34:24.187: W/dalvikvm(4632): VFY: unable to resolve virtual method 11431: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
01-13 17:34:24.187: D/dalvikvm(4632): VFY: replacing opcode 0x6f at 0x0000
01-13 17:34:24.189: I/dalvikvm(4632): Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
01-13 17:34:24.189: W/dalvikvm(4632): VFY: unable to resolve virtual method 9118: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V
01-13 17:34:24.189: D/dalvikvm(4632): VFY: replacing opcode 0x6e at 0x000e
01-13 17:34:24.206: I/dalvikvm(4632): Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
01-13 17:34:24.206: W/dalvikvm(4632): VFY: unable to resolve virtual method 441: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
01-13 17:34:24.207: D/dalvikvm(4632): VFY: replacing opcode 0x6e at 0x0002
01-13 17:34:24.208: I/dalvikvm(4632): Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
01-13 17:34:24.208: W/dalvikvm(4632): VFY: unable to resolve virtual method 463: Landroid/content/res/TypedArray;.getType (I)I
01-13 17:34:24.213: D/dalvikvm(4632): VFY: replacing opcode 0x6e at 0x0002
01-13 17:34:24.259: D/AndroidRuntime(4632): Shutting down VM
01-13 17:34:24.259: W/dalvikvm(4632): threadid=1: thread exiting with uncaught exception (group=0x41683d40)
01-13 17:34:24.273: E/AndroidRuntime(4632): FATAL EXCEPTION: main
01-13 17:34:24.273: E/AndroidRuntime(4632): Process: com.wit, PID: 4632
01-13 17:34:24.273: E/AndroidRuntime(4632): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.wit/com.wit.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
01-13 17:34:24.273: E/AndroidRuntime(4632):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2198)
01-13 17:34:24.273: E/AndroidRuntime(4632):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
01-13 17:34:24.273: E/AndroidRuntime(4632):     at android.app.ActivityThread.access$800(ActivityThread.java:139)
01-13 17:34:24.273: E/AndroidRuntime(4632):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
01-13 17:34:24.273: E/AndroidRuntime(4632):     at android.os.Handler.dispatchMessage(Handler.java:102)
01-13 17:34:24.273: E/AndroidRuntime(4632):     at android.os.Looper.loop(Looper.java:136)
01-13 17:34:24.273: E/AndroidRuntime(4632):     at android.app.ActivityThread.main(ActivityThread.java:5086)
01-13 17:34:24.273: E/AndroidRuntime(4632):     at java.lang.reflect.Method.invokeNative(Native Method)
01-13 17:34:24.273: E/AndroidRuntime(4632):     at java.lang.reflect.Method.invoke(Method.java:515)
01-13 17:34:24.273: E/AndroidRuntime(4632):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
01-13 17:34:24.273: E/AndroidRuntime(4632):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
01-13 17:34:24.273: E/AndroidRuntime(4632):     at dalvik.system.NativeStart.main(Native Method)
01-13 17:34:24.273: E/AndroidRuntime(4632): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
01-13 17:34:24.273: E/AndroidRuntime(4632):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
01-13 17:34:24.273: E/AndroidRuntime(4632):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
01-13 17:34:24.273: E/AndroidRuntime(4632):     at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
01-13 17:34:24.273: E/AndroidRuntime(4632):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
01-13 17:34:24.273: E/AndroidRuntime(4632):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
01-13 17:34:24.273: E/AndroidRuntime(4632):     at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:228)
01-13 17:34:24.273: E/AndroidRuntime(4632):     at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
01-13 17:34:24.273: E/AndroidRuntime(4632):     at com.wit.MainActivity.onCreate(MainActivity.java:32)
01-13 17:34:24.273: E/AndroidRuntime(4632):     at android.app.Activity.performCreate(Activity.java:5248)
01-13 17:34:24.273: E/AndroidRuntime(4632):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
01-13 17:34:24.273: E/AndroidRuntime(4632):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
01-13 17:34:24.273: E/AndroidRuntime(4632):     ... 11 more
01-13 17:34:24.273: E/AndroidRuntime(4632): Caused by: java.lang.IllegalArgumentException: Binary XML file line #11: Must specify unique android:id, android:tag, or have a parent with an id for ai.wit.eval.wit_eval.MyActivity$PlaceholderFragment
01-13 17:34:24.273: E/AndroidRuntime(4632):     at android.app.Activity.onCreateView(Activity.java:4776)
01-13 17:34:24.273: E/AndroidRuntime(4632):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
01-13 17:34:24.273: E/AndroidRuntime(4632):     ... 21 more

有人可以告诉我为什么应用程序崩溃了吗? 任何解决方案都会非常感激:)

1 个答案:

答案 0 :(得分:3)

Caused by: java.lang.IllegalArgumentException:
Binary XML file line #11:
Must specify unique android:id, android:tag, or have a parent with an id for ai.wit.eval.wit_eval.MyActivity$PlaceholderFragment

例如,将andoid:id="@+id/something"添加到布局XML中的fragment元素。


后续问题:

Caused by: android.app.Fragment$InstantiationException:
Unable to instantiate fragment ai.wit.eval.wit_eval.MyActivity$PlaceholderFragment: make sure class name exists, is public, and has an empty constructor that is public

您在布局XML中使用的包名称为ai.wit.eval.wit_eval,但在代码中您有com.wit。确保完整的类名一致。