{"id":5677,"date":"2014-04-05T04:21:15","date_gmt":"2014-04-05T04:21:15","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/05\/starting-map-activity-in-android-2-1-and-1-5-causes-crash-collection-of-common-programming-errors\/"},"modified":"2014-04-05T04:21:15","modified_gmt":"2014-04-05T04:21:15","slug":"starting-map-activity-in-android-2-1-and-1-5-causes-crash-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/05\/starting-map-activity-in-android-2-1-and-1-5-causes-crash-collection-of-common-programming-errors\/","title":{"rendered":"Starting map activity in Android 2.1 and 1.5 causes crash-Collection of common programming errors"},"content":{"rendered":"<p>In an appwidget I develop I have a problem that when I start a map activity in Android 2.1 and 1.5 it causes a crash. I only notriced this in 1.5 and 2.1, it may happen in 1.6 but I haven&#8217;t tested yet. The problem magically disappears if I let the app run for a while, say 30 minutes to an hour before touching it.<\/p>\n<p>I am pretty convinced this is not a bug in my app, but an Android bug. Is there a way to work around it?<\/p>\n<p>Stack trace:<\/p>\n<pre>\nI\/ActivityManager(  576): Starting activity: Intent { flags=0x10000000 comp={net.example.example\/net.example.example.ExampleTabWidget} }\nD\/dalvikvm(  576): GC freed 8147 objects \/ 444432 bytes in 84ms\nW\/dalvikvm(  822): Unable to resolve superclass of Lnet\/example\/example\/ExampleMaps; (55)\nW\/dalvikvm(  822): Link of class 'Lnet\/example\/example\/ExampleMaps;' failed\nE\/dalvikvm(  822): Could not find class 'net.example.example.ExampleMaps', referenced from method net.example.example.ExampleTabWidget.onCreate\nW\/dalvikvm(  822): VFY: unable to resolve const-class 109 (Lnet\/example\/example\/ExampleMaps;) in Lnet\/example\/example\/ExampleTabWidget;\nW\/dalvikvm(  822): VFY:  rejecting opcode 0x1c at 0x011c\nW\/dalvikvm(  822): VFY:  rejected Lnet\/example\/example\/ExampleTabWidget;.onCreate (Landroid\/os\/Bundle;)V\nW\/dalvikvm(  822): Verifier rejected class Lnet\/example\/example\/ExampleTabWidget;\nW\/dalvikvm(  822): Class init failed in newInstance call (Lnet\/example\/example\/ExampleTabWidget;)\nD\/AndroidRuntime(  822): Shutting down VM\nW\/dalvikvm(  822): threadid=3: thread exiting with uncaught exception (group=0x4000fe70)\nE\/AndroidRuntime(  822): Uncaught handler: thread main exiting due to uncaught exception\nE\/AndroidRuntime(  822): java.lang.VerifyError: net.example.example.ExampleTabWidget\nE\/AndroidRuntime(  822):  at java.lang.Class.newInstanceImpl(Native Method)\nE\/AndroidRuntime(  822):  at java.lang.Class.newInstance(Class.java:1472)\nE\/AndroidRuntime(  822):  at android.app.Instrumentation.newActivity(Instrumentation.java:1097)\nE\/AndroidRuntime(  822):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2186)\nE\/AndroidRuntime(  822):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)\nE\/AndroidRuntime(  822):  at android.app.ActivityThread.access$1800(ActivityThread.java:112)\nE\/AndroidRuntime(  822):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)\nE\/AndroidRuntime(  822):  at android.os.Handler.dispatchMessage(Handler.java:99)\nE\/AndroidRuntime(  822):  at android.os.Looper.loop(Looper.java:123)\nE\/AndroidRuntime(  822):  at android.app.ActivityThread.main(ActivityThread.java:3948)\nE\/AndroidRuntime(  822):  at java.lang.reflect.Method.invokeNative(Native Method)\nE\/AndroidRuntime(  822):  at java.lang.reflect.Method.invoke(Method.java:521)\nE\/AndroidRuntime(  822):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)\nE\/AndroidRuntime(  822):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)\nE\/AndroidRuntime(  822):  at dalvik.system.NativeStart.main(Native Method)\nI\/Process (  576): Sending signal. PID: 822 SIG: 3\nI\/dalvikvm(  822): threadid=7: reacting to signal 3\nI\/dalvikvm(  822): Wrote stack trace to '\/data\/anr\/traces.txt'\nI\/Process (  822): Sending signal. PID: 822 SIG: 9\nI\/ActivityManager(  576): Process net.example.example (pid 822) has died.\n<\/pre>\n<p>Relevant code, starting map activity from tab activity:<\/p>\n<pre><code>intent=new Intent().setClass(this, ExampleMaps.class);\nintent.putExtra(\"t1\",t1);\nintent.putExtra(\"t2\",t2);\nintent.putExtra(\"m1\",m1);\nintent.putExtra(\"details\",details);\nspec=tabHost.newTabSpec(\"Examples\").setIndicator(\"\", res.getDrawable(R.drawable.example_tab_icons_map)).setContent(intent);\nintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);\ntabHost.addTab(spec);\n(..)\ntabHost.setCurrentTab(0);\n<\/code><\/pre>\n<p>The map activity:<\/p>\n<pre><code>public class ExampleMaps extends MapActivity\n{\n  private MapController mapController;\n  private MapView mapView;\n  private LocationManager locationManager;\n\n  @Override\n  protected boolean isRouteDisplayed()\n  {\n    return false;\n  }\n\n  @Override\n  public void onCreate(Bundle savedInstanceState)\n  {\n    super.onCreate(savedInstanceState);\n\n    double t1=0, t2=0;\n    String alerttext=ExampleWidgetProvider.NODATA, mag, details=ExampleWidgetProvider.NODATA;\n    int m1=1;\n    Drawable drawable;\n\n    Bundle extras=getIntent().getExtras();\n    if(extras !=null)\n    {\n(..)\n<\/code><\/pre>\n<p>Afetr checking Android java.lang.VerifyError? and some other places I haven&#8217;t yet found a solution.<\/p>\n<p>The following already were set properly:<\/p>\n<p>project.properties<\/p>\n<pre><code>target=Google Inc.:Google APIs:3\n<\/code><\/pre>\n<p>Manifest, in &#8220;applications&#8221;:<\/p>\n<pre><code>\n    \n(...)\n\n\n<\/code><\/pre>\n<p>Including these in map activity:<\/p>\n<pre><code>import com.google.android.maps.Overlay;\nimport com.google.android.maps.OverlayItem;\nimport com.google.android.maps.GeoPoint;\nimport com.google.android.maps.MapActivity;\nimport com.google.android.maps.MapController;\nimport com.google.android.maps.MapView;\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In an appwidget I develop I have a problem that when I start a map activity in Android 2.1 and 1.5 it causes a crash. I only notriced this in 1.5 and 2.1, it may happen in 1.6 but I haven&#8217;t tested yet. The problem magically disappears if I let the app run for a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5677","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5677","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5677"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5677\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5677"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5677"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5677"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}