Is there any ability to include file inside build.gradle file?
I want to separate same configurations from few projects into one file and than just include it inside build.gradle.
For example, now I have file like this:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 15
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.myapp"
minSdkVersion 15
targetSdkVersion 22
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
println outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def manifestParser = new com.android.builder.core.DefaultManifestParser()
def version = manifestParser.getVersionName(android.sourceSets.main.manifest.srcFile)
def fileName = outputFile.name.replace('.apk', "-${version}.apk")
println fileName
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'
}
lintOptions {
abortOnError false
}
//Signing app
if(project.hasProperty("debugSigningPropertiesPath") && project.hasProperty("releaseSigningPropertiesPath")) {
File debugPropsFile = new File(System.getenv('HOME') + "/" + project.property("debugSigningPropertiesPath"))
File releasePropsFile = new File(System.getenv('HOME') + "/" + project.property("releaseSigningPropertiesPath"))
if(debugPropsFile.exists() && releasePropsFile.exists()) {
Properties debugProps = new Properties()
debugProps.load(new FileInputStream(debugPropsFile))
Properties releaseProps = new Properties()
releaseProps.load(new FileInputStream(releasePropsFile))
signingConfigs {
debug {
storeFile file(debugPropsFile.getParent() + "/" + debugProps['keystore'])
storePassword debugProps['keystore.password']
keyAlias debugProps['keyAlias']
keyPassword debugProps['keyPassword']
}
release {
storeFile file(releasePropsFile.getParent() + "/" + releaseProps['keystore'])
storePassword releaseProps['keystore.password']
keyAlias releaseProps['keyAlias']
keyPassword releaseProps['keyPassword']
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
signingConfig signingConfigs.release
}
}
}
}
}
And I want to simplify it something like this
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 15
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.myapp"
minSdkVersion 15
targetSdkVersion 22
}
include 'applicationVariants.gradle'
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'
}
lintOptions {
abortOnError false
}
include 'signing.gradle'
}
You can include an an external build script. Check the official guide:
Just use:
apply from: 'signing.gradle'
i have done some thing like this.
in my libraries.gradle
ext {
//Android
targetSdkVersion = 22;
compileSdkVersion = 22;
buildToolsVersion = '22.0.1'
....
dagger2Version = '2.0'
butterknifeVersion = '6.1.0'
appCompatVersion = '22.2.0'
designVersion = '22.2.0'
recyclerViewVersion = '22.2.0'=
libraries = [
supportAnnotations: "com.android.support:support-annotations:${androidSupportAnnotationsVersion}",
googlePlayServices: "com.google.android.gms:play-services:${googlePlayServicesVersion}",
recyclerView : "com.android.support:recyclerview-v7:${recyclerViewVersion}",
picasso : "com.squareup.picasso:picasso:${picassoVersion}",
cardView : "com.android.support:cardview-v7:${cardViewVersion}",
appCompat : "com.android.support:appcompat-v7:${appCompatVersion}",
design : "com.android.support:design:${designVersion}",
findBugs : "com.google.code.findbugs:jsr305:${findbugsVersion}",
gson : "com.google.code.gson:gson:${gsonVersion}",
flow : "com.squareup.flow:flow:${flowVersion}",
butterknife : "com.jakewharton:butterknife:${butterknifeVersion}",
rxjava : "io.reactivex:rxjava:${rxjavaVersion}",
rxandroid : "io.reactivex:rxandroid:${rxandroidVersion}",
androidSupport : "com.android.support:support-v13:${androidSupportVersion}",
androidSupportV4: "com.android.support:support-v4:${androidSupportVersion}",
javaxInject : "javax.inject:javax.inject:${javaxInjectVersion}",
retrofit : "com.squareup.retrofit:retrofit:${retrofitVersion}",codec:${commonsCodecVersion}","com.facebook.stetho:stetho:${stethoVersion}",
apache : "org.apache.commons:commons-lang3:${apacheVersion}",
libPhoneNumber : "com.googlecode.libphonenumber:libphonenumber:$libPhoneNumber",
dagger2 : "com.google.dagger:dagger:${dagger2Version}",
dagger2Compiler : "com.google.dagger:dagger-compiler:${dagger2Version}",
javaxAnnotations : "javax.annotation:javax.annotation-api:${javaxAnnotationVersion}"
]
}
in my app.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':logic')
compile project(':local-resources')
compile project(':api')
compile rootProject.ext.libraries.appCompat
compile libraries.design
compile rootProject.ext.libraries.recyclerView
compile rootProject.ext.libraries.butterknife
compile rootProject.ext.libraries.dagger2
compile libraries.rxandroid
compile libraries.stetho
compile libraries.cardView
compile libraries.picasso
apt rootProject.ext.libraries.dagger2Compiler
or apply from: rootProject.file('checkstyle.gradle')
Related
I am trying to debug my error with Proguard. My project is working fine with debug but not with Proguard. Any help will be appreciated.
I have tried with ignore warning in Proguard. However application is crashing with generated APK.
Current Proguard settings is not working. Messages console I have uploaded to Gist
Build.gradle is given below
Prodguard-project.txt in gist
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
build.gradle
apply plugin: 'com.android.application'
apply from: rootProject.file('gradle/codequality.gradle')
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
versionCode 49
versionName "1.8.8"
minSdkVersion 14
targetSdkVersion 22
buildConfigField 'String', 'BUILD_TAG', '"' + getBuildTag() + '"'
buildConfigField 'String', 'OWM_API_KEY', '"' + getOpenWeatherMapApiKey() + '"'
buildConfigField 'boolean', 'ENABLE_WEATHER', 'true'
def buildSuffix = getBuildSuffix(versionName, versionCode)
applicationVariants.all { variant ->
def file = variant.outputs[0].outputFile
variant.outputs[0].outputFile = new File(file.parent, file.name.replace(".apk", "-" + buildSuffix + ".apk"))
}
}
if (project.hasProperty('signingKeyStoreFile')) {
signingConfigs {
release {
storeFile file(signingKeyStoreFile)
storePassword signingKeyStorePassword
keyAlias signingKeyAlias
keyPassword signingKeyPassword
}
}
}
buildTypes {
release {
minifyEnabled true
proguardFile 'proguard-project.txt'
if (project.hasProperty('signingKeyStoreFile')) {
signingConfig signingConfigs.release
}
}
}
lintOptions {
abortOnError false
checkReleaseBuilds false
disable 'MissingTranslation'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
def getBuildSuffix(versionName, versionCode) {
def suffix = versionName + '-' + versionCode
if (System.getenv()['BUILD_NUMBER'] != null) {
suffix += '-b' + System.getenv()['BUILD_NUMBER']
}
return suffix
}
def getBuildTag() {
def tag = ''
if (System.getenv()['BUILD_NUMBER'] != null) {
tag += 'b' + System.getenv()['BUILD_NUMBER']
} else {
tag += 'l'
}
tag += '#' + new Date().format('yyyyMMdd')
return tag
}
def getOpenWeatherMapApiKey() {
if (project.hasProperty('owmApiKey')) {
return owmApiKey
} else {
def apiKeyFile = file('default_owm_api_key');
if (apiKeyFile.isFile()) {
return apiKeyFile.text.trim()
}
}
return 'NOKEY'
}
///////////////////////////////////////////////////
// Dependencies
repositories {
mavenCentral()
}
dependencies {
//compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
//compile 'com.android.support:support-v4:19.1.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'net.danlew:android.joda:2.9.4.1'
compile 'com.google.android.gms:play-services-ads:9.8.0'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.google.android.gms:play-services-appindexing:9.8.0'
}
configurations {
all*.exclude group: 'com.google.firebase', module: 'firebase-core'
all*.exclude group: 'com.google.firebase', module: 'firebase-iid'
}
///////////////////////////////////////////////////
// Checkstyle
task checkstyleDebug(type: Checkstyle, dependsOn: 'compileDebugSources') {
source = fileTree('src/main/java/')
classpath = files('build/intermediates/classes/debug')
}
check.dependsOn checkstyleDebug
///////////////////////////////////////////////////
// Findbugs
task findbugsDebug(type: FindBugs, dependsOn: 'compileDebugSources') {
source = fileTree('src/main/java/')
classes = fileTree('build/intermediates/classes/debug')
classpath = files() // empty classpath!
effort = 'max'
excludeFilter = rootProject.file('config/findbugs/androidExcludeFilter.xml')
}
check.dependsOn findbugsDebug
///////////////////////////////////////////////////
// PMD
task pmd(type: Pmd) {
source = fileTree('src/main/java/')
ruleSets = ['java-basic', 'java-braces', 'java-android']
}
check.dependsOn 'pmd'
Try to add getDefaultProguardFile('proguard-android.txt') to the proguardFile 'proguard-project.txt', to get next row:
proguardFile getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
Or start to search the issues from your proguard-project.txt, like:
Add rule -keepattributes SourceFile,LineNumberTable,InnerClasses,Signature,Exceptions
Add rule -dontwarn com.google.**
And so on, by your proguard failed logs
I updated build tools, and can not compile my app.
I always got an error -
Error:Execution failed for task ':app:processProdDebugGoogleServices'.
Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is
available at
https://bintray.com/android/android-tools/com.google.gms.google-services/)
or updating the version of com.google.android.gms to 9.0.0.
my build.gradle-
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.google.gms:google-services:3.0.0'
//method count
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.3.0'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven {
url "https://dl.bintray.com/supersonic/android-sdk" }
maven {
url "https://clojars.org/repo" }
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
}
project.ext {
versionCode = 14
versionName = "1.1.0.3"
minSdkVersion = 15
compileSdkVersion = 22
sdkTools = '22.0.1'
appcompatVer = "com.android.support:appcompat-v7:22.2.1"
}
my app/build.gradle
def final UNIVERSAL_IMAGE_LOADER = '1.9.5'
def final MULTIVIEW_PAGER_VER = '1.0'
def final ACTIVE_ANDROID_VER = '3.1.0-SNAPSHOT'
def final CIRCLE_IMAGE_VER = '1.3.0';
def final OKHTTP_VER = '2.4.0';
def final EMOJI_VERSION = '1.0'
def final FACEBOOK_SDK_VER = '4.1.0'
def final ROUNDED_IMAGEVIEW_VER = '2.2.1'
def final GSM_VER = '9.0.0'
def final RECYCLER_VIEW_VER = '23.1.1'
def final FLURRY_VER = '6.2.0'
apply plugin: 'com.android.application'
//uncomment this and in top-gradle file to count num of refs
apply plugin: 'com.getkeepsafe.dexcount'
apply plugin: 'com.google.gms.google-services'
dexcount {
includeClasses = true
includeFieldCount = true
printAsTree = true
orderByMethodCount = true
verbose = true
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.sdkTools
packagingOptions {
//this resolves SignalR and Protobuf conflict
//start region
exclude 'package-list'
exclude 'index.html'
exclude 'help-doc.html'
exclude 'constant-values.html'
exclude 'allclasses-noframe.html'
exclude 'allclasses-frame.html'
exclude 'resources/tab.gif'
exclude 'resources/background.gif'
exclude 'resources/titlebar.gif'
exclude 'resources/titlebar_end.gif'
exclude 'stylesheet.css'
exclude 'overview-tree.html'
//end region
}
defaultConfig {
applicationId "dating.social.viche"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.compileSdkVersion
versionCode rootProject.ext.versionCode
versionName rootProject.ext.versionName
}
signingConfigs {
release {
storeFile file("../my-release-key.keystore")
storePassword "qwertysocialapp123"
keyAlias "egoistapp"
keyPassword "qwertysocialapp123"
}
qainvalid{
storeFile file("../debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
}
buildTypes {
debug{
applicationIdSuffix ".debug"
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-debug-rules.pro', 'proguard-rules.pro'
}
release {
lintOptions{
//to fix google error - google_id is not translated to other lang
checkReleaseBuilds false
}
minifyEnabled true
// debuggable false
// jniDebuggable false
// renderscriptDebuggable false
// zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
qa {
signingConfig signingConfigs.qainvalid
String versionName1 = rootProject.ext.versionName + '_QA'
versionName versionName1
}
prod {
signingConfig signingConfigs.release
versionName rootProject.ext.versionName
}
}
}
dependencies {
compile project(':signalr-client-sdk-android')
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "com.android.support:recyclerview-v7:${RECYCLER_VIEW_VER}"
compile "com.nostra13.universalimageloader:universal-image-loader:${UNIVERSAL_IMAGE_LOADER}"
compile "de.hdodenhof:circleimageview:${CIRCLE_IMAGE_VER}"
compile "com.pixplicity.multiviewpager:library:${MULTIVIEW_PAGER_VER}"
compile "com.michaelpardo:activeandroid:${ACTIVE_ANDROID_VER}"
compile "com.squareup.okhttp:okhttp:${OKHTTP_VER}"
compile "com.rockerhieu.emojicon:library:${EMOJI_VERSION}"
compile "com.facebook.android:facebook-android-sdk:${FACEBOOK_SDK_VER}"
compile "com.makeramen:roundedimageview:${ROUNDED_IMAGEVIEW_VER}"
compile 'com.github.orangegangsters:swipy:1.2.2#aar'
compile "com.flurry.android:analytics:${FLURRY_VER}"
compile 'com.supersonic.sdk:mediationsdk:6.4.6#jar'
compile project(':apng_lib')
compile project(':flingCards')
//SignalR libraries
// To get updated libs, make project and grab resourses : https://github.com/SignalR/java-client
// compile files('libs/gson-2.2.2.jar')
// compile 'com.google.code.gson:gson:2.3'
// compile files ('libs/signalr-client-sdk.jar')
// compile files ('libs/signalr-client-sdk-android.jar')
// compile "org.java-websocket:java-websocket:1.3.1"
// To generate new version of proto Java classes refer to tools/readme
compile files('libs/protobuf-java-2.6.1.jar')
compile ('com.google.android.gms:play-services-basement:${GSM_VER}'){
exclude module: 'support-v4';
}
compile "com.google.android.gms:play-services-analytics:${GSM_VER}"
compile "com.google.android.gms:play-services-gcm:${GSM_VER}"
}
I need compile sdk 22, because I did not implemented features from 6 android.
Please help
I want to change the generated name of the .apk file in my build gradle. based on which buildtype i choose. It automatically appends "-release" or "-debug".
How can I change this?
Build gradle file
android {
signingConfigs {
testapp {
storeFile file("itsASecret")
storePassword "itsASecret"
keyAlias "itsASecret"
keyPassword "itsASecret"
}
}
compileSdkVersion 22
buildToolsVersion "22.0.1"
def versionPropertiesFile = file('version.properties')
if (versionPropertiesFile.canRead()) {
def Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropertiesFile))
def code = versionProps['VERSION_CODE'].toInteger() + 1
versionProps['VERSION_CODE'] = code.toString()
versionProps.store(versionPropertiesFile.newWriter(), null)
defaultConfig
{
applicationId "com.testapp.app"
minSdkVersion 19
targetSdkVersion 22
versionCode code
versionName "1.02.00"
multiDexEnabled true
setProperty("archivesBaseName", "TestApp_" + "$versionName" + "_" + "$versionCode")
}
} else {
throw new GradleException("Could not read version.properties!")
}
buildTypes
{
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.testapp
}
debug {
debuggable true
signingConfig signingConfigs.testapp
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
defaultConfig {
signingConfig signingConfigs.railway
}
}
I tried something like
applicationIdSuffix "_DEBUGTEST"
or
versionNameSuffix "_DEBUGTEST"
Filename:
TestApp_1.02.00_458-release.apk
TestApp_1.02.00_458-debug.apk
But this is not working :-(
EDIT:
I do have a common library with another build gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
//compile 'com.squareup.retrofit:retrofit:1.7.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'de.greenrobot:greendao:1.3.7'
compile 'commons-io:commons-io:2.4'
compile 'org.apache.commons:commons-lang3:3.3.2'
compile 'commons-codec:commons-codec:1.10'
compile 'de.mindpipe.android:android-logging-log4j:1.0.3'
compile 'log4j:log4j:1.2.16'
compile 'org.slf4j:slf4j-api:1.6.4'
compile 'org.slf4j:slf4j-log4j12:1.6.4'
compile 'com.google.android.gms:play-services-maps:8.3.0'
compile 'com.google.android.gms:play-services-location:8.3.0'
compile 'commons-net:commons-net:3.3'
compile 'net.lingala.zip4j:zip4j:1.3.2'
compile 'com.jjoe64:graphview:4.0.1'
}
I want to create smth like this in my project, but i'm new to gradle, so i don't know a lot of things it can do.
Here is project structure in explorer
gradle.build from app module
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.7'
}
}
// Manifest version information!
def versionMajor = 1
def versionMinor = 0
def versionPatch = 0
def versionBuild = 0 // bump for dogfood builds, public betas, etc.
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
def gitSha = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
def date = new Date()
def buildTime = date.format("dd.MM.yy", TimeZone.getTimeZone("UTC"))
def buildTimeInternal = date.format("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC"))
android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
versionCode versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100 + versionBuild
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
buildConfigField "String", "GIT_SHA", "\"${gitSha}\""
buildConfigField "String", "BUILD_TIME", "\"${buildTimeInternal}\""
testApplicationId "ru.ltst.u2020mvp.tests"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
debug {
storeFile file("../distribution/debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
release {
storeFile file("../distribution/debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
}
buildTypes {
debug {
applicationIdSuffix '.dev'
versionNameSuffix '-dev'
debuggable true
signingConfig signingConfigs.debug
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), file('proguard-project.txt')
signingConfig signingConfigs.release
}
}
productFlavors {
internal {
applicationId 'ru.ltst.u2020mvp.internal'
}
production {
applicationId 'ru.ltst.u2020mvp'
}
}
lintOptions {
textReport true
textOutput 'stdout'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'LICENSE.txt'
}
}
// TODO remove eventually: http://b.android.com/162285
configurations {
internalDebugCompile
}
dependencies {
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:support-annotations:23.0.1'
compile "com.android.support:appcompat-v7:23.0.1"
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.google.dagger:dagger:2.0.1'
apt 'com.google.dagger:dagger-compiler:2.0'
provided 'org.glassfish:javax.annotation:10.0-b28'
compile 'com.squareup.okhttp:okhttp:2.3.0'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
internalDebugCompile 'com.squareup.retrofit:retrofit-mock:1.9.0'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.jakewharton.timber:timber:2.7.1'
internalDebugCompile 'com.jakewharton.madge:madge:1.1.1'
internalDebugCompile 'com.jakewharton.scalpel:scalpel:1.1.1'
compile 'io.reactivex:rxjava:1.0.8'
compile 'io.reactivex:rxandroid:0.24.0'
internalCompile 'com.mattprecious.telescope:telescope:1.4.0#aar'
// Espresso 2 Dependencies
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'
androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.0') {
exclude module: 'support-annotations'
}
}
// change apk name
android.applicationVariants.all { variant ->
for (output in variant.outputs) {
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def fileName = "u2020-mvp-${output.name}-${buildTime}.apk"
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
// print build finish time
gradle.buildFinished { buildResult ->
def buildFinishDate = new Date()
def formattedDate = buildFinishDate.format('yyyy-MM-dd HH:mm:ss')
println "Build finished: ${formattedDate}"
}
Can someone explain to me how it works?
When i change build Variant the java content is changed. (e.g it was main, internal,internalDebug for internalDebug variant and then it became main,internal,internalRelease for internalRelease build variants).
The reason I'm asking is that i don't see any "internalRelease" word in gradle file, so i don't understand the logic of how the build variants were created and how it defines what modules to show for different build variants
debug for test without signature and release for publish with signature;click the left-top robot ,and turn android to project , u will understand;
I am using first time git hub library in my project and new to android.I am trying to make project in which i need to use graph for this I am using ease graph project from git hub but it is giving me an error
Error:(9, 0) Could not find property 'file' on SigningConfig_Decorated{name=release, storeFile=null, storePassword=null, keyAlias=null, keyPassword=null, storeType=null}.
this is the file coding available
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
signingConfigs {
release {
storeFile file(STORE_FILE)
storePassword STORE_PASSWORD
keyAlias KEY_ALIAS
keyPassword KEY_PASSWORD
}
}
defaultConfig {
applicationId "org.eazegraph.app"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
// this is used to alter output directory and file name. If you don't need it
// you can safely comment it out.
applicationVariants.all { variant ->
variant.outputs.each { output ->
def file = output.outputFile
String parent = file.parent
if (project.hasProperty('OUTPUT_DIR') && new File((String) OUTPUT_DIR).exists())
parent = OUTPUT_DIR
output.outputFile = new File(
parent,
(String) file.name.replace(
".apk",
// alter this string to change output file name
"-" + defaultConfig.versionName + "-build" + defaultConfig.versionCode + ".apk"
)
)
}
}
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':EazeGraphLibrary')
compile 'com.android.support:appcompat-v7:21.0.3'
}
any help please..
It seems you have not defined the variables STORE_FILE, STORE_PASSWORD, KEY_ALIAS, KEY_PASSWORD in your script. You can do it as follows :
apply plugin: 'com.android.application'
def STORE_FILE= "File location goes here"
def STORE_PASSWORD= "Store password"
def KEY_ALIAS= "Alias to use"
def KEY_PASSWORD= "password to the alias"
android {
....
}