开发者

How to get Map on signed Android application?

I have created a map application. It shows the map without signing the APK but while I try to sign and later install that APK in device the map does not display an开发者_如何学Goy more.


You need a separate Google Maps API key for releasing. You say you are not signing the APK when it is working, but the application is actually being signed automatically by your SDK, using the debug key. This is probably the one for which you have a valid Google Maps API key as well.

From the documentation at https://code.google.com/android/add-ons/google-apis/mapkey.html:

While you are developing and debugging your application, you will likely be sigining your application in debug mode — that is, the SDK build tools will automatically sign your application using the debug certificate. To let your MapView elements properly display Maps data during this period, you should obtain a temporary Maps API Key registered to the debug certificate. To do so, you first need to get the MD5 fingerprint of the debug certificate. When you are ready to release your application, you must register your release certificate with the Google Maps service and obtain a new Maps API Key. You must then change the MapView elements in your application to reference the new API key.


Did you use the same api key on two places? Cause the api key needs to be unique on each server.

http://code.google.com/apis/maps/signup.html


You should generate another apiKey using the releasekey file which will be generate on signing. You will get new MD5 key using the following
keytool -list -keystore c:\Users\Sudheesh\releasekey where relesekey is the file which contains the sign release key. By using this MD5 key, you can generate the api key from http://www.mobisoftinfotech.com/blog/android/android-mapview-generate-api-key-using-java-keytool/ Use this apikey in your app.


its better to do in this way

Select the project in workspace-->rightclick---> click export--->export android apps-->next-->next--->enter keystore file name--->next--->enter key alis--->finish

(Please see this here)


Like what RogerKK said, how are you doing your tests/deployments? If you initially Debugged the application against a connected Android device, that is most likely using a Debug Certificate SHA-1 generated key. If you attempted to do a Release build, it requires a completely different key.

Here is what i ran through, but using a Debug certificate to sign.

http://www.digitalopium.com/android-google-maps-api-tutorial/


For all friends who are facing the same problem that nirav patel have.

You can use the following code to find the signed and unsigned hash key

public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        try

        {

            PackageInfo info = getPackageManager().getPackageInfo("Your package name here",PackageManager.GET_SIGNATURE);

            for (Signature signature : info.signatures)
            {
                MessageDigest md = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());
                Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
            }
        } 
        catch (NameNotFoundException e)
        {
            System.out.println("name not found...."+e);
        } catch (NoSuchAlgorithmException e) 
        {
            System.out.println("NoSuchAlgorithmException...."+e);
        }
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜