我该如何解决这个错误? android.view.InflateException:二进制XML文件行#300

时间:2014-06-06 11:29:09

标签: android sdk

你好,我的所有活动都不会因为某些原因而开始,我很难搞清楚,它是一个简单的应用程序,它启动并显示这个布局,但我每次启动时都会遇到错误,我不知道为什么

06-06 12:22:36.918: E/AndroidRuntime(949): FATAL EXCEPTION: main
06-06 12:22:36.918: E/AndroidRuntime(949): java.lang.RuntimeException: Unable to start    activity ComponentInfo{com.portal.karmasutra/com.portal.karmasutra.MainActivity}:   android.view.InflateException: Binary XML file line #300: Error inflating class <unknown>
06-06 12:22:36.918: E/AndroidRuntime(949):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
06-06 12:22:36.918: E/AndroidRuntime(949):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
06-06 12:22:36.918: E/AndroidRuntime(949):  at android.app.ActivityThread.access$600(ActivityThread.java:122)
06-06 12:22:36.918: E/AndroidRuntime(949):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
06-06 12:22:36.918: E/AndroidRuntime(949):  at android.os.Handler.dispatchMessage(Handler.java:99)
06-06 12:22:36.918: E/AndroidRuntime(949):  at android.os.Looper.loop(Looper.java:137)
06-06 12:22:36.918: E/AndroidRuntime(949):  at android.app.ActivityThread.main(ActivityThread.java:4340)
06-06 12:22:36.918: E/AndroidRuntime(949):  at java.lang.reflect.Method.invokeNative(Native Method)
06-06 12:22:36.918: E/AndroidRuntime(949):  at java.lang.reflect.Method.invoke(Method.java:511)
06-06 12:22:36.918: E/AndroidRuntime(949):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-06 12:22:36.918: E/AndroidRuntime(949):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)


Activity:
  import android.app.Activity;
  import android.os.Bundle;


public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


}


}

activity_main.xml中

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.portal.karmasutra.MainActivity"
tools:ignore="MergeRootFrame" >

<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/logo"
            android:layout_width="100sp"
            android:layout_height="100sp"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="50sp"
            android:src="@drawable/logo" />

        <TextView
            android:id="@+id/title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_marginTop="10sp"
            android:text="Kama Sutra 18+"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <TextView
            android:id="@+id/description"
            android:layout_width="250sp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:gravity="center"
            android:text="@string/description"
            android:textAppearance="?android:attr/textAppearanceSmall" />

        <ImageView
            android:id="@+id/imageView50"
            android:layout_width="300sp"
            android:layout_height="300sp"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="10sp"
            android:src="@drawable/balletdancer" />

         <TextView
            android:id="@+id/textView50"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_marginTop="10sp"
            android:text="Ballet Dancer"
            android:textAppearance="?android:attr/textAppearanceMedium" />

          <ImageView
            android:id="@+id/imageView2"
            android:layout_width="300sp"
            android:layout_height="300sp"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="10sp"
            android:src="@drawable/butterchurner" />

         <TextView
            android:id="@+id/textView2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_marginTop="10sp"
            android:text="Butter Churner"
            android:textAppearance="?android:attr/textAppearanceMedium" />

          <ImageView
            android:id="@+id/imageView3"
            android:layout_width="300sp"
            android:layout_height="300sp"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="10sp"
            android:src="@drawable/closedforbusiness" />

         <TextView
            android:id="@+id/textView3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_marginTop="10sp"
            android:text="Closed For Business"
            android:textAppearance="?android:attr/textAppearanceMedium" />

          <ImageView
            android:id="@+id/imageView4"
            android:layout_width="300sp"
            android:layout_height="300sp"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="10sp"
            android:src="@drawable/corkscrew" />

         <TextView
            android:id="@+id/textView4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_marginTop="10sp"
            android:text="Corkscrew"
            android:textAppearance="?android:attr/textAppearanceMedium" />

          <ImageView
            android:id="@+id/imageView5"
            android:layout_width="300sp"
            android:layout_height="300sp"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="10sp"
            android:src="@drawable/cowboy" />

         <TextView
            android:id="@+id/textView5"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_marginTop="10sp"
            android:text="Cowboy"
            android:textAppearance="?android:attr/textAppearanceMedium" />

          <ImageView
            android:id="@+id/imageView6"
            android:layout_width="300sp"
            android:layout_height="300sp"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="10sp"
            android:src="@drawable/cowgirl" />

         <TextView
            android:id="@+id/textView6"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_marginTop="10sp"
            android:text="Cow Girl"
            android:textAppearance="?android:attr/textAppearanceMedium" />

          <ImageView
            android:id="@+id/imageView7"
            android:layout_width="300sp"
            android:layout_height="300sp"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="10sp"
            android:src="@drawable/cowgirlshelper" />

         <TextView
            android:id="@+id/textView7"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_marginTop="10sp"
            android:text="Cowgirls Helper"
            android:textAppearance="?android:attr/textAppearanceMedium" />

          <ImageView
            android:id="@+id/imageView8"
            android:layout_width="300sp"
            android:layout_height="300sp"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="10sp"
            android:src="@drawable/davidcopperfield" />

         <TextView
            android:id="@+id/textView8"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_marginTop="10sp"
            android:text="David Copperfield"
            android:textAppearance="?android:attr/textAppearanceMedium" />

          <ImageView
            android:id="@+id/imageView9"
            android:layout_width="300sp"
            android:layout_height="300sp"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="10sp"
            android:src="@drawable/doggiestyle" />

         <TextView
            android:id="@+id/textView9"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_marginTop="10sp"
            android:text="Doggie Style"
            android:textAppearance="?android:attr/textAppearanceMedium" />

          <ImageView
            android:id="@+id/imageView10"
            android:layout_width="300sp"
            android:layout_height="300sp"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="10sp"
            android:src="@drawable/faceoff" />

         <TextView
            android:id="@+id/textView10"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_marginTop="10sp"
            android:text="Face Off"
            android:textAppearance="?android:attr/textAppearanceMedium" />

          <ImageView
            android:id="@+id/imageView11"
            android:layout_width="300sp"
            android:layout_height="300sp"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="10sp"
            android:src="@drawable/faceoff2" />

         <TextView
            android:id="@+id/textView11"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_marginTop="10sp"
            android:text="Face Off 2"
            android:textAppearance="?android:attr/textAppearanceMedium" />

          <ImageView
            android:id="@+id/imageView12"
            android:layout_width="300sp"
            android:layout_height="300sp"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="10sp"
            android:src="@drawable/flatiron" />

         <TextView
            android:id="@+id/textView12"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_marginTop="10sp"
            android:text="Flat Iron"
            android:textAppearance="?android:attr/textAppearanceMedium" />

          <ImageView
            android:id="@+id/imageView13"
            android:layout_width="300sp"
            android:layout_height="300sp"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="10sp"
            android:src="@drawable/goldenarch" />

         <TextView
            android:id="@+id/textView13"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_marginTop="10sp"
            android:text="Golden Arch"
            android:textAppearance="?android:attr/textAppearanceMedium" />



    </LinearLayout>
</ScrollView>

</FrameLayout>

不明白为什么它不是一个不大的项目?

1 个答案:

答案 0 :(得分:0)

 I have changes in your img src only and set ic_launcher icon in each img src... and its         working fine.....so that mean problems is in your images of img src.....just take a look

<强>&GT; MainActivity.java

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

 public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

@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;
}

}

  

<强> activity_main.xml中

  <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.portal.karmasutra.MainActivity"
    tools:ignore="MergeRootFrame" >

<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/logo"
        android:layout_width="100sp"
        android:layout_height="100sp"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="50sp"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_marginTop="10sp"
        android:text="Kama Sutra 18+"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/description"
        android:layout_width="250sp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center"
        android:text="description"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <ImageView
        android:id="@+id/imageView50"
        android:layout_width="300sp"
        android:layout_height="300sp"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="10sp"
        android:src="@drawable/ic_launcher" />

     <TextView
        android:id="@+id/textView50"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_marginTop="10sp"
        android:text="Ballet Dancer"
        android:textAppearance="?android:attr/textAppearanceMedium" />

      <ImageView
        android:id="@+id/imageView2"
        android:layout_width="300sp"
        android:layout_height="300sp"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="10sp"
        android:src="@drawable/ic_launcher" />

     <TextView
        android:id="@+id/textView2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_marginTop="10sp"
        android:text="Butter Churner"
        android:textAppearance="?android:attr/textAppearanceMedium" />

      <ImageView
        android:id="@+id/imageView3"
        android:layout_width="300sp"
        android:layout_height="300sp"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="10sp"
        android:src="@drawable/ic_launcher" />

     <TextView
        android:id="@+id/textView3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_marginTop="10sp"
        android:text="Closed For Business"
        android:textAppearance="?android:attr/textAppearanceMedium" />

      <ImageView
        android:id="@+id/imageView4"
        android:layout_width="300sp"
        android:layout_height="300sp"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="10sp"
        android:src="@drawable/ic_launcher" />

     <TextView
        android:id="@+id/textView4"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_marginTop="10sp"
        android:text="Corkscrew"
        android:textAppearance="?android:attr/textAppearanceMedium" />

      <ImageView
        android:id="@+id/imageView5"
        android:layout_width="300sp"
        android:layout_height="300sp"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="10sp"
        android:src="@drawable/ic_launcher" />

     <TextView
        android:id="@+id/textView5"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_marginTop="10sp"
        android:text="Cowboy"
        android:textAppearance="?android:attr/textAppearanceMedium" />

      <ImageView
        android:id="@+id/imageView6"
        android:layout_width="300sp"
        android:layout_height="300sp"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="10sp"
        android:src="@drawable/ic_launcher" />

     <TextView
        android:id="@+id/textView6"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_marginTop="10sp"
        android:text="Cow Girl"
        android:textAppearance="?android:attr/textAppearanceMedium" />

      <ImageView
        android:id="@+id/imageView7"
        android:layout_width="300sp"
        android:layout_height="300sp"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="10sp"
        android:src="@drawable/ic_launcher" />

     <TextView
        android:id="@+id/textView7"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_marginTop="10sp"
        android:text="Cowgirls Helper"
        android:textAppearance="?android:attr/textAppearanceMedium" />

      <ImageView
        android:id="@+id/imageView8"
        android:layout_width="300sp"
        android:layout_height="300sp"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="10sp"
        android:src="@drawable/ic_launcher" />

     <TextView
        android:id="@+id/textView8"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_marginTop="10sp"
        android:text="David Copperfield"
        android:textAppearance="?android:attr/textAppearanceMedium" />

      <ImageView
        android:id="@+id/imageView9"
        android:layout_width="300sp"
        android:layout_height="300sp"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="10sp"
        android:src="@drawable/ic_launcher" />

     <TextView
        android:id="@+id/textView9"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_marginTop="10sp"
        android:text="Doggie Style"
        android:textAppearance="?android:attr/textAppearanceMedium" />

      <ImageView
        android:id="@+id/imageView10"
        android:layout_width="300sp"
        android:layout_height="300sp"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="10sp"
        android:src="@drawable/ic_launcher" />

     <TextView
        android:id="@+id/textView10"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_marginTop="10sp"
        android:text="Face Off"
        android:textAppearance="?android:attr/textAppearanceMedium" />

      <ImageView
        android:id="@+id/imageView11"
        android:layout_width="300sp"
        android:layout_height="300sp"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="10sp"
        android:src="@drawable/ic_launcher" />

     <TextView
        android:id="@+id/textView11"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_marginTop="10sp"
        android:text="Face Off 2"
        android:textAppearance="?android:attr/textAppearanceMedium" />

      <ImageView
        android:id="@+id/imageView12"
        android:layout_width="300sp"
        android:layout_height="300sp"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="10sp"
        android:src="@drawable/ic_launcher" />

     <TextView
        android:id="@+id/textView12"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_marginTop="10sp"
        android:text="Flat Iron"
        android:textAppearance="?android:attr/textAppearanceMedium" />

      <ImageView
        android:id="@+id/imageView13"
        android:layout_width="300sp"
        android:layout_height="300sp"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="10sp"
        android:src="@drawable/ic_launcher" />

     <TextView
        android:id="@+id/textView13"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_marginTop="10sp"
        android:text="Golden Arch"
        android:textAppearance="?android:attr/textAppearanceMedium" />



     </LinearLayout>
 </ScrollView>

</FrameLayout>