Saturday, March 31, 2012

/AndroidRuntime(673): java.lang.RuntimeException: Unable to instantiate activity/java.lang.ClassNotFoundException/oader dalvik.system.PathClass

I found this problem in android development because when we not include library files properly in manifest.xml.

java.lang.ClassNotFoundException


 java.lang.RuntimeException: Unable to instantiate activity

we need to set the library tag at proper place in the manifest file.
we can solve this problem by setting the <uses-library> under the application tag.

see the example below if we place the <uses-library> tag out of <application> then it causes error i stated above.


Example: The example works fine .

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.zen.mobile"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="8" />
    <uses-permission android:name="android.permission.INTERNET" />
  
   
     <application android:icon="@drawable/myapp_1" android:name=".AppointmentApplication" android:label="@string/app_name">
         <uses-library android:name="com.google.android.maps"/>
        <activity android:name=".WelcomeScreen" android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".AddCourse" android:label="@string/app_name" />
        <activity android:name=".RemoveCourse" android:label="@string/app_name" />
        <activity android:name=".ViewCourseMap" android:label="@string/app_name" />
    </application>
</manifest>


if you cause error even doing like this than make some inter change of <uses-library> at different ways.

No comments:

Post a Comment