-1

这阻止了我在我的 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
4

1 回答 1

2

问题与 CursorWrapperInner 无关,但与 java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable 无关。

问题出在 Google 服务 SDK 上。确保您已正确导入它(项目而不仅仅是 jar),在 Manifest 中注册并在使用 FragmentAvtivity 时使用 SupportFragmentManager

阅读: 谷歌地图 API v2

于 2013-10-06T16:24:15.753 回答