0

I am developing an android application that consists of a analog gauge view and i found it here when i was imported that library and project in eclipse it was working successfully. When i was including that library into my project it was not accepting it .Showing an Red color cross mark beside the library file andmy application got crashed showing:-- Unable to start activity ComponentInfo{com.example.c1test/com.example.c1test.Test}: android.view.InflateException I also tried to add the library in the form of JAR files also but it didn't work please help me with this i am working on it since four hours please help me. this is my xml:

<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"
>

        <View
        android:id="@+id/view2_drve_res_test"
        android:layout_width="2dp"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/rltve_1_drve_res_test"
        android:background="#000000" />

    <View
        android:id="@+id/view_drve_res_test"
        android:layout_width="wrap_content"
        android:layout_height="2dp"
        android:layout_below="@+id/textView2_drve_res_test"
        android:layout_toRightOf="@+id/rltve_1_drve_res_test"
        android:background="#000000" />

    <TextView
        android:id="@+id/textView2_drve_res_test"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/view2_drve_res_test"
        android:gravity="center"
        android:paddingLeft="10dp"
        android:text="@string/Coil_heading"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <LinearLayout
        android:id="@+id/lner_drve_res_test"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textView2_drve_res_test"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/view_drve_res_test"
        android:layout_marginTop="28dp" >

        <TextView
            android:id="@+id/txtview_drve_res_test"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/Coil_1_value"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:id="@+id/edtxt_coil_1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1" 
            android:gravity="center"/>

    </LinearLayout>



     <RelativeLayout
         android:id="@+id/rltve_1_drve_res_test"
         android:layout_width="750dp"
         android:layout_height="wrap_content"
         android:layout_alignParentBottom="true"
         android:layout_alignParentLeft="true"
         android:layout_alignParentTop="true" >


 <com.example.libraryforvoltmeter
       android:id="@+id/gauge_view1"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_alignParentRight="true"
       android:layout_weight="1" />

     </RelativeLayout>


     <LinearLayout
        android:id="@+id/lner_drve_res_test_coil_2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textView2_drve_res_test"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/lner_drve_res_test"
        android:layout_marginTop="28dp" >

        <TextView
            android:id="@+id/txtview_drve_res_test_2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/Coil_2_value"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:id="@+id/edttxt_coil_2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1" 
            android:gravity="center">

            <requestFocus />
        </EditText>

    </LinearLayout>

     <RelativeLayout
         android:id="@+id/rltve_2_drve_res_test"
         android:layout_width="750dp"
         android:layout_height="wrap_content"
         android:layout_alignParentLeft="true"
         android:layout_alignParentTop="true" >
     </RelativeLayout>

     <LinearLayout
         android:id="@+id/lnear_drve_res_test_3"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_alignParentRight="true"
         android:layout_below="@+id/lner_drve_res_test_coil_2"
         android:layout_marginTop="41dp"
         android:layout_toRightOf="@+id/rltve_1_drve_res_test" >

         <TextView
             android:id="@+id/textView1"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:text="@string/Voltage_value"
             android:textAppearance="?android:attr/textAppearanceMedium" />

         <EditText
             android:id="@+id/edttxt_voltage"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_weight="1" 
             android:gravity="center"/>

     </LinearLayout>

</RelativeLayout>

this is my Log cat:

01-02 06:38:11.530: W/dalvikvm(11015): threadid=1: thread exiting with uncaught exception (group=0x41694700)
01-02 06:38:11.550: D/dalvikvm(11015): GC_FOR_ALLOC freed 127K, 5% free 3484K/3664K, paused 15ms, total 17ms
01-02 06:38:11.560: E/AndroidRuntime(11015): FATAL EXCEPTION: main
01-02 06:38:11.560: E/AndroidRuntime(11015): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.medequip.c1testpanel/com.medequip.c1testpanel.DriveResponseTest}: android.view.InflateException: Binary XML file line #88: Error inflating class com.example.libraryforvoltmeter
01-02 06:38:11.560: E/AndroidRuntime(11015):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at android.os.Handler.dispatchMessage(Handler.java:99)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at android.os.Looper.loop(Looper.java:137)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at android.app.ActivityThread.main(ActivityThread.java:5103)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at java.lang.reflect.Method.invokeNative(Native Method)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at java.lang.reflect.Method.invoke(Method.java:525)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at dalvik.system.NativeStart.main(Native Method)
01-02 06:38:11.560: E/AndroidRuntime(11015): Caused by: android.view.InflateException: Binary XML file line #88: Error inflating class com.example.libraryforvoltmeter
01-02 06:38:11.560: E/AndroidRuntime(11015):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at android.app.Activity.setContentView(Activity.java:1895)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at com.medequip.c1testpanel.DriveResponseTest.onCreate(DriveResponseTest.java:71)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at android.app.Activity.performCreate(Activity.java:5133)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
01-02 06:38:11.560: E/AndroidRuntime(11015):    ... 11 more
01-02 06:38:11.560: E/AndroidRuntime(11015): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.libraryforvoltmeter" on path: DexPathList[[zip file "/data/app/com.medequip.c1testpanel-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.medequip.c1testpanel-1, /vendor/lib, /system/lib]]
01-02 06:38:11.560: E/AndroidRuntime(11015):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at android.view.LayoutInflater.createView(LayoutInflater.java:559)
01-02 06:38:11.560: E/AndroidRuntime(11015):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
01-02 06:38:11.560: E/AndroidRuntime(11015):    ... 22 more
Mark Adler
  • 101,978
  • 13
  • 118
  • 158
lakshman
  • 181
  • 8
  • 20
  • Check package name of your custom view. Have you added any jar file??? – Piyush Jan 19 '15 at 12:13
  • I changed the package name of the custom view and it was showing like The following classes could not be found: - org.codeandmagic.android.gauge (Fix Build Path, Edit XML, Create Class)..i add the jar file to the build path also @Piyush Gupta – lakshman Jan 19 '15 at 12:17
  • Then you need to check checkbox for your jar file in your `Order and Export` Menu. – Piyush Jan 19 '15 at 12:20
  • I also did that but it was crashed this is my log cat 01-02 00:22:33.820: E/AndroidRuntime(3873): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.medequip.c1testpanel/com.medequip.c1testpanel.DriveResponseTest}: android.view.InflateException: Binary XML file line #88: Error inflating class org.codeandmagic.android.gauge – lakshman Jan 19 '15 at 12:28

1 Answers1

2

following line contains error:

<com.example.libraryforvoltmeter
       android:id="@+id/gauge_view1"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_alignParentRight="true"
       android:layout_weight="1" />

Might be libraryforvoltmeter class is not in following package : com.example Change the package where you put that library class file

Anjali
  • 1
  • 1
  • 13
  • 20
  • when i changed the package name it was showing The following classes could not be found: - org.codeandmagic.android.gauge (Fix Build Path, Edit XML, Create Class) how do i over come this @Anjali – lakshman Jan 19 '15 at 12:16
  • in xml preivew you get this error. But when you run the application it runs perfectly – Anjali Jan 19 '15 at 12:17
  • Nope again it was crashed again when i was running application @Anjali – lakshman Jan 19 '15 at 12:24
  • can you share your project structure ? – Anjali Jan 19 '15 at 12:25