我是 Android 编程新手,并且一直在学习本教程以在应用程序中实现 Google Places。当我尝试使用 Google 地点检索附近的地点时,我的应用程序崩溃了。
我相信当我尝试创建一个 http 请求工厂时问题就在这里:
/**
* Creating http request Factory
* */
public static HttpRequestFactory createRequestFactory(final HttpTransport transport) {
return transport.createRequestFactory(new HttpRequestInitializer() {
public void initialize(HttpRequest request) {
HttpHeaders headers = new HttpHeaders();
headers.setUserAgent("Searching Places..");
request.setHeaders(headers);
JsonObjectParser parser = new JsonObjectParser(new JacksonFactory());
request.setParser(parser);
}
});
}
以下是我使用 google-api-java-client-1.15.0-rc 创建此方法时使用的 StackOverflow 资源:
这是包含上述方法的类:
import android.util.Log;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpHeaders;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestFactory;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.HttpResponseException;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonObjectParser;
import com.google.api.client.json.jackson2.JacksonFactory;
public class GooglePlaces {
/** Global instance of the HTTP transport. */
private static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
// Google API Key
private static final String API_KEY = "(HIDDEN ON PURPOSE)";
// Google Places search url's
private static final String PLACES_SEARCH_URL = "https://maps.googleapis.com/maps/api/place/search/json?";
private static final String PLACES_TEXT_SEARCH_URL = "https://maps.googleapis.com/maps/api/place/search/json?";
private static final String PLACES_DETAILS_URL = "https://maps.googleapis.com/maps/api/place/details/json?";
private double _latitude;
private double _longitude;
private double _radius;
/**
* Searching places
*
* @param latitude - latitude of place
* @params longitude - longitude of place
* @param radius - radius of searchable area
* @param types - type of place to search
* @return list of places
* */
public PlacesList search(double latitude, double longitude, double radius,
String types) throws Exception {
this._latitude = latitude;
this._longitude = longitude;
this._radius = radius;
try {
HttpRequestFactory httpRequestFactory = createRequestFactory(HTTP_TRANSPORT);
HttpRequest request = httpRequestFactory
.buildGetRequest(new GenericUrl(PLACES_SEARCH_URL));
request.getUrl().put("key", API_KEY);
request.getUrl().put("location", _latitude + "," + _longitude);
request.getUrl().put("radius", _radius); // in meters
request.getUrl().put("sensor", "false");
if (types != null)
request.getUrl().put("types", types);
PlacesList list = request.execute().parseAs(PlacesList.class);
// Check log cat for places response status
Log.d("Places Status", "" + list.status);
return list;
} catch (HttpResponseException e) {
Log.e("Error:", e.getMessage());
return null;
}
}
/**
* Searching single place full details
*
* @param refrence
* - reference id of place - which you will get in search api
* request
* */
public PlaceDetails getPlaceDetails(String reference) throws Exception {
try {
HttpRequestFactory httpRequestFactory = createRequestFactory(HTTP_TRANSPORT);
HttpRequest request = httpRequestFactory
.buildGetRequest(new GenericUrl(PLACES_DETAILS_URL));
request.getUrl().put("key", API_KEY);
request.getUrl().put("reference", reference);
request.getUrl().put("sensor", "false");
PlaceDetails place = request.execute().parseAs(PlaceDetails.class);
return place;
} catch (HttpResponseException e) {
Log.e("Error in Perform Details", e.getMessage());
throw e;
}
}
/**
* Creating http request Factory
* */
public static HttpRequestFactory createRequestFactory(final HttpTransport transport) {
return transport.createRequestFactory(new HttpRequestInitializer() {
public void initialize(HttpRequest request) {
HttpHeaders headers = new HttpHeaders();
headers.setUserAgent("Searching Places..");
request.setHeaders(headers);
JsonObjectParser parser = new JsonObjectParser(new JacksonFactory());
request.setParser(parser);
}
});
}
}
这是我收到“致命异常:AsyncTask#1”错误的类:
import java.util.ArrayList;
import java.util.HashMap;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
public class CheckAreaActivity extends Activity {
// flag for Internet connection status
Boolean isInternetPresent = false;
// Connection detector class
ConnectionDetector connectionDetector;
// Alert Dialog Manager
AlertDialogManager alert = new AlertDialogManager();
// Google Places
GooglePlaces googlePlaces;
// Places List
PlacesList nearPlaces;
// GPS Location
GPSTracker gps;
// Button
Button btnShowOnMap;
// Progress dialog
ProgressDialog progressDialog;
// Places Listview
ListView placesListView;
// ListItems data
ArrayList<HashMap<String, String>> placesListItems = new ArrayList<HashMap<String, String>>();
// KEY Strings
public static String KEY_REFERENCE = "reference"; // id of the place
public static String KEY_NAME = "name"; // name of the place
public static String KEY_VICINITY = "vicinity"; // Place area name
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.check_area_layout);
this.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.window_title);
this.connectionDetector = new ConnectionDetector(
this.getApplicationContext());
// Check if Internet availability
this.isInternetPresent = this.connectionDetector
.isConnectingToInternet();
if (!this.isInternetPresent) {
// No Internet connection
this.alert.showAlertDialog(CheckAreaActivity.this,
"Internet Connection Error",
"Please connect to working Internet connection", false);
// Stop executing code
return;
}
// Create GPS Class object
this.gps = new GPSTracker(this);
// Check if GPS location can get location
if (this.gps.canGetLocation()) {
Log.d("Your Location", "latitude: " + this.gps.getLatitude()
+ ", longitude: " + this.gps.getLongitude());
} else {
// Can not get user's current location
this.alert.showAlertDialog(CheckAreaActivity.this, "GPS Status",
"Couldn't get location informaiton. Please enable GPS",
false);
// stop executing code
return;
}
// Get listview
this.placesListView = (ListView) findViewById(R.id.list);
// Button show on map
this.btnShowOnMap = (Button) findViewById(R.id.btn_show_map);
// Call background Async task to load Google Places
// After getting places from Google all the data is hown in listview
new LoadPlaces().execute();
/**
* Button click event for show on map
*/
this.btnShowOnMap.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(),
PlacesMapActivity.class);
// Sending user current geo location
intent.putExtra("user_latitude",
Double.toString(gps.getLatitude()));
intent.putExtra("user_longitude",
Double.toString(gps.getLongitude()));
// passing near places to map activity
intent.putExtra("near_places", nearPlaces);
// starting activity
startActivity(intent);
}
});
/**
* ListItem click event On selecting a list item SinglePlaceActivity is
* launched
*/
this.placesListView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int positon, long id) {
// getting values from selected listItem
String reference = ((TextView) view
.findViewById(R.id.reference)).getText().toString();
// Starting new intent
Intent intent = new Intent(getApplicationContext(),
SinglePlaceActivity.class);
// Sending place reference id to single place activity
// place reference id used to get "Place full details"
intent.putExtra(KEY_REFERENCE, reference);
startActivity(intent);
}
});
}
/**
* Background Async Task to Load Google places
*/
class LoadPlaces extends AsyncTask<Void, Void, PlacesList> {
/**
* Before starting background thread Show Progress Dialog
* */
protected void onPreExecute() {
super.onPreExecute();
progressDialog = new ProgressDialog(CheckAreaActivity.this);
progressDialog.setMessage(Html
.fromHtml("<b>Search</b><br/>Loading Places..."));
progressDialog.setIndeterminate(false);
progressDialog.setCancelable(false);
progressDialog.show();
progressDialog.show();
}
@Override
protected PlacesList doInBackground(Void... params) {
// creating Places class object
googlePlaces = new GooglePlaces();
try {
// Separeate your place types by PIPE symbol "|"
// If you want all types places make it as null
// Check list of types supported by google
//
String types = "cafe|restaurant";
// Radius in meters
double radius = 1609.34; // 1609.34 meters = 1 mile
// get nearest places
nearPlaces = googlePlaces.search(gps.getLatitude(),
gps.getLongitude(), radius, types);
} catch (Exception e) {
e.printStackTrace();
}
return nearPlaces;
}
/**
* After completing background task Dismiss the progress dialog and show
* the data in UI Always use runOnUiThread(new Runnable()) to update UI
* from background thread, otherwise will get error
* **/
@Override
protected void onPostExecute(PlacesList nearPlaces1) {
super.onPostExecute(nearPlaces1);
nearPlaces = nearPlaces1;
// dismiss the dialog after getting all products
progressDialog.dismiss();
// updating UI from Background Thread
// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
/**
* Updating parsed Places into LISTVIEW
* */
// Get json response status
String status = nearPlaces.status;
// Check for all possible status
if (status.equals("OK")) {
// Successfully got places details
if (nearPlaces.results != null) {
// loop through each place
for (Place place : nearPlaces.results) {
HashMap<String, String> map = new HashMap<String, String>();
// Place reference won't display in listview
// - it
// will be hidden
// Place reference is used to get
// "place full details"
map.put(KEY_REFERENCE, place.reference);
// Place name
map.put(KEY_NAME, place.name);
// adding HashMap to ArrayList
placesListItems.add(map);
}
// list adapter
ListAdapter adapter = new SimpleAdapter(
CheckAreaActivity.this, placesListItems,
R.layout.list_item, new String[] {
KEY_REFERENCE, KEY_NAME },
new int[] { R.id.reference, R.id.name });
// Adding data into listview
placesListView.setAdapter(adapter);
}
} else if (status.equals("ZERO_RESULTS")) {
// Zero results found
alert.showAlertDialog(
CheckAreaActivity.this,
"Near Places",
"Sorry no places found. Try to change the types of places",
false);
} else if (status.equals("UNKNOWN_ERROR")) {
alert.showAlertDialog(CheckAreaActivity.this,
"Places Error", "Sorry unknown error occured.",
false);
} else if (status.equals("OVER_QUERY_LIMIT")) {
alert.showAlertDialog(
CheckAreaActivity.this,
"Places Error",
"Sorry query limit to google places is reached",
false);
} else if (status.equals("REQUEST_DENIED")) {
alert.showAlertDialog(CheckAreaActivity.this,
"Places Error",
"Sorry error occured. Request is denied", false);
} else if (status.equals("INVALID_REQUEST")) {
alert.showAlertDialog(CheckAreaActivity.this,
"Places Error",
"Sorry error occured. Invalid Request", false);
} else {
alert.showAlertDialog(CheckAreaActivity.this,
"Places Error", "Sorry error occured.", false);
}
}
});
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu){
getMenuInflater().inflate(R.menu.check_area_menu, menu);
return true;
}
}
我在编写 AsyncTask 时使用了 StackOverflow 中的这个资源。
这是我的 AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.renterview"
android:versionCode="1"
android:versionName="1.0" >
<!-- Internet Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Network State Permissions -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- GPS access Permissions -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/CustomTheme" >
<!-- Add Google Map Library -->
<uses-library android:name="com.google.android.maps" />
<!-- Splash Screen Activity -->
<activity
android:name="com.example.renterview.Splash"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Main Activity -->
<activity
android:name="com.example.renterview.Main"
android:label="@string/app_name" >
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- Check Area Activity -->
<activity android:name="com.example.renterview.CheckAreaActivity" />
<!-- Single Places Activity -->
<activity android:name="com.example.renterview.SinglePlaceActivity" />
<!-- PlacesMapActivty -->
<activity android:name="com.example.renterview.PlacesMapActivity" />
</application>
这是 LogCat 向我展示的内容:
08-03 17:06:12.490: D/dalvikvm(895): GC_FOR_ALLOC freed 49K, 7% free 2421K/2596K, paused 36ms, total 48ms
08-03 17:06:12.529: I/dalvikvm-heap(895): Grow heap (frag case) to 6.901MB for 4633616-byte allocation
08-03 17:06:12.590: D/dalvikvm(895): GC_FOR_ALLOC freed <1K, 3% free 6945K/7124K, paused 59ms, total 59ms
08-03 17:06:12.659: D/dalvikvm(895): GC_CONCURRENT freed <1K, 3% free 6945K/7124K, paused 9ms+5ms, total 70ms
08-03 17:06:13.611: D/libEGL(895): loaded /system/lib/egl/libEGL_emulation.so
08-03 17:06:13.629: D/(895): HostConnection::get() New Host Connection established 0x2a157c58, tid 895
08-03 17:06:13.650: D/libEGL(895): loaded /system/lib/egl/libGLESv1_CM_emulation.so
08-03 17:06:13.660: D/libEGL(895): loaded /system/lib/egl/libGLESv2_emulation.so
08-03 17:06:13.740: W/EGL_emulation(895): eglSurfaceAttrib not implemented
08-03 17:06:13.760: D/OpenGLRenderer(895): Enabling debug mode 0
08-03 17:06:17.260: W/EGL_emulation(895): eglSurfaceAttrib not implemented
08-03 17:09:05.439: D/GPS(895): GPS Enabled
08-03 17:09:05.439: D/Your Location(895): latitude: -85.07573166666667, longitude: 33.580275
08-03 17:09:05.519: D/dalvikvm(895): GC_CONCURRENT freed 33K, 2% free 8343K/8488K, paused 70ms+49ms, total 217ms
08-03 17:09:06.152: W/EGL_emulation(895): eglSurfaceAttrib not implemented
08-03 17:09:06.282: W/EGL_emulation(895): eglSurfaceAttrib not implemented
08-03 17:09:07.229: E/dalvikvm(895): Could not find class 'com.fasterxml.jackson.core.JsonFactory', referenced from method com.google.api.client.json.jackson2.JacksonFactory.<init>
08-03 17:09:07.229: W/dalvikvm(895): VFY: unable to resolve new-instance 523 (Lcom/fasterxml/jackson/core/JsonFactory;) in Lcom/google/api/client/json/jackson2/JacksonFactory;
08-03 17:09:07.239: D/dalvikvm(895): VFY: replacing opcode 0x22 at 0x0003
08-03 17:09:07.249: W/dalvikvm(895): VFY: unable to find class referenced in signature (Lcom/fasterxml/jackson/core/JsonToken;)
08-03 17:09:07.249: I/dalvikvm(895): Could not find method com.fasterxml.jackson.core.JsonToken.ordinal, referenced from method com.google.api.client.json.jackson2.JacksonFactory.convert
08-03 17:09:07.249: W/dalvikvm(895): VFY: unable to resolve virtual method 3644: Lcom/fasterxml/jackson/core/JsonToken;.ordinal ()I
08-03 17:09:07.249: D/dalvikvm(895): VFY: replacing opcode 0x6e at 0x0006
08-03 17:09:07.259: W/dalvikvm(895): VFY: unable to resolve static field 998 (UTF8) in Lcom/fasterxml/jackson/core/JsonEncoding;
08-03 17:09:07.259: D/dalvikvm(895): VFY: replacing opcode 0x62 at 0x0004
08-03 17:09:07.259: I/dalvikvm(895): Could not find method com.fasterxml.jackson.core.JsonFactory.createJsonGenerator, referenced from method com.google.api.client.json.jackson2.JacksonFactory.createJsonGenerator
08-03 17:09:07.259: W/dalvikvm(895): VFY: unable to resolve virtual method 3608: Lcom/fasterxml/jackson/core/JsonFactory;.createJsonGenerator (Ljava/io/Writer;)Lcom/fasterxml/jackson/core/JsonGenerator;
08-03 17:09:07.259: D/dalvikvm(895): VFY: replacing opcode 0x6e at 0x0004
08-03 17:09:07.269: I/dalvikvm(895): Could not find method com.fasterxml.jackson.core.JsonFactory.createJsonParser, referenced from method com.google.api.client.json.jackson2.JacksonFactory.createJsonParser
08-03 17:09:07.269: W/dalvikvm(895): VFY: unable to resolve virtual method 3609: Lcom/fasterxml/jackson/core/JsonFactory;.createJsonParser (Ljava/io/InputStream;)Lcom/fasterxml/jackson/core/JsonParser;
08-03 17:09:07.269: D/dalvikvm(895): VFY: replacing opcode 0x6e at 0x0007
08-03 17:09:07.269: I/dalvikvm(895): Could not find method com.fasterxml.jackson.core.JsonFactory.createJsonParser, referenced from method com.google.api.client.json.jackson2.JacksonFactory.createJsonParser
08-03 17:09:07.269: W/dalvikvm(895): VFY: unable to resolve virtual method 3609: Lcom/fasterxml/jackson/core/JsonFactory;.createJsonParser (Ljava/io/InputStream;)Lcom/fasterxml/jackson/core/JsonParser;
08-03 17:09:07.269: D/dalvikvm(895): VFY: replacing opcode 0x6e at 0x0007
08-03 17:09:07.281: I/dalvikvm(895): Could not find method com.fasterxml.jackson.core.JsonFactory.createJsonParser, referenced from method com.google.api.client.json.jackson2.JacksonFactory.createJsonParser
08-03 17:09:07.281: W/dalvikvm(895): VFY: unable to resolve virtual method 3610: Lcom/fasterxml/jackson/core/JsonFactory;.createJsonParser (Ljava/io/Reader;)Lcom/fasterxml/jackson/core/JsonParser;
08-03 17:09:07.281: D/dalvikvm(895): VFY: replacing opcode 0x6e at 0x0007
08-03 17:09:07.281: I/dalvikvm(895): Could not find method com.fasterxml.jackson.core.JsonFactory.createJsonParser, referenced from method com.google.api.client.json.jackson2.JacksonFactory.createJsonParser
08-03 17:09:07.281: W/dalvikvm(895): VFY: unable to resolve virtual method 3611: Lcom/fasterxml/jackson/core/JsonFactory;.createJsonParser (Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser;
08-03 17:09:07.289: D/dalvikvm(895): VFY: replacing opcode 0x6e at 0x0007
08-03 17:09:07.299: D/dalvikvm(895): DexOpt: unable to opt direct call 0x0e15 at 0x05 in Lcom/google/api/client/json/jackson2/JacksonFactory;.<init>
08-03 17:09:07.299: W/dalvikvm(895): threadid=11: thread exiting with uncaught exception (group=0x40a71930)
08-03 17:09:07.349: E/AndroidRuntime(895): FATAL EXCEPTION: AsyncTask #1
08-03 17:09:07.349: E/AndroidRuntime(895): java.lang.RuntimeException: An error occured while executing doInBackground()
08-03 17:09:07.349: E/AndroidRuntime(895): at android.os.AsyncTask$3.done(AsyncTask.java:299)
08-03 17:09:07.349: E/AndroidRuntime(895): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
08-03 17:09:07.349: E/AndroidRuntime(895): at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
08-03 17:09:07.349: E/AndroidRuntime(895): at java.util.concurrent.FutureTask.run(FutureTask.java:239)
08-03 17:09:07.349: E/AndroidRuntime(895): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
08-03 17:09:07.349: E/AndroidRuntime(895): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
08-03 17:09:07.349: E/AndroidRuntime(895): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
08-03 17:09:07.349: E/AndroidRuntime(895): at java.lang.Thread.run(Thread.java:856)
08-03 17:09:07.349: E/AndroidRuntime(895): Caused by: java.lang.NoClassDefFoundError: com.fasterxml.jackson.core.JsonFactory
08-03 17:09:07.349: E/AndroidRuntime(895): at com.google.api.client.json.jackson2.JacksonFactory.<init>(JacksonFactory.java:44)
08-03 17:09:07.349: E/AndroidRuntime(895): at com.example.renterview.GooglePlaces$1.initialize(GooglePlaces.java:109)
08-03 17:09:07.349: E/AndroidRuntime(895): at com.google.api.client.http.HttpRequestFactory.buildRequest(HttpRequestFactory.java:93)
08-03 17:09:07.349: E/AndroidRuntime(895): at com.google.api.client.http.HttpRequestFactory.buildGetRequest(HttpRequestFactory.java:122)
08-03 17:09:07.349: E/AndroidRuntime(895): at com.example.renterview.GooglePlaces.search(GooglePlaces.java:53)
08-03 17:09:07.349: E/AndroidRuntime(895): at com.example.renterview.CheckAreaActivity$LoadPlaces.doInBackground(CheckAreaActivity.java:195)
08-03 17:09:07.349: E/AndroidRuntime(895): at com.example.renterview.CheckAreaActivity$LoadPlaces.doInBackground(CheckAreaActivity.java:1)
08-03 17:09:07.349: E/AndroidRuntime(895): at android.os.AsyncTask$2.call(AsyncTask.java:287)
08-03 17:09:07.349: E/AndroidRuntime(895): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
08-03 17:09:07.349: E/AndroidRuntime(895): ... 4 more
08-03 17:09:08.159: W/EGL_emulation(895): eglSurfaceAttrib not implemented
08-03 17:09:08.929: E/WindowManager(895): Activity com.example.renterview.CheckAreaActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{412a33c0 V.E..... R....... 0,0-322,175} that was originally added here
08-03 17:09:08.929: E/WindowManager(895): android.view.WindowLeaked: Activity com.example.renterview.CheckAreaActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{412a33c0 V.E..... R....... 0,0-322,175} that was originally added here
08-03 17:09:08.929: E/WindowManager(895): at android.view.ViewRootImpl.<init>(ViewRootImpl.java:354)
08-03 17:09:08.929: E/WindowManager(895): at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:216)
08-03 17:09:08.929: E/WindowManager(895): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
08-03 17:09:08.929: E/WindowManager(895): at android.app.Dialog.show(Dialog.java:281)
08-03 17:09:08.929: E/WindowManager(895): at com.example.renterview.CheckAreaActivity$LoadPlaces.onPreExecute(CheckAreaActivity.java:175)
08-03 17:09:08.929: E/WindowManager(895): at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:586)
08-03 17:09:08.929: E/WindowManager(895): at android.os.AsyncTask.execute(AsyncTask.java:534)
08-03 17:09:08.929: E/WindowManager(895): at com.example.renterview.CheckAreaActivity.onCreate(CheckAreaActivity.java:109)
08-03 17:09:08.929: E/WindowManager(895): at android.app.Activity.performCreate(Activity.java:5104)
08-03 17:09:08.929: E/WindowManager(895): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
08-03 17:09:08.929: E/WindowManager(895): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
08-03 17:09:08.929: E/WindowManager(895): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
08-03 17:09:08.929: E/WindowManager(895): at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-03 17:09:08.929: E/WindowManager(895): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
08-03 17:09:08.929: E/WindowManager(895): at android.os.Handler.dispatchMessage(Handler.java:99)
08-03 17:09:08.929: E/WindowManager(895): at android.os.Looper.loop(Looper.java:137)
08-03 17:09:08.929: E/WindowManager(895): at android.app.ActivityThread.main(ActivityThread.java:5041)
08-03 17:09:08.929: E/WindowManager(895): at java.lang.reflect.Method.invokeNative(Native Method)
08-03 17:09:08.929: E/WindowManager(895): at java.lang.reflect.Method.invoke(Method.java:511)
08-03 17:09:08.929: E/WindowManager(895): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
08-03 17:09:08.929: E/WindowManager(895): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
08-03 17:09:08.929: E/WindowManager(895): at dalvik.system.NativeStart.main(Native Method)
我相信 JsonFactory 错误可能是 LogCat 上出现的所有其他错误的原因?
这是我的 libs 文件夹中的 .jar 文件:
android-support-v4.jar
google-api-client-1.15.0-rc.jar
google-api-client-android-1.15.0-rc.jar
google-http-client-1.15.0-rc.jar
google-http-client-android-1.15.0-rc.jar
google-http-client-jackson2-1.15.0-rc.jar
google-oauth-client-1.15.0-rc.jar
gson-2.1.jar
guava-11.0.2.jar
jackson-core-asl-1.9.11.jar
jsr305-1.3.9.jar
protobuf-java-2.4.1.jar
我拥有的项目构建目标(API 级别 17)(已选中 Google API):
Google APIs[Android 4.2.2]
Android Dependencies
我在 android 开发方面的缺乏经验让我暂时陷入了困境。任何和所有的帮助将不胜感激!提前致谢