parsing xml data form the internet

2019-09-07 04:46发布

hello guys i develop a simple app that read an XML file from the internet by using the SAX but i get this error on logcat any help could be helpful

manifest file

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.reaf.xml"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.read.xml.DataHandler"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

Logcat

10-06 07:38:00.014: D/dalvikvm(543): newInstance failed: no <init>()
10-06 07:38:00.054: D/AndroidRuntime(543): Shutting down VM
10-06 07:38:00.054: W/dalvikvm(543): threadid=1: thread exiting with uncaught exception (group=0x40015560)
10-06 07:38:00.064: E/AndroidRuntime(543): FATAL EXCEPTION: main
10-06 07:38:00.064: E/AndroidRuntime(543): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.reaf.xml/com.read.xml.DataHandler}: java.lang.InstantiationException: com.read.xml.DataHandler
10-06 07:38:00.064: E/AndroidRuntime(543):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
10-06 07:38:00.064: E/AndroidRuntime(543):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-06 07:38:00.064: E/AndroidRuntime(543):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-06 07:38:00.064: E/AndroidRuntime(543):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-06 07:38:00.064: E/AndroidRuntime(543):  at android.os.Handler.dispatchMessage(Handler.java:99)
10-06 07:38:00.064: E/AndroidRuntime(543):  at android.os.Looper.loop(Looper.java:123)
10-06 07:38:00.064: E/AndroidRuntime(543):  at android.app.ActivityThread.main(ActivityThread.java:3683)
10-06 07:38:00.064: E/AndroidRuntime(543):  at java.lang.reflect.Method.invokeNative(Native Method)
10-06 07:38:00.064: E/AndroidRuntime(543):  at java.lang.reflect.Method.invoke(Method.java:507)
10-06 07:38:00.064: E/AndroidRuntime(543):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-06 07:38:00.064: E/AndroidRuntime(543):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-06 07:38:00.064: E/AndroidRuntime(543):  at dalvik.system.NativeStart.main(Native Method)
10-06 07:38:00.064: E/AndroidRuntime(543): Caused by: java.lang.InstantiationException: com.read.xml.DataHandler
10-06 07:38:00.064: E/AndroidRuntime(543):  at java.lang.Class.newInstanceImpl(Native Method)
10-06 07:38:00.064: E/AndroidRuntime(543):  at java.lang.Class.newInstance(Class.java:1409)
10-06 07:38:00.064: E/AndroidRuntime(543):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
10-06 07:38:00.064: E/AndroidRuntime(543):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
10-06 07:38:00.064: E/AndroidRuntime(543):  ... 11 more

i did not know what is the error

please help

2条回答
Emotional °昔
2楼-- · 2019-09-07 05:31

Your package is com.reaf.xml and your activity name is com.read.xml.DataHandler (you have a mistake in your package name).

Please accord them by setting package to com.read.xml and activity name to .DataHandler.

查看更多
家丑人穷心不美
3楼-- · 2019-09-07 05:43

It is not able to initialize the DataHandler when you the call of newInstance method . Please ensure that you provide nullary constructor for DataHandler class. For other reasons check with the API doc

查看更多
登录 后发表回答