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

时间:2016-07-30 19:55:07

标签: android json dictionary motorola

我是Android和ArcGIS的新手。

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

地图图层膨胀过程一致失败,出现以下错误。应用程序使用模拟器成功执行:

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字符发送地图。有没有可以轻易纠正这个问题?

我正在使用Android Studio。

这是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>

这是项目build.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
}

这是app 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'
}

1 个答案:

答案 0 :(得分:0)

您可能会收到该错误,因为您在期望JSON时向其发送了XML。