Hi everyone:

When I was learning how to parse XML data described in the Android tutorial 
(http://developer.android.com/training/basics/network-ops/xml.html), I found an 
error in the sample file provided.

This error appears in the Android Manifest file and it is related with the 
class name.

Those are the original lines:

        <activity
            android:name="com.example.networkusage.NetworkActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

Since the default package is "com.example.android.networkusage", Android cannot 
find the right class and the follow error appears:

08-14 16:28:24.435 E/AndroidRuntime(23879): java.lang.RuntimeException: Unable 
to instantiate activity 
ComponentInfo{com.example.android.networkusage/com.example.networkusage.NetworkActivity}:
 java.lang.ClassNotFoundException: com.example.networkusage.NetworkActivity in 
loader 
dalvik.system.PathClassLoader[/data/app/com.example.android.networkusage-2.apk]

There are two way to fix this error. The first one is add the full path, which 
is:

        <activity
            android:name="com.example.android.networkusage.NetworkActivity"
            ....

The second one is simply lfet the activity name (starts with dot):

        <activity
            android:name=".NetworkActivity"
            ....

Cheers
http://www.jiahaoliuliu.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to