Adrian Adrian - 1 month ago 12
Android Question

Gradle does not find property for Properties file in Android Studio

I have run into this problem when I wanted to make a release build of my android app. This worked fine a couple of days ago but now it dosnt seem to work for some reason. I haven't touched the file gradle file except for adding the second compile dependancie for Picasso lib. The properties file hasn't been changed and neither the keystore.

This is what I get whe trying to build.

Error:A problem was found with the configuration of task ':app:packageRelease'.
> File 'C:\Users\MyName\AndroidStudioProjects\MyApp\app\'\C:\Users\MyName\Documents\keystores\android.keystore'' specified for property 'signingConfig.storeFile' does not exist.


build.gradle

apply plugin: 'com.android.application'

android {
signingConfigs {
releaseConfig
}
compileSdkVersion 17
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "org.happymtb.unofficial"
minSdkVersion 16
targetSdkVersion 17
signingConfig signingConfigs.releaseConfig
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}

dependencies {
compile 'com.android.support:support-v4:21.0.+'
compile 'com.squareup.picasso:picasso:2.5.2'
}

def Properties props = new Properties()
def propFile = 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.releaseConfig.storeFile = file(props['STORE_FILE'])
android.signingConfigs.releaseConfig.storePassword = props['STORE_PASSWORD']
android.signingConfigs.releaseConfig.keyAlias = props['KEY_ALIAS']
android.signingConfigs.releaseConfig.keyPassword = props['KEY_PASSWORD']
} else {
android.buildTypes.releaseConfig.signingConfig = null
}
}else {
android.buildTypes.release.signingConfig = null
}


signing.properties

STORE_FILE='//C:/Users/MyName/Documents/keystores/android.keystore'
STORE_PASSWORD='passw'
KEY_ALIAS='myalias'
KEY_PASSWORD='passw'

Answer

Managed to solve it by updating all the libs. Cleanung/rebuilding the project alot of times and changing signing.properties file to this (basically removing all '):

STORE_FILE=//C:/Users/MyName/Documents/keystores/android.keystore
STORE_PASSWORD=passw
KEY_ALIAS=myalias
KEY_PASSWORD=passw