1

I am working on an Android Project of using goolge map. But when I try to run it on a tablet or HTC phone, it says the application has stopped unexpectedly. What kind of setting do I need to do, like adding library files and etc.

I have used my API key as well, so if this apps runs on a device, can I view the map or only the grid? what do we mean by signing the app?

MainActivity.java

package com.sulav.maptravis2;

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;

import android.os.Bundle;
import android.view.Menu;

public class MainActivity extends MapActivity {
MapView map;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    try{
    map=(MapView) findViewById(R.id.mvMain);
    map.setBuiltInZoomControls(true);
    }
    catch(Exception e){}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}

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

}

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

 <com.google.android.maps.MapView
    android:layout_width="fill_parent"        
    android:layout_height="fill_parent"
    android:id="@+id/mvMain"
    android:apiKey="AIzaSyBxPKfOUpiOK981HFNcXi6szt0Dn__tQko"
    />

</RelativeLayout>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sulav.maptravis2"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="7"
    android:targetSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

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

    <activity
        android:name="com.sulav.maptravis2.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest>

logcat output:

05-24 12:06:46.285: I/dalvikvm(7686): Could not find method android.security.MessageDigest.getInstance, referenced from method com.google.android.maps.KeyHelper.getSignatureFingerprint
05-24 12:06:46.285: W/dalvikvm(7686): VFY: unable to resolve static method 153: Landroid/security/MessageDigest;.getInstance (Ljava/lang/String;)Landroid/security/MessageDigest;
05-24 12:06:46.285: D/dalvikvm(7686): VFY: replacing opcode 0x71 at 0x0038
05-24 12:06:46.295: D/AndroidRuntime(7686): Shutting down VM
05-24 12:06:46.295: W/dalvikvm(7686): threadid=1: thread exiting with uncaught exception (group=0x409fe1f8)
05-24 12:06:46.305: E/AndroidRuntime(7686): FATAL EXCEPTION: main
05-24 12:06:46.305: E/AndroidRuntime(7686): java.lang.NoClassDefFoundError: android.security.MessageDigest
05-24 12:06:46.305: E/AndroidRuntime(7686):     at com.google.android.maps.KeyHelper.getSignatureFingerprint(KeyHelper.java:60)
05-24 12:06:46.305: E/AndroidRuntime(7686):     at com.google.android.maps.MapActivity.createMap(MapActivity.java:552)
05-24 12:06:46.305: E/AndroidRuntime(7686):     at com.google.android.maps.MapActivity.onCreate(MapActivity.java:422)
05-24 12:06:46.305: E/AndroidRuntime(7686):     at com.sulav.maptravis2.MainActivity.onCreate(MainActivity.java:13)
05-24 12:06:46.305: E/AndroidRuntime(7686):     at android.app.Activity.performCreate(Activity.java:4465)
05-24 12:06:46.305: E/AndroidRuntime(7686):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
05-24 12:06:46.305: E/AndroidRuntime(7686):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
05-24 12:06:46.305: E/AndroidRuntime(7686):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-24 12:06:46.305: E/AndroidRuntime(7686):     at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-24 12:06:46.305: E/AndroidRuntime(7686):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-24 12:06:46.305: E/AndroidRuntime(7686):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-24 12:06:46.305: E/AndroidRuntime(7686):     at android.os.Looper.loop(Looper.java:137)
05-24 12:06:46.305: E/AndroidRuntime(7686):     at android.app.ActivityThread.main(ActivityThread.java:4424)
05-24 12:06:46.305: E/AndroidRuntime(7686):     at java.lang.reflect.Method.invokeNative(Native Method)
05-24 12:06:46.305: E/AndroidRuntime(7686):     at java.lang.reflect.Method.invoke(Method.java:511)
05-24 12:06:46.305: E/AndroidRuntime(7686):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-24 12:06:46.305: E/AndroidRuntime(7686):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-24 12:06:46.305: E/AndroidRuntime(7686):     at dalvik.system.NativeStart.main(Native Method)
Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
Sulav Timsina
  • 703
  • 7
  • 20

1 Answers1

0

Not sure if you just failed to paste it in but it appears your layout is missing this at the top.

<?xml version="1.0" encoding="utf-8"?>

Regardless check this link out: What is 'android.security.MessageDigest''?

Community
  • 1
  • 1
Larry McKenzie
  • 3,253
  • 25
  • 22
  • adding that line also doesn't help :( – Sulav Timsina May 24 '13 at 06:23
  • Ok what are you trying to run this on? – Larry McKenzie May 24 '13 at 06:24
  • On a HCL Tablet android 4.0.3. it has no GPS – Sulav Timsina May 24 '13 at 06:26
  • Just curious... Try running your app in an emulator to see if you get the same error. – Larry McKenzie May 24 '13 at 06:28
  • I am having problem with my emulators(AVDs).recently ,its been some days,they start very slow,or get stuck on the "android" screen. – Sulav Timsina May 24 '13 at 06:31
  • I edited my answer, it seems that this error is related to your device manufacturer using an old google maps library but you should be able to fix it. – Larry McKenzie May 24 '13 at 06:33
  • It runs on HTC aria. but it doesn't show tha map.but only the grid with a google logo at the bottom left of the screen(map grid) – Sulav Timsina May 24 '13 at 06:36
  • The grid has to do with your api key. You have likely created an api key that works with a signed application. You will need one that works with your debug signing key. See here: https://developers.google.com/maps/documentation/android/start#obtaining_an_api_key – Larry McKenzie May 24 '13 at 06:56
  • so u mean if i don't want to upload it to google play i dont need the api key? how do i get the debug signing key? – Sulav Timsina May 24 '13 at 07:38
  • No you need the a pi key to make the map display but you need a key based off your production signing key for production and a key based on your development or debug signing key when developing. The link I posted in the above comment explains it. – Larry McKenzie May 24 '13 at 14:16