Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/402.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在Android中调用API时发生XML错误_Java_Android_Xml_Android Asynctask_Http Post - Fatal编程技术网

Java 在Android中调用API时发生XML错误

Java 在Android中调用API时发生XML错误,java,android,xml,android-asynctask,http-post,Java,Android,Xml,Android Asynctask,Http Post,“XML文档(7,26)中存在错误”。这是我从web API得到的响应。我检查了Manifest.xml和项目中的所有其他xml文件,但没有发现异常。API请求不是通过XML发送的,而是使用异步任务在主活动中发送的。如果问题需要代码和项目背景,那么告诉我我会编辑我的帖子。先谢谢大家 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk

“XML文档(7,26)中存在错误”。这是我从web API得到的响应。我检查了Manifest.xml和项目中的所有其他xml文件,但没有发现异常。API请求不是通过XML发送的,而是使用异步任务在主活动中发送的。如果问题需要代码和项目背景,那么告诉我我会编辑我的帖子。先谢谢大家

   <?xml version="1.0" encoding="utf-8"?>
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.abdullahazam.myapplication"  >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/pitb"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
<android.support.design.widget.AppBarLayout android:layout_height="wrap_content"
    android:layout_width="match_parent" android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar android:id="@+id/toolbar"
        android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"
        android:background="#00a651" app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_main" />

<android.support.design.widget.AppBarLayout android:layout_height="wrap_content"
    android:layout_width="match_parent" android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar android:id="@+id/toolbar"
        android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"
        android:background="#00a651" app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_main" />
上面提到的代码是manifest.xml。下面是mainactivity.xml

<android.support.design.widget.AppBarLayout android:layout_height="wrap_content"
    android:layout_width="match_parent" android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar android:id="@+id/toolbar"
        android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"
        android:background="#00a651" app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_main" />


问题出在参数上。API服务器无法识别其中一个参数格式,正在返回此类未识别的错误。因此,我的应用程序和API服务器尤其如此。

“xmlns:app=”“xmlns:tools=”“android:layout\u width=“match\u parent”android:layout\u height=“match\u parent”android:fitsystemwindows=“true”tools:context=“.main活动“>mainactivity.xml的前7行logcat上显示了什么错误?它没有显示任何错误。但是,来自API的响应表明存在错误。这正是响应字符串{“success”:“109”,“message”:“XML文档(7,26)中存在错误”。}其中success表示安全密钥有效并成功调用了API。109表示“异常:系统遇到意外错误”,109错误代码的消息是“XML文档(7,26)中存在错误”。请在mainactivity中删除android:theme=“@style/AppTheme.AppBarOverlay”,然后重试
<android.support.design.widget.AppBarLayout android:layout_height="wrap_content"
    android:layout_width="match_parent" android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar android:id="@+id/toolbar"
        android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"
        android:background="#00a651" app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_main" />