2015-02-23 54 views
0

我是这项技术的新手。我正面临InflateException:二进制XML行#9错误。活动被添加到清单文件中。什么是问题?任何人都可以帮我解决Coverflow上的InflateException吗?

<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:pj="http://schemas.android.com/apk/res" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:paddingLeft="16dp" 
     android:paddingRight="16dp" > 

    <com.myexample.CoverFlowView 
     xmlns:imageCoverFlow="http://schemas.android.com/apk/lib/com.myexample.CoverFlowView" 
     android:id="@+id/coverflow" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:paddingLeft="20dp" 
     android:paddingRight="20dp" 
     imageCoverFlow:coverflowGravity="center_vertical" 
     imageCoverFlow:coverflowLayoutMode="wrap_content" 
     imageCoverFlow:enableReflection="true" 
     imageCoverFlow:reflectionGap="10dp" 
     imageCoverFlow:reflectionHeight="30%" 
     imageCoverFlow:reflectionShaderEnable="true" 
     imageCoverFlow:visibleImage="5" > 
    </com.myexample.CoverFlowView> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/textCartDetails" 
     android:onClick="onClick" 
     android:clickable="true" 
     android:text="" /> 
    </LinearLayout> 

错误日志:下面是每个构建弹出的错误我做

02-23 00:54:53.809: E/AndroidRuntime(2458): FATAL EXCEPTION: main 
    02-23 00:54:53.809: E/AndroidRuntime(2458): Process: com.myexample, PID: 2458 
    02-23 00:54:53.809: E/AndroidRuntime(2458): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myexample/com.myexample.CreativeProducts}: android.view.InflateException: Binary XML file line #9: Error inflating class com.myexample.CoverFlowView 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at android.app.ActivityThread.access$800(ActivityThread.java:135) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at android.os.Handler.dispatchMessage(Handler.java:102) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at android.os.Looper.loop(Looper.java:136) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at android.app.ActivityThread.main(ActivityThread.java:5017) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at java.lang.reflect.Method.invokeNative(Native Method) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at java.lang.reflect.Method.invoke(Method.java:515) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at dalvik.system.NativeStart.main(Native Method) 
    02-23 00:54:53.809: E/AndroidRuntime(2458): Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class com.myexample.CoverFlowView 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at android.view.LayoutInflater.createView(LayoutInflater.java:620) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at android.app.Activity.setContentView(Activity.java:1929) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at com.myexample.CreativeProducts.onCreate(CreativeProducts.java:44) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at android.app.Activity.performCreate(Activity.java:5231) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  ... 11 more 
    02-23 00:54:53.809: E/AndroidRuntime(2458): Caused by: java.lang.reflect.InvocationTargetException 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at java.lang.reflect.Constructor.constructNative(Native Method) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at android.view.LayoutInflater.createView(LayoutInflater.java:594) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  ... 22 more 
    02-23 00:54:53.809: E/AndroidRuntime(2458): Caused by: java.lang.IllegalArgumentException: visible image must be an odd number 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at com.myexample.CoverFlowView.initAttributes(CoverFlowView.java:178) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  at com.myexample.CoverFlowView.<init>(CoverFlowView.java:161) 
    02-23 00:54:53.809: E/AndroidRuntime(2458):  ... 25 more 
    02-23 00:55:00.719: D/dalvikvm(2458): GC_FOR_ALLOC freed 605K, 16% free 3555K/4228K, paused 49ms, total 49ms 
+0

您在com.myexample.CoverFlowView类中有错误!添加logcat和这个类到你的问题 – 2015-02-23 07:15:14

+0

你确定'com.myexample'前缀是正确的吗? – 2015-02-23 07:17:29

+0

是的。这是我的包名:。 com.myexample.CoverFlowView – Pooja 2015-02-23 07:20:20

回答

1
<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:imageCoverFlow="http://schemas.android.com/apk/lib/com.myexample.CoverFlowView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:paddingLeft="16dp" 
     android:paddingRight="16dp" > 

    <com.myexample.CoverFlowView 
     android:id="@+id/coverflow" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:paddingLeft="20dp" 
     android:paddingRight="20dp" 
     imageCoverFlow:coverflowGravity="center_vertical" 
     imageCoverFlow:coverflowLayoutMode="wrap_content" 
     imageCoverFlow:enableReflection="true" 
     imageCoverFlow:reflectionGap="10dp" 
     imageCoverFlow:reflectionHeight="30%" 
     imageCoverFlow:reflectionShaderEnable="true" 
     imageCoverFlow:visibleImage="5" > 
    </com.myexample.CoverFlowView> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/textCartDetails" 
     android:onClick="onClick" 
     android:clickable="true" 
     android:text="" /> 
    </LinearLayout> 

名称空间必须只在父布局中提到的,然后你应该Android清单包注册这个名字意味着你在版本名称上面提到了androidManifest.xml。

相关问题