org.codehaus.jackson.JsonParseException:意外字符("<"(代码 60))



我是android和ArcGIS的新手。

我正在尝试在运行Android 4.1.2(API 16)的摩托罗拉Zoom平板电脑上执行ArcGIS HelloWorld示例应用程序。

贴图层膨胀过程始终失败,并出现以下错误。应用程序使用Emulator成功执行:

07-30 13:30:31.850 15409-15433/com.example.scottbing.servicearea E/ArcGIS: 
url =http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer
org.codehaus.jackson.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
at [Source: java.io.StringReader@421ec6b0; line: 1, column: 2]
at org.codehaus.jackson.JsonParser._constructError(JsonParser.java:1432)
at org.codehaus.jackson.impl.JsonParserMinimalBase._reportError(JsonParserMinimalBase.java:521)
at org.codehaus.jackson.impl.JsonParserMinimalBase._reportUnexpectedChar(JsonParserMinimalBase.java:442)
at org.codehaus.jackson.impl.ReaderBasedParser._handleUnexpectedValue(ReaderBasedParser.java:1198)
at org.codehaus.jackson.impl.ReaderBasedParser.nextToken(ReaderBasedParser.java:485)
at com.esri.core.internal.io.handler.h.a(SourceFile:206)
at com.esri.core.internal.io.handler.h.a(SourceFile:227)
at com.esri.core.internal.io.handler.h.a(SourceFile:63)
at com.esri.core.internal.tasks.ags.t.a(SourceFile:39)
at com.esri.android.map.ags.ArcGISTiledMapServiceLayer.initLayer(SourceFile:156)
at com.esri.android.map.ags.ArcGISTiledMapServiceLayer$1.run(SourceFile:132)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)

我使用的是基本世界街道地图:http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer

看起来映射是用某种无效的JSON字符发送的。有没有办法轻易纠正这个问题?

我使用的是安卓工作室。

这是MainActivity.java

package com.example.scottbing.helloworld;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import com.esri.android.map.MapView;

public class MainActivity extends Activity {
    MapView mMapView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        // after the content of this activity is set
        // the map can be accessed from the layout
        mMapView = (MapView)findViewById(R.id.map);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

这是manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.scottbing.helloworld" >
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:configChanges="orientation|screenSize|uiMode" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

这是项目建筑.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://esri.bintray.com/arcgis'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        jcenter()
        maven {
            url 'https://esri.bintray.com/arcgis'
        }
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

这是应用程序build.gradle

apply plugin: 'com.android.application'
android {
    compileSdkVersion 15
    buildToolsVersion '19.1.0'
    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    packagingOptions{
        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
        debug {
            debuggable true
        }
    }
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.esri.arcgis.android:arcgis-android:10.2.8-1'
}

您可能会收到这个错误,因为您向它发送了一个XML,而它需要一个JSON。

相关内容

最新更新