1

I am trying implement In-App billing in my Androd app and when I test the purchase functionality I get the error "This version of the application is not configured for billing through Google Play."

I suspect that I did not properly generate a signed APK and that the problem is with my buil.gradle file.

I genereated a keystore by following the instructions here and generated .jks. My question is what exactly do I put for the storeFile file() in signingConfigs?

The following example is from the Android docs:

signingConfigs {
    release {
        storeFile file("myreleasekey.keystore")
        storePassword "password"
        keyAlias "MyReleaseKey"
        keyPassword "password"
    }
}

Simply putting the path to my .jks file didn't work. Is a .jks file different than a .keystore file? If so, how do I genereate a .keystore?

UPDATE

I learned that the .keystore and .jks are arbitrary file extensions from this answer.

My plan is to simply copy the my keystore.jks file in to the app directory then add the tag as follows:

    storeFile file("keystore.jks")

Is this correct? Unfortunately it will take a few hours for the apk to be published by Google Play so I can't get a quick answer on this.

Community
  • 1
  • 1
ChemDev
  • 827
  • 1
  • 8
  • 23

3 Answers3

2

I solved the problem. The key was to choose the app directory as the key store path.

Here are detailed instructions on how I generated a signed apk in Android Studio:

  1. Go to Build->Generate Signed apk
  2. Select the app module, click next.
  3. Under Key store path, click create new.
  4. The following window will pop up. enter image description here Select your app directory for the keystore path. It will create a keystore with default name "keystore.jks". You can change it if you like.
  5. Enter a password for the keystore. We will call it "StorePassword"
  6. Enter a Key Alias (let's call it "KeyAlias") and a Key password (let's call it "KeyPassword")
  7. In the build.gradle file add the following:

Example Signing config:

 signingConfigs {
    release {
        storeFile file("keystore.jks")
        storePassword "StorePassword"
        keyAlias "KeyAlias"
        keyPassword "KeyPassword"
    }
}
  1. Continue through the Generate Signed apk Wizard and enter in the appropriate passwords and generate the apk. The key is to make sure that the build.gradle is updated in the final signed apk.
  2. To confirm that you successfully signed the .apk see this question.

And of course, have secure backups and be extremely protective of the keystore once it is genereated.

Community
  • 1
  • 1
ChemDev
  • 827
  • 1
  • 8
  • 23
1
keytool -genkey -v -keystore name_of_your_file.keystore -alias your_alias -keyalg RSA -keysize 2048 -validity 10000

This is command will generate new keys

  • change name_of_your_file for your name
  • and your_alias for your alias

the keystore will be generated in folder where you call this

Then add this to your build.gradle

signingConfigs { 
    config { 
        storeFile file("${rootDir}/name_of_your_file.keystore") 
        storePassword "qwerty" 
        keyAlias "your_alias" 
        keyPassword "qwerty" 
    } 
}

buildTypes { 
    release { 
        signingConfig android.signingConfigs.config 
    }
} 

but change qwerty to your password and your_alias to your alias name which you use when you generate keystore and name_of_your_file to name of your kestore

clean your project and run ./gradlew task assembleRelease

Jared Burrows
  • 54,294
  • 25
  • 151
  • 185
Mounir Elfassi
  • 2,242
  • 3
  • 23
  • 38
  • Thanks for your answer. I posted my solution to the problem in which I generate the keystore using Android Studio. – ChemDev Mar 16 '15 at 01:04
0

In Android Studio go to Build->Generate Signed apk and follow steps. You don't need to add signingConfigsin build.gradle At least on current android studio version which is 1.3.2

user2661518
  • 2,677
  • 9
  • 42
  • 79