As Android debug builds get reinstalled when the same phone is connected to different MacBooks, is there any way for all development machines (MacBooks) to share the same debug certificate? It will help to avoid reinstallation on development devices.
Easiest thing to do this would be to check the debug keystore into your project and then reference it in build.gradle like so:
signingConfigs {
debug {
storeFile file('../keystore/debug.keystore')
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
release {
// ...
}
}
I think that's possible. Android Studio automatically creates the debug keystore and certificate the first time you run or debug a project in Android Studio.
Simply go to :
~/.android/ folder on OS X and Linux
C:\Documents and Settings\.android\ on Windows XP
C:\Users\.android\ on Windows Vista and Windows 7, 8, and 10
on one of your development machine and find your debug.keystore file. Copy and paste the file on the other machines at the same location.
Hope it will work!
Yes you can.
To do that, just share the certificate file located at ~.android/debug.keystore with your teammates.
You can create your own keystore for debug builds too. On Mac, this is usually found at ~/.android folder. To create Keystore, you may do following:
Create a .properties file with your project name(say, projectname.properties) file and store it somewhere in your project root or elsewhere.
Add following entries.
keystore=<path>\\filename.keystore
keystore.password=<password>
Now we need connect projectname.properties to our project. Open gradle.properties and add an entry.
projectname.properties=<path to .properties file>
We can access this properties now in gradle.build file.
You can check now if a .properties file is available.
if(project.hasProperty("yourprojectname.properties")
&& new File(project.property("yourprojectname.properties")).exists()) {
Properties propObj = new Properties()
propObj.load(new FileInputStream(file(project.property("yourprojectname.properties")))
// now we have 'propObj' object to access keystore.
}
use this propObj to sign app for debug build.
android {
signingConfigs {
release {
//.......
}
debug {
keyAlias 'debug'
keyPassword propObj['keystore.password']
storeFile file(propObj['keystore'])
storePassword propObj['keystore.password']
}
}
Related
I read many similar content but I couldn't find a solution.
I am a flutter developer, yesterday i signed an android application and sent it to google play.
I cannot find the key file I created or I am not sure if its name is the key.
I created it yesterday on this mac computer , but today there is no such file. I only have a file named 'private_key.pepk' on my desktop.
Can I find out where the path I chose when signing for the first time from my Android project? i need your help
Android developer that hasn't signed a Flutter app yet, but in build.gradle you should have something like this:
signingConfigs {
release {
storeFile file("EITHER A PATH OR RELATIVE PATH")
storePassword sPassword
keyAlias kAlias
keyPassword kPassword
}
}
I have multiple android dev workstations and I work on them to build Android apk and deploy them on one Android device. Whenever I change a workstation, I have to remove the app from the device and reinstall it with a new one. So all caches are removed after reinstall. I wonder whether there is a way for me to deal with multiple workstations sharing with one android device without reinstall. I think there must be something unique across multiple workstations.
This happens because different workstations have different debug keystore. You can achieve your intended behavior as follows:
You can create your own keystore (follow this SO for creating it), check it in your repository. Place this keystore in your project directory.
Change your debug config to use this new keystore. This will ensure your debug app is signed with same keystore across all your dev workstations
To do that change your build.gradle as follows:
android {
...
signingConfigs {
defaultConfig {
storeFile file(getRootDir().getPath() + "\<file-name>.keystore")
storePassword <your password>
keyAlias <your alias>
keyPassword <your password>
}
}
buildTypes {
debug {
signingConfig signingConfigs.defaultConfig
...
}
}
}
Commit the code and perform pull across all your dev workstations.
I have my keystore release.keystore in the path /home/ankit/keystores/release.keystore. I want to use the keypair aliased as example for signing an app that is built using Jenkins. However, I am unable to feed the address of the keystore in the Jenkins. Below is the screenshot:
As it can be seen, there is a drop down list against the key store label and it has no item. I tried to follow the official doc but I didn't get it.
I think I have to link the existing keypair somehow to Jenkins, so that it shows up in the drop down list. But I can't figure how.
Instead you could configure this all in gradle itself, which will work independent of any CI. First create a build.properties in root of your project and include following:
#Key store
keystore.release=../keys/release.keystore
keystore.debug=../keys/debug.keystore
keystore.key.alias=...
keystore.key.password=...
keystore.password=...
Now in your app modules build.gradle access those props:
final Properties props = new Properties()
props.load(new FileInputStream('build.properties'))
android {
signingConfigs {
release {
keyAlias props['keystore.key.alias']
keyPassword props['keystore.key.password']
storeFile file(props['keystore.release'])
storePassword props['keystore.password']
}
debug {
storeFile file(props['keystore.debug'])
}
}
buildTypes {
release {
...
signingConfig signingConfigs.release
}
debug {
...
signingConfig signingConfigs.debug
}
}
}
Now make sure it works in your local machine with ./gradlew clean assembleRelease (There's something else if you do in PC)
After that commit the changes and update the gradle build settings in your CI. And make sure those keystores are there.
From the Android Signing Jenkins Plugin documentation:
Before adding a Sign Android APKs build step to a job, you must configure a certificate credential using the Credentials Plugin's UI.
If you need more details about how to use the Credentials Plugin in Jenkins, here is the user guide.
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'
}
}