在Android 2.1和1.5中启动地图活动会导致崩溃

时间:2012-03-01 01:10:58

标签: android android-appwidget

在我开发的appwidget中,我有一个问题,当我在Android 2.1和1.5中启动地图活动时会导致崩溃。我只在1.5和2.1中记录过这个,它可能发生在1.6但我还没有测试过。如果我让应用程序运行一段时间,比如在触摸它之前30分钟到一小时,问题就会神奇地消失。

我非常确信这不是我的应用中的错误,而是Android错误。有办法解决它吗?

堆栈追踪:

I/ActivityManager(  576): Starting activity: Intent { flags=0x10000000 comp={net.example.example/net.example.example.ExampleTabWidget} }
D/dalvikvm(  576): GC freed 8147 objects / 444432 bytes in 84ms
W/dalvikvm(  822): Unable to resolve superclass of Lnet/example/example/ExampleMaps; (55)
W/dalvikvm(  822): Link of class 'Lnet/example/example/ExampleMaps;' failed
E/dalvikvm(  822): Could not find class 'net.example.example.ExampleMaps', referenced from method net.example.example.ExampleTabWidget.onCreate
W/dalvikvm(  822): VFY: unable to resolve const-class 109 (Lnet/example/example/ExampleMaps;) in Lnet/example/example/ExampleTabWidget;
W/dalvikvm(  822): VFY:  rejecting opcode 0x1c at 0x011c
W/dalvikvm(  822): VFY:  rejected Lnet/example/example/ExampleTabWidget;.onCreate (Landroid/os/Bundle;)V
W/dalvikvm(  822): Verifier rejected class Lnet/example/example/ExampleTabWidget;
W/dalvikvm(  822): Class init failed in newInstance call (Lnet/example/example/ExampleTabWidget;)
D/AndroidRuntime(  822): Shutting down VM
W/dalvikvm(  822): threadid=3: thread exiting with uncaught exception (group=0x4000fe70)
E/AndroidRuntime(  822): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime(  822): java.lang.VerifyError: net.example.example.ExampleTabWidget
E/AndroidRuntime(  822):  at java.lang.Class.newInstanceImpl(Native Method)
E/AndroidRuntime(  822):  at java.lang.Class.newInstance(Class.java:1472)
E/AndroidRuntime(  822):  at android.app.Instrumentation.newActivity(Instrumentation.java:1097)
E/AndroidRuntime(  822):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2186)
E/AndroidRuntime(  822):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)
E/AndroidRuntime(  822):  at android.app.ActivityThread.access$1800(ActivityThread.java:112)
E/AndroidRuntime(  822):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
E/AndroidRuntime(  822):  at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(  822):  at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(  822):  at android.app.ActivityThread.main(ActivityThread.java:3948)
E/AndroidRuntime(  822):  at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(  822):  at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(  822):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
E/AndroidRuntime(  822):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
E/AndroidRuntime(  822):  at dalvik.system.NativeStart.main(Native Method)
I/Process (  576): Sending signal. PID: 822 SIG: 3
I/dalvikvm(  822): threadid=7: reacting to signal 3
I/dalvikvm(  822): Wrote stack trace to '/data/anr/traces.txt'
I/Process (  822): Sending signal. PID: 822 SIG: 9
I/ActivityManager(  576): Process net.example.example (pid 822) has died.

相关代码,从标签活动中启动地图活动:

intent=new Intent().setClass(this, ExampleMaps.class);
intent.putExtra("t1",t1);
intent.putExtra("t2",t2);
intent.putExtra("m1",m1);
intent.putExtra("details",details);
spec=tabHost.newTabSpec("Examples").setIndicator("", res.getDrawable(R.drawable.example_tab_icons_map)).setContent(intent);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
tabHost.addTab(spec);
(..)
tabHost.setCurrentTab(0);

地图活动:

public class ExampleMaps extends MapActivity
{
  private MapController mapController;
  private MapView mapView;
  private LocationManager locationManager;

  @Override
  protected boolean isRouteDisplayed()
  {
    return false;
  }

  @Override
  public void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);

    double t1=0, t2=0;
    String alerttext=ExampleWidgetProvider.NODATA, mag, details=ExampleWidgetProvider.NODATA;
    int m1=1;
    Drawable drawable;

    Bundle extras=getIntent().getExtras();
    if(extras !=null)
    {
(..)

Afetr检查Android java.lang.VerifyError?和其他一些我尚未找到解决方案的地方。

以下内容已正确设置:

project.properties

target=Google Inc.:Google APIs:3

Manifest,在“应用程序”中:

<application 
    android:label="@string/app_name"
    android:icon="@drawable/scaled48">
    <uses-library android:name="com.google.android.maps"/>
(...)
</application>
<uses-sdk android:minSdkVersion="3" />

将这些内容包含在地图活动中:

import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;

1 个答案:

答案 0 :(得分:1)

java.lang.VerifyError看起来很可疑。您可能希望卸载,重建,重新安装并确保正确编译库。查看here以获取与VerifyError

相关的信息