MapActivity / MapView causes application to crash at startup

by bw » Mon, 10 Nov 2008 10:33:26 GMT


Sponsored Links
 Hi,

I'm trying to create a new application with a MapView.
When I first create a new Android project in Eclipse, I run it in the
emulator and get the expected "Hello, [project name]" message.
Then, I try changing "Activity" to "MapActivity" and adding a MapView
(I've tried both the xml and the code route):


public class MyMap extends MapActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        MapView mMapView = new MapView(this, "my_map_api_key");
        mMapView.setClickable(true);
        mMapView.setEnabled(true);
        mMapView.setSatellite(true);
        setContentView(mMapView);

    }


        @Override
        protected boolean isRouteDisplayed() {
                // TODO Auto-generated method stub
                return false;
        }
}


However, when I run this in the emulator, it immediately crashes with
the "Application has stopped unexpectedly" error. The debugger shows
this error:


Thread [<3> main] (Suspended (exception RuntimeException))
        ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord)
line: 2068
        ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord)
line: 2156
        ActivityThread.access$1800(ActivityThread, ActivityThread
$ActivityRecord) line: 112
        ActivityThread$H.handleMessage(Message) line: 1580
        ActivityThread$H(Handler).dispatchMessage(Message) line: 88
        Looper.loop() line: 123
        ActivityThread.main(String[]) line: 3742
        Method.invokeNative(Object, Object[], Class, Class[], Class, int,
boolean) line: not available [native method]
        Method.invoke(Object, Object...) line: 515
        ZygoteInit$MethodAndArgsCaller.run() line: 739
        ZygoteInit.main(String[]) line: 497
        NativeStart.main(String[]) line: not available [native method]


I know I'm making some stupid mistake.. but I can't figure it out.

-Ben
--~--~---------~--~----~------------~-------~--~----~



MapActivity / MapView causes application to crash at startup

by bw » Mon, 10 Nov 2008 11:13:16 GMT


 Got it..

"This is not a standard package in the Android library. In order to
use it, you must add the following XML element, as a child of the
application  element, in your AndroidManifest.xml file:

<uses-library android:name="com.google.android.maps" />


From:

 http://code.google.com/android/toolbox/apis/lbs.html 

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


MapActivity / MapView causes application to crash at startup

by bw » Mon, 10 Nov 2008 11:44:08 GMT


 Also had to add

<uses-permission android:name="android.permission.INTERNET" />

above my application tag.

(Source:



MapActivity / MapView causes application to crash at startup

by Frank Trollmann » Tue, 11 Nov 2008 00:10:08 GMT


 Hi

You might want to look here:

 http://zackola.com/blog/2008/10/26/android-mapview-permissions-and-prerequisites/ #comment-227

this site subsumes (hopefully) all permissions and prerequisites
needed for the MapView.

- Frank

--~--~---------~--~----~------------~-------~--~----~



MapActivity / MapView causes application to crash at startup

by Billsen » Tue, 11 Nov 2008 03:15:23 GMT


 You need to generate a key for apikey for your emulator since Google
has started to enforce the rule to put real key in xml file.



> (Source:



MapActivity / MapView causes application to crash at startup

by Dagger » Wed, 19 Nov 2008 15:24:51 GMT


 I am having the same problem but I am only implementing the Activity
Class which is included in the package by default.
THis is the partial code.

public class ActiveOctave extends Activity implements OnErrorListener,
        OnBufferingUpdateListener, OnCompletionListener,
        OnPreparedListener, SurfaceHolder.Callback {

        private static final String TAG = "VideoPlayer";
    private MediaPlayer mp;
    private SurfaceView mPreview;
    private EditText mPath;
    private SurfaceHolder holder;
    private ImageButton mPlay;
    private ImageButton mPause;
    private ImageButton mReset;
    private ImageButton mStop;
    private String current;
    /**
     * Called when the activity is first created.
     */
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);
        // Set up the play/pause/reset/stop buttons
        mPreview = (SurfaceView) findViewById(R.id.surface);
        mPath = (EditText) findViewById(R.id.path);
        mPlay = (ImageButton) findViewById(R.id.play);
        mPause = (ImageButton) findViewById(R.id.pause);
        mReset = (ImageButton) findViewById(R.id.reset);
        mStop = (ImageButton) findViewById(R.id.stop);

This is my Debug Stack.
Thread [<3> main] (Suspended (exception RuntimeException))
        ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord)
line: 2131
        ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord)
line: 2147
        ActivityThread.access$1800(ActivityThread, ActivityThread
$ActivityRecord) line: 112
        ActivityThread$H.handleMessage(Message) line: 1572
        ActivityThread$H(Handler).dispatchMessage(Message) line: 88
        Looper.loop() line: 123
        ActivityThread.main(String[]) line: 3708
        Method.invokeNative(Object, Object[], Class, Class[], Class, int,
boolean) line: not available [native method]
        Method.invoke(Object, Object...) line: 492
        ZygoteInit$MethodAndArgsCaller.run() line: 734
        ZygoteInit.main(String[]) line: 492
        NativeStart.main(String[]) line: not available [native method]

Please help what to Do.





> > (Source:



MapActivity / MapView causes application to crash at startup

by Alemao » Wed, 10 Dec 2008 03:40:51 GMT


 I'm also having the same issue. I even tried a very simple example
from Android's documentation ( http://code.google.com/android/samples/ 
ApiDemos/src/com/example/android/apis/view/MapViewDemo.html) but the
result is the same: "Application has stopped unexpectedly".

I added all the permissions ( http://zackola.com/blog/2008/10/26/ 
android-mapview-permissions-and-prerequisites/#comment-227) and also
the lib access ( http://code.google.com/android/toolbox/apis/lbs.html ),
but the application still crashes.

What I did is simply to create a "new Android activity" and replace
the default code to the one from Android's documentation, then I added
the permissions to the Manifest.xml file. Am I missing something? Does
anybody know why I can't start a MapActivity?

--~--~---------~--~----~------------~-------~--~----~



MapActivity / MapView causes application to crash at startup

by Aldo Neto » Wed, 10 Dec 2008 03:53:25 GMT


 Never mind. I was adding the LIB in the wrong place of the Manifest.XML
file.
Thanks anyway.






--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. "Hello World"-where it comes from (SOLVED)

Hi all,

Found where it's coming from: res>values>strings.xml.

Any way, expect more helps from this group...








--~--~---------~--~----~------------~-------~--~----~

2. Rotating an image using Drawable

Hi,

I have an image which I got from my resource as below:

android.graphics.drawable.Drawable CarImage =
context.getResources().getDrawable(R.drawable.car);
Rect carRect= new Rect(x, y, x + 10, y + 10);
CarImage.setBounds(carRect);
CarImage.draw(canvas);

Now I want to draw it again on canvas but before drawing want to
rotate it by 180 degree.(want to invert it)

I tried all possible ways but can't rotate it. I also tried to use
RotateDrawable but didn't get how to use level parameter to rotate it.

Could any one plz send me a sample example to rotate image using
Drawable or RotateDrawable  class.

Thanks,
Ramesh

--~--~---------~--~----~------------~-------~--~----~

3. Developing in C\C++ for Android

4. HTC Dream + Android, sans T-Mobile deal?

5. Frame Layout

6. BroadCastReceiver with PhoneStateListener

7. I need a favor please from someone who has Real HTC Device (new androind GPhone)....