in android studio 2 you can save key store password and key password but in android studio 3 you can just save key password and you have to write key store password every time you want to build apk is there a settings or way to save key store password in android studio 3?
I Know I can save the password in my build.gradle file but I don't want to password be saved on git.
I am having the same issue. But you can add your signing configs this way so they won't be checked into version control:
Put this into ~/.gradle/gradle.properties
RELEASE_STORE_FILE={path to your keystore}
RELEASE_STORE_PASSWORD=*****
RELEASE_KEY_ALIAS=*****
RELEASE_KEY_PASSWORD=*****
Modify your build.gradle like this:
...
signingConfigs {
release {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
Source: How to create a release signed apk file using Gradle?
It seems to be a bug.
On Mac you can fix this by manually adding a Keychain Access entry:
Related
I made this Android app that fetches some data using AI Platform Training & Prediction API from Google Cloud Platform. For this app to work it needs to be approved by GCP using SHA-1 Fingerprint certificate. I am making this app as an assessment for module Im taking at the university, so, when the teacher will open my Android Studio project it will have a different SHA-1, so the app will not fetch the data...
Any Ideas how I might be able to maybe set a permanent SHA-1 key for my project, so when the teacher will open the project, Android Studio will not generate a new one?
Thank you!
The SHA-1 is based on the app signature. Since this is for a project I suggest you do the following (never do this in a production app).
Create a new signing key (Build -> Generate Signed Apk -> APK ->
Create New)
Move the signing key to your project's folder
Add this to your app.gradle
android {
signingConfigs {
debug{
storeFile file("your_key.keystore")
storePassword 'password'
keyAlias 'alias'
keyPassword 'password'
}
release {
storeFile file("your_key.keystore")
storePassword 'password'
keyAlias 'alias'
keyPassword 'password'
}
}
}
EDIT: Forgot to mention, run the signingReport gradle task after you do this to get your new SHA-1 that you have to add to your project.
after creating the .keystore file and running the report I get the new SHA-1 key, but the build fails. I get this:
Entry name 'play-services-ads-identifier.properties' collided
I'm using gradle (assembleRelease) to generate the release apk.
I have saved the keystore file in project/app/filename.keystore (Within the application)
I have specified details related to signing in gradle.properties file
RELEASE_STORE_FILE=filename.keystore
RELEASE_STORE_PASSWORD=****
RELEASE_KEY_ALIAS=alias
RELEASE_KEY_PASSWORD=****
My build.gradle file has the following related to signing
signingConfigs {
release {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
}
}
I have specified signing configurations in the same gradle file as below
buildTypes {
release {
signingConfig signingConfigs.release
}
}
However, when I'm trying to create the release build I keep getting following error
Error:Execution failed for task ':app:package<flavor>Release'.
> Failed to read key from keystore
I tried following
Giving a wrong password to see if the file can be found.Gives the following error with correct path there for I assume the file can be found.
Failed to read key from store "": Keystore was tampered with, or password was incorrect
Appreciate your input!
My problem was that I had entered a random keyAlias. When trying to sign the apk using the IDE (IntlliJ Idea and Android Studio: Build menu -> generate signed APK), by clicking the ellipse button (...) next to the textbox for entering key alias, I found the correct key alias that I had earlier set for my keystore. Double check that you are not entering some ad-hoc random password and keyAlias for your keystore as they should be identical to the password and key alias you set for your keystore when creating it.
If you have forgotten either the password or the key alias, I am afraid you have to create a new keystore as you cannot read your keystore without these. I suggest saving these two properties (and attaching your keystore file) in a password manager like Lastpass, as you need them in future.
I was using double-quotes with alias and passwords as shown below
storePassword="spass"
keyAlias="kalias"
keyPassword="kpass"
Removing double-quotes solved my problem
storePassword=spass
keyAlias=kalias
keyPassword=kpass
My problem was that I had extra whitespace in the gradle.properties file. So if you have entries like this:
MYAPP_RELEASE_KEY_ALIAS=my-key-alias(\s)(\r\n)
Make sure there is no leading whitespace for all the entries:
MYAPP_RELEASE_KEY_ALIAS=my-key-alias(\r\n)
I have not fully fixed this issue, but I think it is related to the following entries in 'Telegram\TMessagesProj\build.gradle':
signingConfigs {
debug {
storeFile file("config/release.keystore")
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
}
release {
storeFile file("config/release.keystore")
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
}
}
Note that the DEBUG config is set to us a 'release.keystore'.
The passwords and alias are stored in 'Telegram\gradle.properties' and I have had some success by changing these to the ones I use when signing APKs and changing the debug line to point to your own signing key (created through Android Studio).
E.g. Change the line to
debug {
storeFile file("path/to/your/signing/key/ApkSigning.jks")
...
}
And set the appropriate passwords and alias in the gradle properties file.
Hope that helps.
I've been developing my project in Eclipse IDE. The app is submitted on Play Store, and I've published a couple of versions updates successfully.
Recently I've migrated to Android Studio (and gradle, of course). I've done some changes to the project code base, including min and target sdk changes, but package name remains the same. The project is successfully compiled and debug app is successfully assembled and running ok.
But now I can not assemble a release version because of :
Keystore was tampered with, or password was incorrect
The keystore have not changed, and I do know it's password.
I've set signingconfigs in build.gradle:
android {
...
signingConfigs {
release {
storeFile file("keystore/motolife.keystore")
storePassword "***"
keyAlias "motolife"
keyPassword "***"
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
...
}
I've tried also to sign using jarsigner:
jarsigner -verbose -keystore keystore/motolife.keystore build/outputs/apk/motolife-new-debug.apk motolife
But no luck.
I've even installed gradle support for Eclipse and tried to assemble signed release app , but got the same "Keystore was tampered with, or password was incorrect" error.
try doing something like this then:
release {
storeFile file("keystoreName.keystore") //change value per signing
def pass = System.console().readPassword("\nPlease enter key password: ")
pass = new String(pass)
storePassword pass
keyAlias "revision3" //need to change these values per signing
keyPassword pass
}
As I am working with Google Maps API, I have been used to work with a custom debug key in Eclipse (that is in fact my production key)
This manipulation allowed me to use the same API key for Maps and most of Google Play Services (in app billing) in my debug and release build.
This was really convenient because there was no need to change the key in the manifest.
Unfortunately, with the migration to Android Studio, I am missing this feature.
Any idea where I can find this option back?
Thank a lot.
You define a keystore in your build.gradle file. See the Signing Configurations section here: https://developer.android.com/studio/build/index.html
In your case, you want to redefine the keystore for the debug variant:
android {
signingConfigs {
debug {
storeFile file("your.keystore")
}
}
}
However, you should really be using two different keystores for debug and release configurations.
On recent Android Studio 0.8.9 you will find this at a way better place:
File->Project Structure
Add a keystore at "Signing" Tab
Select it for your debug/release "Build types".
Make sure the alias name matchs with your keystore (keytool -list -v shows your alias name)
It creates the gradle stuff, syncrhonizes automatically on "Apply" and worked immediately like a charm.
Hi If you don't want to go for hard code all of this stuff , then go for below easy steps
->Your project
->Your Module
->Right click on your module
->go to open module settings
->Go to Signing section
->Specify all the attribute here and browse your Custom debug key in Store File
Then you will find below code which will be auto-create by android studio in build.gradle
signingConfigs {
debug {
storeFile file('custom_debug_keystore')
keyAlias 'androiddebugkey'
keyPassword 'android'
storePassword 'android'
}
}
Note:
1) Please do not use .keystore in the code manually you go for manual configuration
2) Please specify correct Alias and password
Here is a complete step-by-step that I took to move both of my keys out of the gradle.build file into a file that will not be included in any builds or repository commits.
1) Create a gradle.properties (if you don't already have one).
The location for this file depends on your OS:
/home/<username>/.gradle/ (Linux)
/Users/<username>/.gradle/ (Mac)
C:\Users\<username>\.gradle (Windows)
2) Add an entry pointing to yourprojectname.properties file.
(example for Windows)
yourprojectname.properties=c:\\Users\\<username>\\signing\\yourprojectname.properties
3) Create yourprojectname.properties file in the location you specified in Step 2 with the following information:
keystore=C:\\path\\to\\keystore\\yourapps.keystore
keystore.password=your_secret_password
4) Modify your gradle.build file to point to yourprojectname.properties file to use the variables.
if(project.hasProperty("yourprojectname.properties")
&& new File(project.property("yourprojectname.properties")).exists()) {
Properties props = new Properties()
props.load(new FileInputStream(file(project.property("yourprojectname.properties"))))
android {
signingConfigs {
release {
keyAlias 'release'
keyPassword props['keystore.password']
storeFile file(props['keystore'])
storePassword props['keystore.password']
}
debug {
keyAlias 'debug'
keyPassword props['keystore.password']
storeFile file(props['keystore'])
storePassword props['keystore.password']
}
}
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "your.project.app"
minSdkVersion 16
targetSdkVersion 17
}
buildTypes {
release {
}
}
}
}
dependencies {
...
}
5) Enjoy! Now all of your keys will be outside of the root of the directory and yet you still have the joys of automation for each build.
If you get an error in your gradle.build file about the "props" variable it's because you are not executing the "android {}" block inside the very first if condition where the props variable gets assigned so just move the entire android{ ... } section into the condition in which the props variable is assigned then try again.
I pieced these steps together from the information found here and here.
You can specify the debug.keystore for your project independently.
Two steps with the following images: (Android Studio v0.5.2)
Step 1: Click the button of project structure.
Step 2: Add the debug.keystore as follows.
The keystore needs to be in build.gradle, example follows:
android{
signingConfigs {
release {
storeFile file('/path/platform.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
...
buildTypes {
release {
signingConfig signingConfigs.release
}
}
Eclipse didn't really ask for a password or alias, but gradle does. I believe Eclipse just assumed it was password:android and alias:androiddebugkey. This might not be true for your keystore but I would try it like that on gradle.
If you know the password, but you are not sure of the alias you can also run the following command to get the alias:
keytool -list -keystore /path/platform.keystore link
As pointed out, you can use the gradle file to specify it.
I also found very convenient to use the Home folder as part of the path. It makes it easier when working within a team. Here is my suggestion :
android {
signingConfigs {
debug {
storeFile file(System.properties['user.home']+"/.android/custom.debug.keystore")
}
}
}
I'm developing some applications that need system UID. So I made a special keystore file "PFDebug.keystore" made from AOSP's platform.pk8 and platform.x509.pem.
I set it in Eclipse >window >preferences >android >build >cutstom debug keystore. That works fine.
But I am also developing non-privileged applications that use my own debug.keystore file. So I have to change keystore file for each build. I know that default debug.keystore is used when I set blank.
How can I bind debug keystore files for each android project?
It's doable with gradle.
For each project you have a build.gradle in which you can specify a signingConfig. Like that :
signingConfigs {
debug {
storeFile file("../debug.keystore")
}
release {
storeFile file("../prod.keystore")
storePassword 'prod'
keyAlias 'prod'
keyPassword 'prod'
}
}