我正在开发一个 android 地图应用程序来在地图上放置标记。我正在使用 JSON 将标记数据从 url 解析到放置在地图上但我在 Log Cat 中得到以下错误。这是 Log Cat
07-16 11:27:37.771: E/Trace(32163): error opening trace file: No such file or directory (2)
07-16 11:27:37.791: W/dalvikvm(32163): Refusing to reopen boot DEX '/system/framework/hwframework.jar'
07-16 11:27:38.391: W/System.err(32163): Invalid int: ""
07-16 11:27:38.411: W/dalvikvm(32163): Refusing to reopen boot DEX '/system/framework/hwframework.jar'
07-16 11:27:39.961: W/dalvikvm(32163): threadid=1: thread exiting with uncaught exception (group=0x41cdc438)
07-16 11:28:48.851: E/Trace(32327): error opening trace file: No such file or directory (2)
07-16 11:28:48.901: W/dalvikvm(32327): Refusing to reopen boot DEX '/system/framework/hwframework.jar'
07-16 11:28:49.271: W/System.err(32327): Invalid int: ""
07-16 11:28:49.291: W/dalvikvm(32327): Refusing to reopen boot DEX '/system/framework/hwframework.jar'
07-16 11:28:49.871: W/dalvikvm(32327): threadid=1: thread exiting with uncaught exception (group=0x41cdc438)
来源 这是我的源代码
package pkg.pkg.map3;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.widget.Toast;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.SupportMapFragment;
import android.graphics.drawable.Drawable;
import android.net.ParseException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class MainActivity extends FragmentActivity {
JSONArray jArray;
String result = null;
InputStream is = null;
StringBuilder sb=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//GoogleMap mMap;
//mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
GoogleMap mMap = fm.getMap();
String readTwitterFeed = readpoints();
double LAT;
double LANG;
String INFO;
try {
JSONArray jsonArray = new JSONArray(readTwitterFeed);
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
LAT=jsonObject.getDouble("lat");
LANG=jsonObject.getDouble("lang");
INFO=jsonObject.getString("info");
mMap.addMarker(new MarkerOptions().position(new LatLng(LAT, LANG)).title(INFO));
}
} catch (Exception e) {
e.printStackTrace();
}
}
@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;
}
public String readpoints() {
StringBuilder builder = new StringBuilder();
HttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet("http://202.125.144.34/a/map.php");
try {
HttpResponse response = client.execute(httpGet);
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
if (statusCode == 200) {
HttpEntity entity = response.getEntity();
InputStream content = entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(content));
builder.append(reader.readLine() + "\n");
String line;
while ((line = reader.readLine()) != null) {
builder.append(line + "\n");
}
} else {
Log.e(MainActivity.class.toString(), "Failed to download file");
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return builder.toString();
}
}
显现
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pkg.pkg.map3"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" android:maxSdkVersion="16" android:targetSdkVersion="16"/>
<permission
android:name="pkg.pkg.map3.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="pkg.pkg.map3.maps.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_PERMISSION"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:debuggable="true" >
<activity
android:name="pkg.pkg.map3.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDhJFrxxmuDGC4EC389AJ9AmyKFc--0S8s" />
</application>
</manifest>
布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
任何人告诉我关于这个问题可能是什么问题。请帮助!