Android穿" BoxInsetLayout#34;,致命异常

时间:2015-04-05 14:12:15

标签: android eclipse exception inflate-exception

我在日食中开发了磨损(齿轮现场),我使用加速度计。但我有一个问题。我添加了库“wearable-1.0.0”。 我在activity_main.xml中使用“BoxInsetLayout”代码。当我检查手表中的布局时,发生错误(不幸的是,应用程序已停止)。 我该如何解决?帮助..

附上了下面的logcat。

04-05 22:55:03.958: E/AndroidRuntime(2128): FATAL EXCEPTION: main
04-05 22:55:03.958: E/AndroidRuntime(2128): Process: com.abc.wear, PID: 2128
04-05 22:55:03.958: E/AndroidRuntime(2128): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.abc.wear/com.abc.wear.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.wearable.view.BoxInsetLayout
04-05 22:55:03.958: E/AndroidRuntime(2128):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
04-05 22:55:03.958: E/AndroidRuntime(2128):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
04-05 22:55:03.958: E/AndroidRuntime(2128):     at android.app.ActivityThread.access$800(ActivityThread.java:144)
04-05 22:55:03.958: E/AndroidRuntime(2128):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
04-05 22:55:03.958: E/AndroidRuntime(2128):     at android.os.Handler.dispatchMessage(Handler.java:102)
04-05 22:55:03.958: E/AndroidRuntime(2128):     at android.os.Looper.loop(Looper.java:135)
04-05 22:55:03.958: E/AndroidRuntime(2128):     at android.app.ActivityThread.main(ActivityThread.java:5221)
04-05 22:55:03.958: E/AndroidRuntime(2128):     at java.lang.reflect.Method.invoke(Native Method)
04-05 22:55:03.958: E/AndroidRuntime(2128):     at java.lang.reflect.Method.invoke(Method.java:372)
04-05 22:55:03.958: E/AndroidRuntime(2128):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
04-05 22:55:03.958: E/AndroidRuntime(2128):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
04-05 22:55:03.958: E/AndroidRuntime(2128): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.wearable.view.BoxInsetLayout
04-05 22:55:03.958: E/AndroidRuntime(2128):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
04-05 22:55:03.958: E/AndroidRuntime(2128):     at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
04-05 22:55:03.958: E/AndroidRuntime(2128):     at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
04-05 22:55:03.958: E/AndroidRuntime(2128):     at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
04-05 22:55:03.958: E/AndroidRuntime(2128):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:377)
04-05 22:55:03.958: E/AndroidRuntime(2128):     at android.app.Activity.setContentView(Activity.java:2144)
04-05 22:55:03.958: E/AndroidRuntime(2128):     at com.abc.wear.MainActivity.onCreate(MainActivity.java:43)
04-05 22:55:03.958: E/AndroidRuntime(2128):     at android.app.Activity.performCreate(Activity.java:5943)
04-05 22:55:03.958: E/AndroidRuntime(2128):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
04-05 22:55:03.958: E/AndroidRuntime(2128):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
04-05 22:55:03.958: E/AndroidRuntime(2128):     ... 10 more
04-05 22:55:03.958: E/AndroidRuntime(2128): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.wearable.view.BoxInsetLayout" on path: DexPathList[[zip file "/data/app/com.abc.wear-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
04-05 22:55:03.958: E/AndroidRuntime(2128):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
04-05 22:55:03.958: E/AndroidRuntime(2128):     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
04-05 22:55:03.958: E/AndroidRuntime(2128):     at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
04-05 22:55:03.958: E/AndroidRuntime(2128):     at android.view.LayoutInflater.createView(LayoutInflater.java:571)
04-05 22:55:03.958: E/AndroidRuntime(2128):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
04-05 22:55:03.958: E/AndroidRuntime(2128):     ... 19 more
04-05 22:55:03.958: E/AndroidRuntime(2128):     Suppressed: java.lang.ClassNotFoundException: android.support.wearable.view.BoxInsetLayout
04-05 22:55:03.958: E/AndroidRuntime(2128):         at java.lang.Class.classForName(Native Method)
04-05 22:55:03.958: E/AndroidRuntime(2128):         at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
04-05 22:55:03.958: E/AndroidRuntime(2128):         at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
04-05 22:55:03.958: E/AndroidRuntime(2128):         at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
04-05 22:55:03.958: E/AndroidRuntime(2128):         ... 22 more
04-05 22:55:03.958: E/AndroidRuntime(2128):     Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

附上我的代码'activity_main.xml'

<?xml version="1.0" encoding="utf-8"?>
<android.support.wearable.view.BoxInsetLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_height="match_parent"
    android:layout_width="match_parent">

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="10dp"
        android:id="@+id/box"
        app:layout_box="all">

    <TextView
        android:id="@+id/flag1"
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:gravity="center" />

     <Button
        android:id="@+id/start"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/main_btn"
        android:text="" />

    <TextView
        android:id="@+id/depth2"
        android:layout_width="fill_parent"
        android:layout_height="80dp"
        android:gravity="center"
        android:text="depth"
        android:textSize="60px" />

     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="40dp"
         android:gravity="center"
         android:orientation="horizontal" >

         <TextView
             android:id="@+id/depth1"
             android:layout_width="wrap_content"
             android:layout_height="match_parent"
             android:layout_weight="1"
             android:gravity="center_horizontal|center_vertical"
             android:text="Depth: "
             android:textSize="15sp" />

            <TextView
                android:id="@+id/depth3"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center_horizontal|center_vertical"
                android:text="00mm"
                android:textSize="25sp" />
     </LinearLayout>

     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="40dp"
         android:gravity="center"
         android:orientation="horizontal" >

         <TextView
             android:id="@+id/depth4"
             android:layout_width="wrap_content"
             android:layout_height="match_parent"
             android:layout_weight="1"
             android:gravity="center_horizontal|center_vertical"
             android:text="Rate: "
             android:textSize="15sp" />

         <TextView
             android:id="@+id/depth5"
             android:layout_width="wrap_content"
             android:layout_height="match_parent"
             android:layout_weight="1"
             android:gravity="center_horizontal|center_vertical"
             android:text="000/min"
             android:textSize="25sp" />

      </LinearLayout>

      </LinearLayout>



</android.support.wearable.view.BoxInsetLayout>

MainActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    View mainView = findViewById(R.id.box);
    mainView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {

        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            // TODO Auto-generated method stub
            if(insets.isRound()){
                Log.d(TAG,"Round screen");
            }
            else{
                Log.d(TAG,"Not found Round screen");
            }
            return insets;
        }
    });

...

0 个答案:

没有答案