Sharing android debug certificate across different developer machines in Android Studio

余生颓废 提交于 2019-12-22 06:59:28

问题


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.


回答1:


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 {
        // ...
    }
}



回答2:


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!




回答3:


Yes you can.

To do that, just share the certificate file located at ~.android/debug.keystore with your teammates.




回答4:


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:

  1. Create a .properties file with your project name(say, projectname.properties) file and store it somewhere in your project root or elsewhere.
  2. Add following entries.
      keystore=<path>\\filename.keystore
      keystore.password=<password>
    
  3. Now we need connect projectname.properties to our project. Open gradle.properties and add an entry.
     projectname.properties=<path to .properties file>
    
  4. 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.
    
     }
    
  5. 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']
            }
        }
    


来源:https://stackoverflow.com/questions/54178735/sharing-android-debug-certificate-across-different-developer-machines-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!