Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Use signing.properties file which controls which keystore to use to sign the APK with gradle.
android {
signingConfigs {
release
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
def Properties props = new Properties()
def propFile = new File('signing.properties')
if (propFile.canRead()){
props.load(new FileInputStream(propFile))
if (props!=null && props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') &&
props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) {
android.signingConfigs.release.storeFile = file(props['STORE_FILE'])
android.signingConfigs.release.storePassword = props['STORE_PASSWORD']
android.signingConfigs.release.keyAlias = props['KEY_ALIAS']
android.signingConfigs.release.keyPassword = props['KEY_PASSWORD']
} else {
println 'signing.properties found but some entries are missing'
android.buildTypes.release.signingConfig = null
}
}else {
println 'signing.properties not found'
android.buildTypes.release.signingConfig = null
}
STORE_FILE=/path/to/your.keystore
STORE_PASSWORD=yourkeystorepass
KEY_ALIAS=projectkeyalias
KEY_PASSWORD=keyaliaspassword
@IlyaEremin

This comment has been minimized.

Show comment
Hide comment
@IlyaEremin

IlyaEremin commented Dec 21, 2015

Thanks!

@elbow95

This comment has been minimized.

Show comment
Hide comment
@elbow95

elbow95 commented Mar 7, 2016

Thanks!

@tavioto

This comment has been minimized.

Show comment
Hide comment
@tavioto

tavioto Mar 12, 2016

Thank you!! this solved my problem

tavioto commented Mar 12, 2016

Thank you!! this solved my problem

@huttarl

This comment has been minimized.

Show comment
Hide comment
@huttarl

huttarl Apr 7, 2016

Thank you, this helped me solve exactly the same problem you had.

huttarl commented Apr 7, 2016

Thank you, this helped me solve exactly the same problem you had.

@gkfillipus

This comment has been minimized.

Show comment
Hide comment
@gkfillipus

gkfillipus Sep 14, 2016

Very good thanks alot it also solved my problem the way

gkfillipus commented Sep 14, 2016

Very good thanks alot it also solved my problem the way

@camsteffen

This comment has been minimized.

Show comment
Hide comment

camsteffen commented Jan 30, 2017

@ajitdubey-mob-ibtech

This comment has been minimized.

Show comment
Hide comment
@ajitdubey-mob-ibtech

ajitdubey-mob-ibtech Dec 13, 2017

When I build project found error message

Error:(17, 0) Could not get unknown property 'release' for SigningConfig container of type org.gradle.api.internal.FactoryNamedDomainObjectContainer.

ajitdubey-mob-ibtech commented Dec 13, 2017

When I build project found error message

Error:(17, 0) Could not get unknown property 'release' for SigningConfig container of type org.gradle.api.internal.FactoryNamedDomainObjectContainer.

@zdavatz

This comment has been minimized.

Show comment
Hide comment
@zdavatz

zdavatz Feb 2, 2018

Great solution @gabrielemariotti thanks for sharing this!
This is how I did it: zdavatz/generika_android@e16af6f

zdavatz commented Feb 2, 2018

Great solution @gabrielemariotti thanks for sharing this!
This is how I did it: zdavatz/generika_android@e16af6f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment