这阻止我在我的nexus设备上启动我的应用程序。我不知道为什么我收到此错误,因为我的代码中没有光标。我正在制作一个使用谷歌地图的应用程序。我不知道这是否是问题的一部分。没有错误消息,导入了所有正确的库。
这是我的代码:
package com.example.gpstracking;
import java.util.List;
import java.util.Locale;
import android.app.Activity;
import android.content.Context;
import android.location.Address;
import android.location.Criteria;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.Menu;
import android.widget.TextView;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
public class MainActivity extends MapActivity {
private long lastUpdate;
private long lastUpdate2;
float epsilon = 0.0001f;
private TextView aTextView;
private TextView mTextView;
Location mLocation;
LocationListener mLocationListener;
LocationManager mLocationManager;
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MapView mapView = (MapView) findViewById(R.id.map1);
tv = (TextView) findViewById(R.id.tv1);
lastUpdate = System.currentTimeMillis();
mLocationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();;
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setPowerRequirement(Criteria.POWER_LOW);
String locationprovider = mLocationManager.getBestProvider(criteria,true);
mLocation = mLocationManager.getLastKnownLocation(locationprovider);
mLocationListener = new LocationListener() {
public void onLocationChanged(Location location) {
if(location != null)
{
tv.setText("Latitude:" + " " + Double.toString(location.getLatitude()) + " " + "degrees" + "<br>");
tv.setText("Longitude:" + " " + Double.toString(location.getLongitude()) + " " + "degrees");
}
}
@Override
public void onStatusChanged(String provider, int status,
Bundle extras) {
}
public void onProviderEnabled(String provider) {
}
public void onProviderDisabled(String provider) {
}
};
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3000, 1, mLocationListener);
}
@Override
public void onPause(){
super.onPause();
mLocationManager.removeUpdates(mLocationListener);
}
@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
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
她就是原木猫:
10-06 08:49:27.642: D/dalvikvm(2264): GC_FOR_ALLOC freed 247K, 4% free 7742K/8052K, paused 32ms, total 33ms
10-06 08:49:27.652: W/CursorWrapperInner(2264): Cursor finalized without prior close()
10-06 08:49:27.682: W/dalvikvm(2264): VFY: unable to resolve static field 1355 (MapAttrs) in Lcom/google/android/gms/R$styleable;
10-06 08:49:27.682: D/dalvikvm(2264): VFY: replacing opcode 0x62 at 0x000e
10-06 08:49:27.682: D/AndroidRuntime(2264): Shutting down VM
10-06 08:49:27.682: W/dalvikvm(2264): threadid=1: thread exiting with uncaught exception (group=0x41a5e700)
10-06 08:49:27.692: E/AndroidRuntime(2264): FATAL EXCEPTION: main
10-06 08:49:27.692: E/AndroidRuntime(2264): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
答案 0 :(得分:2)
问题与CursorWrapperInner无关,但java.lang.NoClassDefFoundError:com.google.android.gms.R $ styleable。
问题与Google Service SDK有关。确保已正确导入(项目而不仅仅是jar),在Manifest中注册并使用SupportFragmentManager(如果使用FragmentAvtivity
)阅读本文: Google map API v2