我正在实现google maps v2,我正在绘制从外部gpx文件接收的it交付路径、设备路径、设备当前位置和交付点位置。问题是它大部分时间都在工作…
我得到的错误(当它不工作时)是下一个:
03-16 20:48:37.811: I/dalvikvm(16510): threadid=30: stack overflow on call to Lmaps/t/bx;.d:FLLL
03-16 20:48:37.811: I/dalvikvm(16510): method requires 40+20+0=60 bytes, fp is 0x60223318 (24 left)
03-16 20:48:37.811: I/dalvikvm(16510): expanding stack end (0x60223300 to 0x60223000)
03-16 20:48:37.811: I/dalvikvm(16510): Shrank stack (to 0x60223300, curFrame is 0x60226e54)
03-16 20:48:37.821: D/gralloc(16510): unmap_buffer: Successfully unmapped 0xa5000 bytes at address 0x60416000, SharedFd=89, map_count = 3
03-16 20:48:37.821: D/gralloc(16510): unmap_buffer: Successfully unmapped 0xa5000 bytes at address 0x604bb000, SharedFd=96, map_count = 2
03-16 20:48:37.881: W/dalvikvm(16510): threadid=30: thread exiting with uncaught exception (group=0x409f61f8)
03-16 20:32:23.471: E/AndroidRuntime(16283): FATAL EXCEPTION: GLThread 1827
03-16 20:32:23.471: E/AndroidRuntime(16283): java.lang.StackOverflowError
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.bx.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.bx.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
03-16 20:32:23.471: E/AndroidRuntime(16283): at maps.t.cg.a(Unknown Source)
下面是生成问题的代码示例。
updatemap方法在活动的oncreate方法中只调用一次。updatemap内部是drawuserlocationmap调用。我愿意接受任何建议。
UpdateMap方法:
private void UpdateMap() {
map = ((SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map)).getMap();
int i = 0;
// GPS COORDINATES RECEIVED FROM GPX FILE
PolylineOptions pOptions = new PolylineOptions();
LatLng initialCameraPosition = null;
for (GpxTrackModel trackModel : ProviderUtility.GpxProvider.GpxTracks) {
for (GpxTrackCoordinateModel coorModel : trackModel.getTrackCoordinates()) {
if (i == 0)
initialCameraPosition = new LatLng(coorModel.getLatitude(), coorModel.getLongitude());
pOptions.add(new LatLng(coorModel.getLatitude(), coorModel.getLongitude()));
i++;
}
// ADDING DESTINATION MARKERS (LAST LOCATION IN TRACK SEGMENT)
MarkerOptions mOptions = new MarkerOptions();
mOptions.draggable(false);
GpxTrackCoordinateModel model = trackModel.getTrackCoordinates().get(trackModel.getTrackCoordinates().size() - 1);
mOptions.position(new LatLng(model.getLatitude(), model.getLongitude()));
mOptions.title(trackModel.getName());
map.addMarker(mOptions).showInfoWindow();
map.animateCamera(CameraUpdateFactory.newLatLngZoom(initialCameraPosition, 14));
DrawUserLocationOnMap();
}
pOptions.color(Color.parseColor("#FF0000"));
map.addPolyline(pOptions);
}
DrawUserLocationMap方法:
PolylineOptions recordedPOptions = null;
MarkerOptions userLocation = null;
private void DrawUserLocationOnMap() {
// RECORDED GPS DATA WITH GREEN LINE
if (recordedPOptions == null)
recordedPOptions = new PolylineOptions();
// ADDING SAVED USER GPS COORDINATES FROM DATABASE AND DRAWING PATH
ArrayList<GPSTrackingModel> list = ProviderUtility.GPSTrackingProvider.GetGPSCoordinates(false);
for (GPSTrackingModel recordedGps : list)
recordedPOptions.add(new LatLng(Double.parseDouble(recordedGps.getLatitude()), Double.parseDouble(recordedGps.getLongitude())));
recordedPOptions.color(Color.parseColor("#00FF00"));
map.addPolyline(recordedPOptions);
// ADDING CURRENT LOCATION MARKER
GPSTrackingModel lastPosition = ProviderUtility.GPSTrackingProvider.GetLastCoordinate();
if (lastPosition != null && lastPosition.getLatitude() != null
&& !lastPosition.getLatitude().equals("")
&& lastPosition.getLongitude() != null
&& !lastPosition.getLongitude().equals("")) {
LatLng lp = new LatLng(Double.parseDouble(lastPosition.getLatitude()), Double.parseDouble(lastPosition.getLongitude()));
if (userLocation == null) {
userLocation = new MarkerOptions();
userLocation.draggable(false);
userLocation.position(lp);
userLocation.title("My current location");
userLocation.icon(BitmapDescriptorFactory.fromResource(R.drawable.currentlocation));
map.addMarker(userLocation);
} else
userLocation.position(lp);
float zoom = map.getCameraPosition().zoom;
if (zoom < 14)
zoom = 14;
map.animateCamera(CameraUpdateFactory.newLatLngZoom(lp, zoom));
}
}
更新:
为了强制出错,我添加了一个循环,每200毫秒调用一次drawuserlocationonmap()方法。4-5秒后,它崩溃了。
最佳答案
我将从解决代码中的一些问题开始,并希望其中一个问题会使maps v2库出错。
不要在循环内多次调用animateCamera()
。你的用户会头晕。请在最后打一次电话。
不要一直在相同的位置重新添加相同的标记,因为您的代码是通过调用它几十次(每200毫秒,4-5秒后崩溃)来获得相同的模型数据的,因为这要么是无效的生产代码(如果您真的这样做了),要么是无效的测试(如果这纯粹是您强制崩溃)。
如果这些都没有帮助,慢慢地开始注释代码的部分,直到可以精确地缩小触发无限递归的范围。我希望堆栈跟踪可以明确显示问题在代码中的触发位置,但这并没有成功。
关于android - 致命异常:Google Maps V2的GLThread,StackOverflowError,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15453542/