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. WebView request monitoring

Hi all.

I open up an Activity with a WebView, and load up a URL which allows
the user to fill in a form, going through a series of pages.

I need to monitor the requests, to look at what stage of the process
they're at, then act at a certain point.

How can I get hold of the requests made by the WebView please?

-- 

2. libaudio

ok searched and searched and found lots of people asking but no
answer.

I'm building froyo and it fails with the below error

Install: out/target/product/omap2420/system/bin/dexopt
make: *** No rule to make target `out/target/product/omap2420/obj/lib/
libaudio.so', needed by `out/target/product/omap2420/obj/
SHARED_LIBRARIES/libaudioflinger_intermediates/LINKED/
libaudioflinger.so'

obviously I have no libaudio.so so I got alsa_sound but not sure how
to get it to build.  I looked at a page that talked about android
porting and well after putting the files in what is supposed to be the
proper place I still get nothing

any one got this working?

thanks,
Joe

-- 

3. Include .jar file in my project?

4. disable log messages "dataCallback(16, 0x11af10)" when using mCamera.setPreviewCallback(this);

5. Dex not working with spaces in path on the new android platform tools (V8)

6. Can not find target after updating android 2.3 sdk

7. who can give me android 2.2 system source code ?