How to sign debug APK's with the same key as release APK's - Android Studio

b85411 picture b85411 · Dec 5, 2016 · Viewed 9.3k times · Source

I want to test in-app purchasing within my app, but it seems impossible to do this with a regular debug APK through Android Studio? Has anyone done this before and if so what steps did you take to do it?

I was thinking to get around it I should try signing my debug APK's in the same way I sign my release APK's. How can I do this?

Answer

Jacob picture Jacob · Dec 5, 2016

You can config that in your android studio, right click your project, chose the open module settings

Or if you are crazy about the hand-writen build scripts, here is a snapshot of code:

android {
  signingConfigs {
    release {
      storeFile file(project.property("MyProject.signing") + ".keystore")
      storePassword "${storePassword}"
      keyAlias "${keyAlias}"
      keyPassword "${keyPassword}"
    }
  }

  buildTypes {
    release {
      signingConfig signingConfigs.release
    }
    debug {
      signingConfig signingConfigs.release
    }
  }
}

Just config your debug and release build type with same signingConfig.