0

I have developed my 1st application which is a location based reminder which uses google maps. When i debug my project from android studio to my device using USB cable everything goes fine but when i export my app by "Generating signed apk" in my device m unable to see map it's just a blank page with Google written below.. M unable to fetch the map.. M i missing something or is there another way to generate apk for google map project's ?

Have generated a keystore for release mode by using this command :-

keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

After this i added the signing configuration to the build file for the app module as :-

android {
signingConfigs {
    config {
        keyAlias 'ramu'
        keyPassword 'ramu@localert'
        storeFile file('C:/Program Files/Java/jdk1.8.0_25/bin/my-release-key.keystore')
        storePassword 'ramu@localert'
    }
    release {
        storeFile file('C:/Program Files/Java/jdk1.8.0_25/bin/my-release-key.keystore')
        storePassword 'ramu@localert'
        keyAlias 'ramu'
        keyPassword "password"
    }
}
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
    applicationId "com.example.anand.project"
    minSdkVersion 18
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.release
    }
    debug {
        signingConfig signingConfigs.config
    }
}

}

n now when i invoke assemblerelease m getting the following error :-

Error:Execution failed for task ':app:packageRelease'.

Failed to read key ramu from store "C:\Program Files\Java\jdk1.8.0_25\bin\my-release-key.keystore": Cannot recover key

Either i missed something and i am confused whether to generate a new keystore for release mode or should i use the debug keystore which i used for google maps api.. ? I ended up with generating more than 2 .apk's..

user2205230
  • 161
  • 1
  • 14
  • Have you followed the step for `Signing Your App in Android Studio`[here](http://developer.android.com/tools/publishing/app-signing.html#studio)? – bjiang Jun 01 '15 at 22:24
  • @bjiang yess for enabling google maps api i have followed to sign my app in debug mode which has a debug keystore and yesterday i followed the steps for release mode.. Have edited the post and added what i did.. please have a look.. – user2205230 Jun 02 '15 at 02:25
  • I noticed that you use the `Java1.8`, you may try to use `Java 1.7` which fully compatible. – bjiang Jun 02 '15 at 16:22
  • Thanx.. I found my solution for it.. – user2205230 Jun 02 '15 at 16:39

2 Answers2

0

You will get separate keys for debug keystore and release keystore. Debug keystore API key won't work for signed apk, you will have to get release API key.

Noor Nawaz
  • 2,007
  • 22
  • 34
  • As i am new to android m confused exactly what should i do.. I reffered android developers site to generate release key but it is saying that you need to create a keystore and private key.. what is it all about ? How can i create a private key ? Is the Google Map API V2 key is the key which i should use ? – user2205230 Jun 01 '15 at 18:33
  • Have you generate sha1 from debug keystore? if yes, then similarly you can generate sha1 from release keystore which you got from signed apk process. – Noor Nawaz Jun 01 '15 at 18:39
  • Also see this to generate sha1 from releasse keystore [read this](http://stackoverflow.com/questions/3997748/how-can-i-create-a-keystore) – Noor Nawaz Jun 01 '15 at 18:40
  • Yess i have generated my SHA1 key from debug keystore for the google map to work.. – user2205230 Jun 01 '15 at 18:45
  • when you try to generate a signed apk, then you got a keystore, right? You can use that keystore to generate release API key – Noor Nawaz Jun 01 '15 at 18:46
  • .jks file is the keystore file you talking about ? – user2205230 Jun 01 '15 at 18:53
  • You should look at [this](http://stackoverflow.com/questions/15727912/sha-1-fingerprint-of-keystore-certificate) – Noor Nawaz Jun 01 '15 at 18:56
  • Yess this was the command which i used to get the SHA1 fingerprint.. keytool -list -alias androiddebugkey -keystore "C:\Documents and Settings\Anand\.android\debug.keystore" -storepass android -keypass android – user2205230 Jun 01 '15 at 18:57
  • debug.keystore which is here "C:\Documents and Settings\Anand\.android\debug.keystore" should i use this keystore for release mode ? – user2205230 Jun 01 '15 at 18:59
0

Well I found my solution for my problem.. For enabling my google map api i used debug keystore to get my SHA1 fingerprint and added the google map api key in my project. So when i try to run\release my application which has a debug keystore signature it wasn't fetching the map

Solution :-

The solution is u need to have a key generated by release mode to be able to view map after you run\release your app. Below is the procedure for signing your app with release mode :-

First create a keystore in command line by :-

keytool -genkey -v -keystore my-release-key.keystore -alias alias-name -keyalg RSA -keysize 2048 -validity 10000

You'll get the SHA1 fingerprint from the keystore

Use this to enable api n generate google map api key in google developers console.

Now, Goto Android Studio -> Build -> Generate Signed apk -> Locate the above created keystore by "Choose existing" -> Enter password which you gave while creating the keystore in command line -> Next -> Choose your destination folder where you want to save your .apk file -> Finish.

Now use this apk to run\release your project.

user2205230
  • 161
  • 1
  • 14