Use different class for android build variant - android

I have 6 apps that all use one main build to run off of. They all have 4 tab buttons but I'd like to switch one app to have 5 tab bar buttons.
So I've configured a main class that has 4 tab bar buttons, however for one app I'd like it to override that and use 5 tab bar buttons. I'm just not sure how to change out the classes.
Any help at all would be greatly appreciated
EDIT: also, if you downvote, please say why. If it's unclear what I'm asking or if it's a simple question etc.
Here's the class I'm trying to exchange
package com.android.stanby.app.domain;
import com.android.stanby.app.R;
/**
* Created by trevor.wood on 2018/05/01.
*/
public class BottomMenuButtons {
public static final int TAB_INDEX_JOB_LIST = 0;
public static final int TAB_INDEX_JOB_MAP = 1;
public static final int TAB_INDEX_WEB = 2;
public static final int TAB_INDEX_RECOMMEND = 3;
public static final int TAB_INDEX_CHAT = 4;
public static final int[] NAVI_ITEMS = {
R.id.bottom_navigation_job_list,
R.id.bottom_navigation_job_map,
R.id.bottom_navigation_keep,
R.id.bottom_navigation_recommend,
R.id.bottom_navigation_chat,
};
public static final int[] NAVI_ICONS = {
R.id.bottom_navigation_job_list_icon,
R.id.bottom_navigation_job_map_icon,
R.id.bottom_navigation_keep_icon,
R.id.bottom_navigation_recommend_icon,
R.id.bottom_navigation_chat_icon,
};
public static final int[] NAVI_OFF_ICONS = {
R.drawable.stanby_ic_bottom_tab_job_off,
R.drawable.stanby_ic_bottom_tab_job_map_off,
R.drawable.stanby_ic_bottom_tab_keep_off,
R.drawable.stanby_ic_bottom_tab_recommend_off,
R.drawable.stanby_ic_bottom_tab_chat_off,
};
public static final int[] NAVI_ON_ICONS = {
R.drawable.stanby_ic_bottom_tab_job_on,
R.drawable.stanby_ic_bottom_tab_job_map_on,
R.drawable.stanby_ic_bottom_tab_keep_on,
R.drawable.stanby_ic_bottom_tab_recommend_on,
R.drawable.stanby_ic_bottom_tab_chat_on,
};
}
And here are my build settings
def PACKAGE_NAME = "com.stanby.jp"
// VERSION_CODE及びVERSION_NAMEはgradle.propertiesに定義されている
def VERSION_CODE = APP_VERSION_CODE.toInteger()
def VERSION_NAME = APP_VERSION_NAME
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionCode VERSION_CODE
versionName VERSION_NAME
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
release {
keyAlias STANBY_KEY_ALIAS
keyPassword STANBY_KEY_PASSWORD
storeFile file(System.getenv("HOME") + "/.android/" + STANBY_STORE_FILE)
storePassword STANBY_STORE_PASSWORD
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
// フレーバー
flavorDimensions "type", "env"
productFlavors {
// 全部入り
stanby {
dimension "type"
applicationId "${PACKAGE_NAME}"
}
// アルバイト・パート
part {
dimension "type"
applicationId "${PACKAGE_NAME}.part"
}
// 転職(正社員)
full {
dimension "type"
applicationId "${PACKAGE_NAME}.full"
}
// ハローワーク
hellowork {
dimension "type"
applicationId "${PACKAGE_NAME}.hellowork"
}
// 富山県
toyama {
dimension "type"
applicationId "${PACKAGE_NAME}.toyama"
}
// 福島県
fukushima {
dimension "type"
applicationId "${PACKAGE_NAME}.fukushima"
}
// 福岡県
fukuoka {
dimension "type"
applicationId "${PACKAGE_NAME}.fukuoka"
}
develop {
dimension "env"
}
product {
dimension "env"
}
}
// ビルドタイプ
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt'
buildConfigField "boolean", "USE_CRASHLYTICS", "true"
ext.enableCrashlytics = true
}
debug {
//signingConfig signingConfigs.release
buildConfigField "boolean", "USE_CRASHLYTICS", "false"
ext.enableCrashlytics = false
}
}
// ソース構成
sourceSets {
// 全部入り
stanby {
java.srcDirs = ['src/stanby/java', 'src/common/java']
res.srcDirs = ['src/stanby/res', 'src/common/res']
}
// アルバイト・パート
part {
java.srcDirs = ['src/part/java', 'src/common/java']
res.srcDirs = ['src/part/res', 'src/common/res']
}
// 転職(正社員)
full {
java.srcDirs = ['src/full/java', 'src/common/java']
res.srcDirs = ['src/full/res', 'src/common/res']
}
// ハローワーク
hellowork {
java.srcDirs = ['src/hellowork/java', 'src/common/java']
res.srcDirs = ['src/hellowork/res', 'src/common/res']
}
// 富山県
toyama {
java.srcDirs = ['src/toyama/java']
res.srcDirs = ['src/toyama/res']
}
// 福島県
fukushima {
java.srcDirs = ['src/fukushima/java']
res.srcDirs = ['src/fukushima/res']
}
// 福岡県
fukuoka {
java.srcDirs = ['src/fukuoka/java']
res.srcDirs = ['src/fukuoka/res']
}
// 検証環境
develop {
java.srcDirs = ['src/develop/java']
res.srcDirs = ['src/develop/res']
}
// 本番環境
product {
java.srcDirs = ['src/product/java']
res.srcDirs = ['src/product/res']
}
}
// google-services.json を develop/product からコピーする
gradle.taskGraph.beforeTask { Task task ->
if (task.name ==~ /process.*GoogleServices/) {
applicationVariants.all { variant ->
if (task.name ==~ /(?i)process${variant.name}GoogleServices/) {
String fromDir = "${variant.flavorName}";
if (fromDir.endsWith("Develop")) {
fromDir = "develop";
} else if (fromDir.endsWith("Product")) {
fromDir = "product";
}
print "\n#####################################################\n";
print "google-services.json fromDir=${fromDir}\n"
print "#####################################################\n\n";
copy {
from "src/" + fromDir
into "."
include "google-services.json"
}
}
}
}
}
}
apply plugin: 'com.neenbedankt.android-apt'
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
// https://developer.android.com/topic/libraries/support-library/revisions.html
def supportLibraryVersion = '25.3.1'
// https://developers.google.com/android/guides/releases
def playServiceVersion = '11.8.0'
// https://github.com/firebase/FirebaseUI-Android
def firebaseUiDatabaseVersion = '1.2.0'
def retrofitVersion = '2.1.0'
def okHttpVersion = '3.4.1'
def daggerVersion = '2.6'
def butterknifeVersion = '8.3.0'
def rxLifecycleVersion = '0.7.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
// 計測
compile('com.crashlytics.sdk.android:crashlytics:2.8.0#aar') {
transitive = true;
}
compile 'com.adjust.sdk:adjust-android:4.2.1'
// support library
compile 'com.android.support:multidex:1.0.1'
compile "com.android.support:support-v4:${supportLibraryVersion}"
compile "com.android.support:appcompat-v7:${supportLibraryVersion}"
compile "com.android.support:design:${supportLibraryVersion}"
compile "com.android.support:recyclerview-v7:${supportLibraryVersion}"
compile "com.android.support:cardview-v7:${supportLibraryVersion}"
// Play service
compile "com.google.android.gms:play-services-analytics:${playServiceVersion}"
compile "com.google.android.gms:play-services-location:${playServiceVersion}"
compile "com.google.android.gms:play-services-maps:${playServiceVersion}"
compile 'com.google.maps.android:android-maps-utils:0.4.3'
// Firebase
compile "com.google.firebase:firebase-core:${playServiceVersion}"
compile "com.google.firebase:firebase-messaging:${playServiceVersion}"
compile "com.google.firebase:firebase-config:${playServiceVersion}"
compile "com.google.firebase:firebase-auth:${playServiceVersion}"
compile "com.google.firebase:firebase-database:${playServiceVersion}"
compile "com.google.firebase:firebase-invites:${playServiceVersion}"
compile "com.firebaseui:firebase-ui-database:${firebaseUiDatabaseVersion}"
// retrofit
compile "com.squareup.retrofit2:retrofit:${retrofitVersion}"
compile "com.squareup.retrofit2:adapter-rxjava:${retrofitVersion}"
compile "com.squareup.retrofit2:converter-gson:${retrofitVersion}"
// okHttp
compile "com.squareup.okhttp3:logging-interceptor:${okHttpVersion}"
// Glide
compile 'com.github.bumptech.glide:glide:3.7.0'
// Twillio
compile 'com.koushikdutta.ion:ion:2.1.7'
compile 'com.twilio:conversations-android:0.12.2'
// 求人詳細の WebView レイアウト
compile 'com.samskivert:jmustache:1.12'
// base framework
apt "com.google.dagger:dagger-compiler:$daggerVersion"
compile "com.google.dagger:dagger:$daggerVersion"
apt "com.jakewharton:butterknife-compiler:$butterknifeVersion"
compile "com.jakewharton:butterknife:$butterknifeVersion"
compile "com.trello:rxlifecycle:$rxLifecycleVersion"
compile "com.trello:rxlifecycle-android:$rxLifecycleVersion"
compile "com.trello:rxlifecycle-components:$rxLifecycleVersion"
compile 'io.reactivex:rxandroid:1.1.0'
// library
compile 'com.facebook.android:facebook-android-sdk:4.25.0'
compile 'com.viewpagerindicator:library:2.4.1#aar'
compile 'com.wefika:flowlayout:0.4.1'
compile 'com.ncapdevi:frag-nav:1.0.3'
compile 'com.github.ksoichiro:android-observablescrollview:1.6.0'
compile 'com.github.2359media:EasyAndroidAnimations:0.8'
compile 'commons-codec:commons-codec:1.10'
compile 'net.danlew:android.joda:2.9.2'
// test
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'org.hamcrest:hamcrest-library:1.3'
androidTestCompile "com.android.support:support-annotations:$supportLibraryVersion"
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') {
exclude group: 'com.google.code.findbugs', module: 'jsr305'
}
androidTestCompile("com.squareup.retrofit2:retrofit-mock:$retrofitVersion") {
exclude group: 'com.squareup.okio', module: 'okio'
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
androidTestCompile('com.squareup.assertj:assertj-android:1.1.1') {
exclude group: 'com.squareup.okio', module: 'okio'
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'io.fabric'
apply plugin: 'realm-android'

You need to create your flavor directory for it. For example, if you want to create specific class for fukusima flavor, you need to create the fukusima directory inside your src directory. Like this:
src/fukusima/java/your/package/name/bottommenu
then you create the BottomMenuButtons there. Change your/package/name/bottommenu to your BottomMenuButtons path.
The other way is using a flag for adding specific flag for your flavor. First, add a specific flag to your flavor. For example, we use USE_FIVE_TAB. Change the flavor by adding the flag:
productFlavors {
stanby {
buildConfigField "boolean", "USE_FIVE_TAB", "false"
dimension "type"
applicationId "${PACKAGE_NAME}"
}
part {
buildConfigField "boolean", "USE_FIVE_TAB", "false"
dimension "type"
applicationId "${PACKAGE_NAME}.part"
}
full {
buildConfigField "boolean", "USE_FIVE_TAB", "true"
dimension "type"
applicationId "${PACKAGE_NAME}.full"
}
// add the same flag to all of your flavors
...
Then, you can use it something like this:
if(BuildConfig.USE_FIVE_TAB) {
// set to use five tabs
} else {
// use four tabs
}

You can override classses per variant by creating the corresponding folder in the project with the same name for the flavor. Check this SO link that explains the directory structure needed. Then automatically when you compile that flavor the class will be overriden.

Related

Project 'app' not found in root project 'MobileBuy'

FAILURE: Build failed with an exception.
What went wrong:
Project 'app' not found in root project 'MobileBuy'.
getting above error when I build project. but in my android project no app folder then why this Project 'app' not found in root project 'MobileBuy' getting this error.
settings.gradle
include ':sample', ':buy3', ':buy3-pay-support', ':graphql-java-support'
project(':graphql-java-support').projectDir = new File('./libs/graphql_java_gen/support')
build.gradle
buildscript {
dependencies {
classpath dep.androidPlugin
classpath dep.retrolambda
classpath dep.butterknifePlugin
classpath dep.apolloPlugin
}
}
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'com.jakewharton.butterknife'
apply plugin: 'com.apollographql.android'
android {
compileSdkVersion androidConfig.compileSdkVersion
buildToolsVersion androidConfig.buildToolsVersion
defaultConfig {
applicationId "com.shopify.sample"
minSdkVersion androidConfig.minSdkVersion
targetSdkVersion androidConfig.targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
all {
buildConfigField 'okhttp3.logging.HttpLoggingInterceptor.Level', 'OKHTTP_LOG_LEVEL', 'okhttp3.logging.HttpLoggingInterceptor.Level.BODY'
// We pull the shop settings either from the Environment or a file called shop.properties at the root of the project.
// Environment variables will take precedence, we will attempt to read those first.
def shopDomain
def apiKey
def androidPayPublicKey
def androidPayEnvironment
// get the shop setting from the environment if there any
shopDomain = System.getenv("SHOP_DOMAIN")
apiKey = System.getenv("API_KEY")
androidPayPublicKey = System.getenv("ANDROID_PAY_PUBLIC_KEY")
androidPayEnvironment = System.getenv("ANDROID_PAY_ENVIRONMENT")
// pull the store properties from the local file if it exists. Environment variables take precedence
def shopProperties = new Properties();
File shopPropertiesFile = project.file('shop.properties')
if (shopPropertiesFile.exists()) {
shopProperties.load(new FileInputStream(shopPropertiesFile))
shopDomain = shopDomain ?: shopProperties["SHOP_DOMAIN"]
apiKey = apiKey ?: shopProperties["API_KEY"]
androidPayPublicKey = androidPayPublicKey ?: shopProperties["ANDROID_PAY_PUBLIC_KEY"]
androidPayEnvironment = androidPayEnvironment ?: shopProperties["ANDROID_PAY_ENVIRONMENT"]
}
if (!shopDomain) {
shopDomain = ""
}
if (!apiKey) {
apiKey = ""
}
if (!androidPayPublicKey) {
androidPayPublicKey = ""
}
if (!androidPayEnvironment) {
androidPayEnvironment = "com.google.android.gms.wallet.WalletConstants.ENVIRONMENT_SANDBOX"
}
buildConfigField "String", "SHOP_DOMAIN", "\"" + shopDomain.toString() + "\""
buildConfigField "String", "API_KEY", "\"" + apiKey.toString() + "\""
buildConfigField "String", "ANDROID_PAY_PUBLIC_KEY", "\"" + androidPayPublicKey.toString() + "\""
buildConfigField "int", "ANDROID_PAY_ENVIRONMENT", androidPayEnvironment
debuggable = true
minifyEnabled = false
}
}
productFlavors {
shopify {
}
xApollo {
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile dep.androidSupportDesign
compile dep.androidSupportV4
compile dep.androidSupportV7
compile dep.androidSupportAnnotations
compile dep.rxAndroid
compile dep.rxJava
compile dep.timber
compile dep.butterKnife
compile 'com.ss.bannerslider:bannerslider:1.8.0'
compile 'com.ss.bottomnavigation:bottomnavigation:1.5.2'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'org.apmem.tools:layouts:1.10#aar'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
annotationProcessor dep.butterKnifeCompiler
compile(dep.fresco) {
exclude group: 'com.android.support'
}
compile dep.constraintLayout
compile dep.rxrelay
compile dep.archRuntime
compile dep.archExt
annotationProcessor dep.arcCompiler
compile project(':buy3-pay-support')
shopifyCompile project(':buy3')
xApolloCompile dep.apolloRuntime
xApolloCompile dep.okhttpLogging
xApolloCompile dep.apolloHttpCache
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.xiaofeng.android:flowlayoutmanager:1.2.3.2'
compile 'com.beloo.widget:ChipsLayoutManager:0.3.7#aar'
}
task downloadApolloSchema(type: DefaultTask, group: "GraphQL", description: "Download GraphQL store front API schema") {
doLast {
println("Downloading GraphQL schema...")
def schemaFile = new File(project.projectDir.absolutePath + '/src/xApollo/graphql/com/shopify/sample/domain/schema.json')
if (schemaFile.exists()) {
schemaFile.delete()
}
new URL('https://app.shopify.com/services/ping/storefront_graphql_schema').withInputStream { i ->
schemaFile.withOutputStream {
it << i
}
}
println("GraphQL schema has been downloaded!")
}
}
apollo {
customTypeMapping['URL'] = "String"
customTypeMapping['HTML'] = "String"
customTypeMapping['Money'] = "java.math.BigDecimal"
nullableValueType = "apolloOptional"
generateAccessors = false
useSemanticNaming = false
}

Unable to make executable signed-release build dexgaurd

I updated my project to gradle version to 4.0 and android support version library to latest(i.e. 27.0.0) with target api with Android O(26), and made a signed release build.
Now I'm getting this crash when open the app:
java.lang.IllegalAccessError: Method 'boolean android.view.ViewGroup.checkLayoutParams(android.view.ViewGroup$LayoutParams)' is inaccessible to class 'android.support.v7.widget.ActionMenuPresenter' (declaration of 'android.support.v7.widget.ActionMenuPresenter' appears in /data/app/com.myairtelapp-iuW7irEMrfWuoyVjp6OGKA==/base.apk)
at android.support.v7.widget.ActionMenuPresenter.getItemView(:202)
at android.support.v7.widget.ActionMenuPresenter.flagActionItems(:476)
at android.support.v7.view.menu.MenuBuilder.flagActionItems(:1164)
at android.support.v7.view.menu.BaseMenuPresenter.updateMenuView(:95)
at android.support.v7.widget.ActionMenuPresenter.updateMenuView(:229)
at android.support.v7.view.menu.MenuBuilder.dispatchPresenterUpdate(:291)
at android.support.v7.view.menu.MenuBuilder.onItemsChanged(:1051)
at android.support.v7.view.menu.MenuBuilder.startDispatchingItemsChanged(:1078)
at android.support.v7.app.ToolbarActionBar.populateOptionsMenu(:460)
at android.support.v7.app.ToolbarActionBar$1.run(:55)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6809)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)'
My build.gradle is:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'net.researchgate.release'
apply plugin: 'dexguard'
android {
compileSdkVersion project.ext.compile_sdk_version
buildToolsVersion project.ext.build_tools_version
lintOptions {
quiet false
abortOnError false
ignoreWarnings false
disable "ResourceType"
}
dexOptions {
javaMaxHeapSize "4g"
}
signingConfigs {
release {
}
}
flavorDimensions 'channel'
productFlavors {
playstore {
dimension 'channel'
manifestPlaceholders = [channelName: "playstore"]
}
}
configurations {
all {
exclude group: 'org.json', module: 'json'
exclude module: 'httpclient'
exclude module: 'commons-logging'
resolutionStrategy {
force "com.android.support:gridlayout-v7:${support_version}"
force "com.android.support:support-v4:${support_version}"
force "com.android.support:appcompat-v7:${support_version}"
force "com.android.support:cardview-v7:${support_version}"
force "com.android.support:recyclerview-v7:${support_version}"
force "com.android.support:design:${support_version}"
}
}
}
defaultConfig {
applicationId "com.myairtelapp"
minSdkVersion project.ext.min_sdk_version
targetSdkVersion project.ext.target_sdk_version
vectorDrawables.useSupportLibrary = true
versionCode manifestVersionCode
versionName manifestVersionName
buildConfigField BOOLEAN, LOAD_DUMMY_JSON, FALSE
// Config for enbling dummy mode
buildConfigField BOOLEAN, SET_SPOOF_REQUEST, FALSE
// Config for spoofing request
buildConfigField BOOLEAN, REPORT_CRASHES, TRUE
// Flag for reporting crashlytics
multiDexEnabled true
}
buildTypes {
release {
buildConfigField BOOLEAN, LOG_LEVEL_DEBUG, FALSE
signingConfig signingConfigs.release
buildConfigField STRING, S3_URL, BASE_URL_S3_PROD
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFile getDefaultDexGuardFile('dexguard-release.pro')
proguardFile 'dexguard-project.pro'
proguardFile 'proguard-rules.pro'
}
debug {
debuggable true
buildConfigField BOOLEAN, REPORT_CRASHES, FALSE
buildConfigField BOOLEAN, LOG_LEVEL_DEBUG, TRUE
proguardFile getDefaultDexGuardFile('dexguard-debug.pro')
proguardFile 'dexguard-project.pro'
proguardFile 'proguard-rules.pro'
applicationIdSuffix ".debug"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
def gitBranchName() {
return 'git rev-parse --abbrev-ref HEAD'.execute().text.trim()
}
/** generate main build tasks
* generated tasks : [airtelOneDebugAssemble, airtelOneReleaseAssemble, airtelOneStagingAssemble
* airtelOneQaAssemble,airtelOneDummyAssemble]
**/
android.buildTypes.all { buildType ->
android.productFlavors.each { flavor ->
task("airtelOne${flavor.name.capitalize()}${buildType.name.capitalize()}Assemble") {
if (buildType.name == android.buildTypes.release.name) {
dependsOn "release"
} else {
dependsOn "assemble${flavor.name.capitalize()}${buildType.name.capitalize()}"
}
}
}
}
/**
* rename the generated apk.
* use SNAPSHOT for intermediate builds
*/
tasks.whenTaskAdded { task ->
if (task.name == 'generateReleaseBuildConfig') {
task.dependsOn 'updateVersionProperties'
}
}
/*
Override release plugin task and update version properties file.
*/
task('updateVersionProperties') << {
def incVersion = manifestVersionCode + 1
props.setProperty(PropertyVersionCode, incVersion.toString())
def appVersion = manifestVersionName.split("\\.")
def majorVersion = appVersion[0]
def minorVersion = appVersion[1]
def patchVersion = appVersion[2]
def updatePatchVersion = patchVersion.toInteger() + 1
def newVersionName = "${majorVersion}.${minorVersion}.${updatePatchVersion}"
props.setProperty(PropertyVersionName, newVersionName)
def writer = new FileWriter(file(PropertiesFile))
try {
props.store(writer, 'Manifest Version Properties')
writer.flush()
} finally {
writer.close()
}
}
def getDate() {
def date = new Date()
def formattedDate = date.format("dd-MM'T'HH-mm")
return formattedDate
}
repositories {
mavenCentral()
maven { url 'http://dl.bintray.com/amulyakhare/maven' }
maven { url 'https://s3-ap-southeast-1.amazonaws.com/godel-release/godel/' }
maven { url 'https://maven.fabric.io/public' }
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
compile(name: 'GoogleConversionTrackingSdk-2.2.4', ext: 'jar')
compile(name: 'leap_sdk', ext: 'aar')
compile(name: 'SecureComponent-PROD-V1.5', ext: 'aar')
implementation project(':qrcodereaderview')
implementation project(':applib')
compile 'com.android.support:multidex:1.0.3'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.squareup:otto:1.3.8'
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
compile 'com.squareup.okhttp:okhttp:2.7.5'
//compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.7.5'
compile 'commons-codec:commons-codec:20041127.091804'
compile 'com.github.castorflex.smoothprogressbar:library-circular:1.0.0'
compile 'com.birbit:android-priority-jobqueue:1.3'
compile 'com.squareup.wire:wire-runtime:1.6.1'
compile 'com.squareup:tape:1.2.3'
compile('com.crashlytics.sdk.android:crashlytics:2.6.3#aar') {
transitive = true;
}
compile('com.github.ozodrukh:CircularReveal:1.1.1#aar') {
transitive = true;
}
compile('com.moengage:moe-android-sdk:7.7.15') {
exclude group: 'com.moengage', module: 'moe-location-lib'
}
compile ('com.moengage:addon-messaging:1.1.02')
{
exclude group: 'com.android.support'
}
compile 'com.github.bumptech.glide:glide:3.7.0'
compile ('in.juspay:godel:0.6.24.1423')
{
exclude group: 'com.android.support'
}
/* compile ('fr.baloomba:viewpagerindicator:2.4.2')
{
exclude group: 'com.android.support'
}*/
compile 'com.madgag.spongycastle:core:1.54.0.0'
compile 'com.madgag.spongycastle:prov:1.54.0.0'
compile files('libs/secure-component-sdk.jar')
compile 'com.github.PhilJay:MPAndroidChart:v3.0.0'
//Charts lib
compile 'com.github.evgenyneu:js-evaluator-for-android:v2.0.0'
compile "com.android.support:customtabs:${support_version}"
//SafetyNet dependency
compile ("com.google.android.gms:play-services-safetynet:${google_play_services_version}")
{
exclude group: 'com.android.support'
exclude module: 'support-v4'
}
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.appsflyer:af-android-sdk:4.8.8'
compile 'com.android.installreferrer:installreferrer:1.0'
compile ('com.firebase:firebase-jobdispatcher:0.8.5')
{
exclude group: 'com.android.support'
}
}
I checked for duplicate dependencies and remove almost all duplicate dependencies
I didn't find any seemlier question
This is due to the following optimization: method/generalization/class.
I tried to make a release build using the following rule in your dexguard configuration:
-optimizations !method/generalization/class
Its working fine for me

Gradle build error (manifestOutputFile) when upgrading plugin to 3.0.0

After upgrading the Gradle plugin version to 3.0.0 (classpath "com.android.tools.build:gradle:3.0.0") and if I then try to clean or build the project I get this error:
A problem occurred configuring project ':app'.
> Manifest Tasks does not support the manifestOutputFile property any
more, please use the manifestOutputDirectory instead.
For more information, please check
https://developer.android.com/studio/build/gradle-plugin-3-0-0-
migration.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or
--debug option to get more log output.
* Get more help at https://help.gradle.org
I am not using manifestOutputFile anywhere in any of my gradle files. using the --debug and --stacktrace flags did nothing for me. I'm guessing this issue is coming up in one of my dependencies but I have no idea. Also, I am using Kotlin in a lot of classes; I'm not sure if that matters or not. Does anyone know if there is a way to see which library is throwing this error? Or does anyone have any suggestions or insight around this issue when the build.gradle file does not even reference manifestOutputFile?
Here's most of the build.gradle file:
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://plugins.gradle.org/m2/' }
maven { url 'https://maven.google.com'}
}
dependencies {
classpath 'io.fabric.tools:gradle:1.24.4'
classpath 'me.tatarka:gradle-retrolambda:3.7.0'
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.2'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0'
classpath 'gradle.plugin.com.nobleworks_software.icon-overlay:icon-overlay-plugin:1.2.3'
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'io.fabric'
apply plugin: 'checkstyle'
apply plugin: 'findbugs'
apply plugin: 'jacoco'
apply plugin: 'jacoco-android'
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'com.nobleworks_software.icon-overlay'
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
flatDir {
dirs 'libs'
}
}
ext {
libsSrcDir = new File('${projectDir}/libs')
}
String gpsPropertyName = 'gps'
String gpsPropertyValueAlpha = 'alpha'
String gpsPropertyValueBeta = 'beta'
boolean tangoBuild = false
String tangoPropertyName = 'tango'
String alphaBuildEnding = '20'
String betaBuildEnding = '10'
String productionBuildEnding = '00'
def isBuildForGPS = { ->
return project.hasProperty(gpsPropertyName)
}
def isTangoBuild = { ->
return project.hasProperty(tangoPropertyName)
}
def getBranchName = { ->
try {
def branchOut = new ByteArrayOutputStream()
exec {
commandLine 'git', 'symbolic-ref', '--short', 'HEAD'
standardOutput = branchOut
}
return branchOut.toString().trim()
}
catch (ignored) {
return 'master'
}
}
def getVersionCode = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', '--count', 'HEAD'
standardOutput = stdout
}
// Make the Tango version use '50' as the least sig offset
int tangoOffset = 0
if (tangoBuild) {
tangoOffset = 50
}
if (isBuildForGPS()) {
String channel = project.findProperty(gpsPropertyName)
if (gpsPropertyValueAlpha == channel) {
return Integer.parseInt(stdout.toString().trim() + alphaBuildEnding) + tangoOffset
} else if (gpsPropertyValueBeta == channel) {
return Integer.parseInt(stdout.toString().trim() + betaBuildEnding) + tangoOffset
}
}
return Integer.parseInt(stdout.toString().trim() + productionBuildEnding) + tangoOffset
}
catch (ignored) {
return -1
}
}
def getVersionName = { ->
try {
if (isBuildForGPS()) {
def tag = getLastTaggedVersion()
String channel = project.findProperty(gpsPropertyName)
if (gpsPropertyValueAlpha == channel) {
tag = tag + '-a'
} else if (gpsPropertyValueBeta == channel) {
tag = tag + '-b'
}
return tag
} else {
return getBranchName()
}
}
catch (ignored) {
return 'X.X.X'
}
}
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
javaMaxHeapSize "4g"
}
dataBinding {
enabled = true
}
defaultConfig {
versionCode getVersionCode()
versionName getVersionName()
applicationId getApplicationId()
minSdkVersion 16
targetSdkVersion 26
multiDexEnabled = true
multiDexKeepFile file('multidex_keep_file.txt')
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "com.demoapp.demoapp.WayTestRunner"
renderscriptTargetApi 16
renderscriptSupportModeEnabled true
String branchName = getBranchName().toUpperCase()
String iconOverlayText = branchName.toLowerCase()
buildConfigField "String", "LAST_TAGGED_VERSION", "\"${getLastTaggedVersion()}\""
if (branchName == 'DEV') {
iconOverlayText = 'ALPHA'
} else if (branchName.startsWith('RELEASE')) {
iconOverlayText = 'BETA'
}
if (!isBuildForGPS()) {
iconOverlay {
enabled = true
fontSize = 8
textColor = [255, 255, 255, 255]
verticalLinePadding = 2
backgroundOverlayColor = [0, 0, 0, 180]
text = { "$iconOverlayText" }
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
}
flavorDimensions("store", "3d_enabled")
productFlavors {
demoapp {
dimension = "store"
applicationId getApplicationId()
// Dupe required because SearchRecentSuggestionsProvider has no available context in its constructor
buildConfigField "String", "SEARCH_RECENT_AUTHORITY", "\"${applicationId}.WFSearchRecentSuggestionsProvider\""
// And one for the manifest
resValue "string", "SEARCH_RECENT_AUTHORITY", "${applicationId}.WFSearchRecentSuggestionsProvider"
// These need to be defined as string resources so they can be registered in the manifest.
// However in order to access them in tests it's convenient to have them also defined in BuildConfig
String deepLinkScheme = "demoappapp"
resValue "string", "EXPLICIT_DEEP_LINK_SCHEME1", deepLinkScheme
resValue "string", "EXPLICIT_DEEP_LINK_SCHEME2", deepLinkScheme
buildConfigField "String", "EXPLICIT_DEEP_LINK_SCHEME1", "\"${deepLinkScheme}\""
buildConfigField "String", "EXPLICIT_DEEP_LINK_SCHEME2", "\"${deepLinkScheme}\""
if (getBranchName().toUpperCase() == 'MASTER') {
manifestPlaceholders = [
appIcon : "#mipmap/ic_launcher",
appRoundIcon: "#mipmap/ic_launcher_round"
]
} else {
manifestPlaceholders = [
appIcon : "#mipmap/ic_launcher_dev",
appRoundIcon: "#mipmap/ic_launcher_dev_round"
]
}
}
demoappflavor {
dimension = "store"
applicationId getDemoappflavorApplicationId()
// Dupe required because SearchRecentSuggestionsProvider has no available context in its constructor
buildConfigField "String", "SEARCH_RECENT_AUTHORITY", "\"${applicationId}.WFSearchRecentSuggestionsProvider\""
// And one for the manifest
resValue "string", "SEARCH_RECENT_AUTHORITY", "${applicationId}.WFSearchRecentSuggestionsProvider"
// These need to be defined as string resources so they can be registered in the manifest.
// However in order to access them in tests it's convenient to have them also defined in BuildConfig
String deepLinkScheme1 = "theapp"
String deepLinkScheme2 = "demoappflavorapp"
resValue "string", "EXPLICIT_DEEP_LINK_SCHEME1", deepLinkScheme1
resValue "string", "EXPLICIT_DEEP_LINK_SCHEME2", deepLinkScheme2
buildConfigField "String", "EXPLICIT_DEEP_LINK_SCHEME1", "\"${deepLinkScheme1}\""
buildConfigField "String", "EXPLICIT_DEEP_LINK_SCHEME2", "\"${deepLinkScheme2}\""
manifestPlaceholders = [
appIcon : "#mipmap/ic_launcher",
appRoundIcon: "#mipmap/ic_launcher_round"
]
}
}
android.variantFilter { variant ->
def store = variant.getFlavors().get(0).name
def tango_enabled = variant.getFlavors().get(1).name
// Disable building the tango dimension
if ((store == 'demoappflavor' || !isTangoBuild()) && tango_enabled == "tangoEnabled") {
variant.setIgnore(true)
}
}
buildTypes {
release {
// Commented out to stop a production build crash with OKIO
//minifyEnabled true
// Commented out due to Gradle 2.2.0 issue
//shrinkResources true
ext.enableCrashlytics = true
apply plugin: 'signing'
signingConfig signingConfigs.release
ext.betaDistributionReleaseNotesFilePath = './release-notes.txt'
ext.betaDistributionGroupAliases = 'android-nightly'
buildConfigField 'boolean', 'OVERRIDE_MIN_VERSION', isBuildForGPS() ? 'false' : 'true'
buildConfigField 'boolean', 'ENABLE_APPSEE', isBuildForGPS() ? 'true' : 'false'
}
debug {
// TODO: Uncomment this out to enable code coverage
// testCoverageEnabled true
buildConfigField 'boolean', 'OVERRIDE_MIN_VERSION', isBuildForGPS() ? 'false' : 'true'
buildConfigField 'boolean', 'ENABLE_APPSEE', isBuildForGPS() ? 'true' : 'false'
}
configurations.all {
resolutionStrategy {
force 'com.google.code.findbugs:jsr305:1.3.9'
force 'com.google.guava:guava:21.0'
force "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
force 'com.google.code.gson:gson:2.8.2'
}
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'bin/AndroidManifest.xml'
exclude 'bin/jarlist.cache'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
return 0
}
testOptions {
// Disable animations for UI testing
animationsDisabled = true
unitTests.returnDefaultValues = true
unitTests.all {
jacoco {
includeNoLocationClasses = true
}
}
}
sourceSets {
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
}
}
configurations {
demoappTangoEnabledCompile
}
allprojects {
repositories {
jcenter()
maven { url 'https://jitpack.io' }
maven { url "https://clojars.org/repo/" }
}
}
ext.daggerVersion = '2.11'
ext.playServicesVersion = '11.6.2'
ext.supportLibsVersion = '27.0.1'
ext.robolectricVersion = '3.3.2'
ext.frescoVersion = '1.5.0'
ext.leakCanaryVersion = '1.5.4'
ext.roomVersion ='1.0.0'
ext.butterKnifeVersion ='8.7.0'
ext.espressoVersion ='3.0.1'
ext.gsonVersion ='2.8.2'
ext.mockitoVersion ='2.9.0'
ext.dexmakerVersion ='1.2'
ext.icepickVersion ='3.2.0'
ext.multidexVersion ='1.0.2'
dependencies {
// Compile Project
compile(project(':models'))
// Compile
compile('com.crashlytics.sdk.android:crashlytics:2.7.1#aar') {
transitive = true
}
// GOOGLE LIBS
compile "com.android.support:design:${supportLibsVersion}"
compile "com.android.support:recyclerview-v7:${supportLibsVersion}"
compile "com.android.support:cardview-v7:${supportLibsVersion}"
compile "com.android.support:support-v4:${supportLibsVersion}"
compile "com.android.support:support-v13:${supportLibsVersion}"
compile "com.android.support:percent:${supportLibsVersion}"
compile "com.android.support:support-annotations:${supportLibsVersion}"
compile "com.android.support:appcompat-v7:${supportLibsVersion}"
compile "com.android.support:multidex:${multidexVersion}"
compile "com.google.code.gson:gson:${gsonVersion}"
// FIREBASE AND PLAY SERVICES
compile "com.google.firebase:firebase-messaging:${playServicesVersion}"
compile "com.google.firebase:firebase-appindexing:${playServicesVersion}"
//noinspection GradleDependency
compile "com.google.android.gms:play-services-analytics:${playServicesVersion}"
//noinspection GradleDependency
compile "com.google.android.gms:play-services-auth:${playServicesVersion}"
//noinspection GradleDependency
compile "com.google.android.gms:play-services-wallet:${playServicesVersion}"
// FLOW LAYOUT FOR CHIPS
compile 'org.apmem.tools:layouts:1.10#aar'
// RxJava and related
compile 'io.reactivex.rxjava2:rxjava:2.1.7'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile project(':FloatingSearchView')
// RxJava support for Room
compile 'android.arch.persistence.room:rxjava2:1.0.0'
// Testing support
androidTestCompile 'android.arch.core:core-testing:1.1.0'
// Dagger
compile "com.google.dagger:dagger:${daggerVersion}"
compile "com.google.dagger:dagger-android-support:${daggerVersion}"
kapt "com.google.dagger:dagger-compiler:${daggerVersion}"
kapt "com.google.dagger:dagger-android-processor:${daggerVersion}"
compile ("com.facebook.fresco:imagepipeline-okhttp3:${frescoVersion}") {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
compile "com.jakewharton:butterknife:${butterKnifeVersion}"
kapt "com.jakewharton:butterknife-compiler:${butterKnifeVersion}"
compile 'com.android.support.constraint:constraint-layout:1.1.0-beta4'
compile 'com.appsee:appsee-android:2.3.4'
compile 'commons-io:commons-io:2.5'
compile "com.android.support.test:runner:1.0.1"
// ESPRESSO
androidTestCompile "com.android.support:support-v4:${supportLibsVersion}"
androidTestCompile "com.android.support:support-annotations:${supportLibsVersion}"
androidTestCompile "com.android.support:recyclerview-v7:${supportLibsVersion}"
androidTestCompile "com.android.support:design:${supportLibsVersion}"
androidTestCompile "com.android.support:recyclerview-v7:${supportLibsVersion}"
androidTestCompile "com.android.support.test.espresso:espresso-core:${espressoVersion}"
androidTestCompile "com.android.support.test.espresso:espresso-intents:${espressoVersion}"
androidTestCompile "com.android.support.test.espresso:espresso-contrib:${espressoVersion}"
androidTestCompile "com.android.support.test.espresso:espresso-web:${espressoVersion}"
androidTestCompile "org.mockito:mockito-core:${mockitoVersion}"
androidTestCompile "com.google.dexmaker:dexmaker:${dexmakerVersion}"
androidTestCompile "com.google.dexmaker:dexmaker-mockito:${dexmakerVersion}"
androidTestCompile "com.android.support:multidex:${multidexVersion}"
androidTestCompile "org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}"
androidTestCompile "org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}"
androidTestCompile "com.google.code.gson:gson:${gsonVersion}"
androidTestCompile('com.jakewharton.espresso:okhttp3-idling-resource:1.0.0') {
//Using App Version Instead
exclude group: 'com.squareup.okio', module: 'okio'
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
//WireMock
androidTestCompile( project(":wiremock")) {
//Using Android Version Instead
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
exclude group: 'org.ow2.asm', module: 'asm'
//Using Android Version Instead
exclude group: 'org.json', module: 'json'
exclude group: 'com.google.guava', module: 'guava'
}
androidTestCompile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:${mockitoVersion}"
testCompile 'org.hamcrest:hamcrest-library:1.3'
testCompile "org.robolectric:robolectric:${robolectricVersion}"
testCompile "org.robolectric:shadows-multidex:${robolectricVersion}"
testCompile "org.robolectric:shadows-support-v4:${robolectricVersion}"
testCompile "com.google.code.gson:gson:${gsonVersion}"
testCompile "com.google.dagger:dagger:${daggerVersion}"
testCompile "com.android.support:multidex:${multidexVersion}"
kaptTest "com.google.dagger:dagger-compiler:${daggerVersion}"
// Kotlin mockito
testCompile ("com.nhaarman:mockito-kotlin-kt1.1:1.5.0"){
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib'
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-reflect'
}
compile "frankiesardo:icepick:${icepickVersion}"
provided "frankiesardo:icepick-processor:${icepickVersion}"
compile "com.facebook.fresco:fresco:${frescoVersion}"
compile "com.facebook.fresco:animated-gif:${frescoVersion}"
// Canary
debugCompile "com.squareup.leakcanary:leakcanary-android:${leakCanaryVersion}"
releaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:${leakCanaryVersion}"
androidTestCompile "com.squareup.leakcanary:leakcanary-android-no-op:${leakCanaryVersion}"
testCompile "com.squareup.leakcanary:leakcanary-android-no-op:${leakCanaryVersion}"
compile 'com.prolificinteractive:material-calendarview:1.4.3'
//Card IO
compile 'io.card:android-sdk:5.5.1'
compile 'com.facebook.rebound:rebound:0.3.8'
//Chrome Web-View
compile "com.android.support:customtabs:${supportLibsVersion}"
def folder = new File('./brickkit-android/BrickKit/bricks/build.gradle')
if (folder.exists()) {
compile project(':bricks')
} else {
compile 'com.demoapp:brickkit-android:0.9.27'
}
// intellij annotations are included in kotlin, so this creates
// a "java.util.zip.ZipException: duplicate entry" on its modules
//compile 'com.intellij:annotations:12.0#jar'
testCompile "com.google.dagger:dagger:${daggerVersion}"
demoappTangoEnabledCompile project(':demoappView')
compile ('com.perimeterx.sdk:msdk:1.1.0') {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
// Kotlin support
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
//Data binding
kapt "com.android.databinding:compiler:$gradleVersion"
compile 'nl.littlerobots.rxlint:rxlint:1.4'
// Room
compile "android.arch.persistence.room:runtime:${roomVersion}"
kapt "android.arch.persistence.room:compiler:${roomVersion}"
androidTestCompile "android.arch.persistence.room:testing:${roomVersion}"
// Stetho
compile 'com.facebook.stetho:stetho:1.5.0'
compile 'com.facebook.stetho:stetho-js-rhino:1.4.2'
compile 'com.siftscience:sift-android:0.9.10'
}
import groovy.json.JsonBuilder
task uploadapithingFiles << {
// Get all the apithing files
String apithingDir = "${project.rootDir}/models/src/main/java/com/demoapp/models/requests/apithing-files"
FileTree files = fileTree(dir: apithingDir)
// TreeMap of File names and File Data
TreeMap<String, String> fileMap = new TreeMap<>()
files.each { file ->
Scanner input = new Scanner(file)
String output = ""
while (input.hasNext()) {
output = output + input.nextLine()
}
input.close()
fileMap.put(file.name.take(file.name.lastIndexOf('.')), output)
}
// Build request JSON
def json = new JsonBuilder()
json{
payload {
build_id getVersionCode()
client_id 2
version lastTaggedVersion
is_production isBuildForGPS() ? 1 : 0
queries fileMap.collect {
[
"name": it.key,
"query": it.value
]
}
}
}
// Create POST Request
def url = 'http://services.demoapp.com:8280/purest/performance/app_apithing'
def post = new URL(url).openConnection()
def message = json.toString()
projects.logger.debug(message)
post.setRequestMethod("POST")
post.setRequestProperty("Content-Type", "application/json; charset=utf-8")
post.setDoOutput(true)
post.getOutputStream().write(message.getBytes("UTF-8"))
def responseCode = post.getResponseCode()
if(responseCode >= 200 && responseCode <= 299) {
projects.logger.lifecycle("apithing upload successful.")
} else {
projects.logger.lifecycle("apithing Upload Failed with response: ${post.getResponseMessage()}")
throw new GradleException("ERROR: Unable to upload apithing files. Server returned a response code: ${responseCode}")
}
}
project.gradle.taskGraph.whenReady {
->
project.tasks.findAll { it.name =~ /connected.+AndroidTest/ }.each {
it.ignoreFailures = true
}
}
def errorOutput(dir) {
println "\n\n================OUTPUT REPORT=================\n\n"
println "The file $dir does not exist\n "
println "Check the current APK Path and Version "
println "\n\n==============================================\n\n"
}
def executeUpload(dir, isUpload, key) {
if (isUpload) {
exec {
commandLine 'curl', 'https://tok_gh6e7yrydkhgqyaz2fvx702y8m#api.appetize.io/v1/apps', '-F', "file=#$dir", '-F', 'platform=android'
}
} else {
exec {
commandLine 'curl', "https://tok_gh6e7yrydkhgqyaz2fvx702y8m#api.appetize.io/v1/apps/$key", '-F', "file=#$dir", '-F', 'platform=android'
}
}
}
apply plugin: 'com.google.gms.google-services'
jacocoAndroidUnitTestReport {
excludes += ['**/R.class','**/R$*.class','**/*$ViewInjector*.*','**/*$ViewBinder*.*','**/BuildConfig.*','**/Manifest*.*','**/*$Lambda$*.*','**/*Module.*','**/*Dagger*.*','**/*MembersInjector*.*','**/*_Provide*Factory*.*','**/*_Factory*.*','**/*$*$*.*','**/test*/**','**/androidTest/**','**/databinding/**']
}
tasks.whenTaskAdded { task ->
if (task.name == 'connecteddemoappDebugAndroidTest' || task.name == 'connecteddemoappflavorDebugAndroidTest') {
task.doFirst() {
exec {
commandLine 'sh', 'get_android_wiremock.sh'
}
}
task.doLast() {
exec {
commandLine 'sh', 'get_device_recordings.sh', 'wiremock_blacklist.txt'
}
}
}
}
android.applicationVariants.all { variant ->
task("checkstyle${variant.name.capitalize()}", type: Checkstyle) {
configFile file("${project.rootDir}/config/quality/checkstyle/checkstyle.xml")
configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath
source 'src'
include '**/*.java'
exclude '**/gen/**'
exclude '**/models/generated/**'
classpath = files() as FileCollection
group = "verification"
}
check.dependsOn("checkstyle${variant.name.capitalize()}")
}
android.applicationVariants.all { variant ->
task("findbugs${variant.name.capitalize()}", type: FindBugs) {
ignoreFailures = false
effort = "default"
reportLevel = "medium"
excludeFilter = new File("${project.rootDir}/config/quality/findbugs/findbugs-filter.xml")
classes = files("${project.rootDir}/app/build/intermediates/classes")
source = fileTree('src/main/java/')
classpath = files()
group = "verification"
reports {
xml.enabled = false
html.enabled = true
xml {
destination "$project.buildDir/findbugs/findbugs-output.xml"
}
html {
destination "$project.buildDir/findbugs/findbugs-output.html"
}
}
dependsOn "compile${variant.name.capitalize()}JavaWithJavac"
}
check.dependsOn("findbugs${variant.name.capitalize()}")
}
android.applicationVariants.all { variant ->
task("buildCheckTest${variant.name.capitalize()}", type: GradleBuild) {
dependsOn "checkstyle${variant.name.capitalize()}"
dependsOn "assemble${variant.name.capitalize()}"
dependsOn "lint${variant.name.capitalize()}"
dependsOn "findbugs${variant.name.capitalize()}"
dependsOn "test${variant.name.capitalize()}UnitTest"
dependsOn "jacocoTest${variant.name.capitalize()}UnitTestReport"
mustRunAfter "clean"
}
}
task buildReleaseTest(type: GradleBuild)
android.applicationVariants.all { variant ->
if (variant.name.endsWith("Release")) {
buildReleaseTest.dependsOn("buildCheckTest${variant.name.capitalize()}")
}
}
android.applicationVariants.all { v ->
if (v.buildType.name == "release"){
v.assemble.dependsOn("uploadapithingFiles")
}
}
buildReleaseTest.mustRunAfter('clean')
task cleanBuildReleaseTest(type: GradleBuild)
cleanBuildReleaseTest.dependsOn('clean')
cleanBuildReleaseTest.dependsOn('buildReleaseTest')
Whoa, that's a lot of plugins. The error message comes because one of them depends on an API that was changed in 3.x (hence migration link). You'll need to update the corresponding plugin.
Based on gradle dependencies run at step 3 below, my guess is gradle.plugin.com.nobleworks_software.icon-overlay:icon-overlay-plugin. It shows com.android.tools.build:gradle:2.2.3 -> 3.0.1 nested under.
(gradlew buildEnvironment on your project may also give you a similar result if you add 3.0.1 Android Gradle Plugin to your build.gradle)
--stacktrace should have also given you the exact location where com.android.build.gradle.tasks.ManifestProcessorTask#getManifestOutputFile was called from. If it doesn't you can still do below:
This is a way I would answer this question if I had an mvce. You have too many plugins to set up everything manually from scratch. This method is also applicable to any Gradle buildscript weirdness in plugins.
Close your project in AS/IDEA
Note: if you have a buildSrc in your project that could also work, so there's no need to close and create another.
Create another project (let's call it debugger) with build.gradle file as follows:
buildscript {}'s contents from your project (but no buildscript block!)
repositories {
jcenter()
...
}
dependencies {
implementation ... // for each classpath ...
}
add plugins { id 'java' } on root level
add implementation 'com.android.tools.build:gradle:3.0.1' inside dependencies
Open this project in IDEA/Android Studio
(this will download all the sources for those plugins)
Run gradlew --no-daemon -Dorg.gradle.debug=true --debug --stacktrace from terminal
(this will stop executing and wait,
note: Listening for transport dt_socket at address: 5005)
Go to "Run/Debug configurations" dialog in debugger project
Create a "Remote" configuration (green +) with parameters from Gradle's log:
Close dialog with OK / Apply
Jump to class/file com.android.build.gradle.tasks.ManifestProcessorTask inside gradle-core-3.0.1-sources.jar
Put a breakpoint at line 128 in ManifestProcessorTask.getManifestOutputFile
To be safe repeat above two steps for gradle-core-3.0.1.jar's decompiled code as well. (line number may differ)
Run menu > Debug "Remote"
Wait and celebrate when breakpoint hits and you see who calls the method in the Debug view's Stack frame listing.
It looks overwhelming, but it's quite simple and fast after you did this once.

./Gradlew Build is taking 2 hours and 40 minutes - Is there any room for improvement?

The app that we are working on is not very large - most of it is an empty application that gets filled in from various endpoints (server side), but we currently have 18 separate flavors of the app that get built.
The issue is, there will be 78 flavors of the application built and if the build time is linear, we are looking at about 11 hours per ./gradlew build request.
Im not well versed in Gradle at all and I was hoping you guys could help me find some problem areas that might be able to improve our build times
Here is the build.gradle:
apply plugin: 'com.android.application'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'io.fabric'
apply from: '../jacoco.gradle'
apply from: '../flavors.gradle'
apply from: '../autoTasks.gradle'
ext {
applicationName = 'OurApp'
supportLibVersion = '25.3.0'
playServicesVersion = '9.6.1'
}
android {
signingConfigs {
debug {
keyAlias 'key'
keyPassword 'pass'
storeFile file('../file.keystore')
storePassword 'pass'
}
release {
keyAlias 'key'
keyPassword 'pass'
storeFile file('../file.jks')
storePassword 'pass'
}
}
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
vectorDrawables.useSupportLibrary true
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
multiDexEnabled true
}
dataBinding {
enabled true
}
lintOptions {
abortOnError false
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
buildConfigField 'String', 'DFP_NETWORK_ID', '"id"'
buildConfigField 'String', 'YOUTUBE_API_KEY', '"ourkey"'
}
debug {
signingConfig signingConfigs.debug
testCoverageEnabled = true
buildConfigField 'String', 'DFP_NETWORK_ID', '"id"'
buildConfigField 'String', 'YOUTUBE_API_KEY', '"anotherKey"'
}
debuggable.initWith(buildTypes.debug)
debuggable {
testCoverageEnabled = false
}
}
dexOptions {
javaMaxHeapSize "4g"
}
applicationVariants.all { variant ->
if (variant.buildType.name == 'release') {
createZipProguardTask(variant);
}
updateApkName(variant);
}
}
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
annotationProcessor 'com.bluelinelabs:logansquare-compiler:1.3.7'
annotationProcessor 'com.squareup:javapoet:1.8.0'
annotationProcessor 'com.google.dagger:dagger-compiler:2.7'
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile "com.android.support:recyclerview-v7:${supportLibVersion}"
compile "com.android.support:support-v13:${supportLibVersion}"
compile "com.android.support:percent:${supportLibVersion}"
compile "com.android.support:preference-v14:${supportLibVersion}"
compile "com.google.android.gms:play-services-gcm:${playServicesVersion}"
compile "com.google.android.gms:play-services-maps:${playServicesVersion}"
compile "com.google.firebase:firebase-core:${playServicesVersion}"
compile "com.google.firebase:firebase-messaging:${playServicesVersion}"
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.roughike:bottom-bar:2.2.0'
compile 'io.reactivex.rxjava2:rxjava:2.0.1'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.l4digital.rxloader:rxloader:2.0.1'
compile 'com.bluelinelabs:logansquare:1.3.7'
compile 'com.github.aurae.retrofit2:converter-logansquare:1.4.1'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
compile 'com.google.dagger:dagger:2.7'
compile 'com.facebook.stetho:stetho:1.4.2'
compile 'com.facebook.stetho:stetho-okhttp3:1.4.2'
compile('com.crashlytics.sdk.android:crashlytics:2.6.5#aar') {
transitive = true
}
compile(name:'googlemediaframework-release', ext:'aar')
compile "com.google.android.gms:play-services-ads:${playServicesVersion}"
compile "com.google.android.gms:play-services-analytics:${playServicesVersion}"
compile 'com.flurry.android:ads:6.2.0'
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
compile 'com.google.android.exoplayer:exoplayer:r1.5.14'
compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.5.0'
debugCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
debuggableCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.squareup.okhttp3:okhttp:3.5.0'
androidTestCompile 'org.mockito:mockito-core:1.10.19'
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
androidTestCompile('com.android.support.test:rules:0.5') {
exclude module: 'support-annotations'
}
androidTestCompile (name:'cloudtestingscreenshotter_lib', ext:'aar')
androidTestCompile('com.android.support.test:runner:0.5') {
exclude module: 'support-annotations'
}
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2') {
exclude module: 'support-annotations'
}
compile(name:'MapSDK', ext:'aar')
compile('com.twitter.sdk.android:twitter:2.3.2#aar') {
transitive = true;
}
}
def createZipProguardTask(variant) {
def prefix = project.ext.applicationName;
if (project.hasProperty('buildNumber')) {
prefix += '-' + project.getProperties().get('buildNumber');
}
def taskName = variant.flavorName.substring(0, 1).toUpperCase() + variant.flavorName.substring(1);
task("zipProguard${taskName}", type: Zip) {
archiveName = "${prefix}-${variant.flavorName}-proguard.zip";
from "build/outputs/mapping/${variant.flavorName}/release"
destinationDir file('build/outputs/mapping')
}
}
def updateApkName(variant) {
def prefix = project.ext.applicationName;
if (project.hasProperty('buildNumber')) {
prefix += '-' + project.getProperties().get('buildNumber');
}
variant.outputs.each { output ->
def fileName = output.outputFile.name.replace('app', prefix);
def outputFile = new File(output.outputFile.parent.toString(), fileName.toString());
output.outputFile = outputFile;
}
}
Here is what we have in the gradle properties:
org.gradle.jvmargs=-Xmx4608M -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.daemon=true
Any input would be greatly appreciated - like I said, I'm not well versed in gradle at all, so I'm open to anything.
Thank you in advance
I'm sure you figured something out by now, but just for future googlers -
Android Studio gradle takes too long to build improved the speed of my gradle build drastically. It suggests enabling Offline work in Android Studio by going to file>settings>build, execution, deployment>gradle and checking the "Offline work" option.

Gradle execution failed for task

Once a while while building my project i keep getting:
Error:Gradle: Execution failed for task ':app:packageProductionDebug'.
> value (115422) > 0x0000ffff
This happens for 30%-50% attempts to run my project regardless of device.
I've tried to clean my project but still no luck.
The value (115422)seems to be changing but the hex value remains the same.
EDIT
My gradle file
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.myapp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "0.1"
buildConfigField 'String', 'BUILD_DIR', "\"${project.buildDir}\""
}
dexOptions {
javaMaxHeapSize "4g"
}
testOptions {
unitTests.returnDefaultValues = true
}
/* set file name depending on build variant*/
applicationVariants.all { variant ->
variant.outputs.each { output ->
def filename = applicationId
if (variant.buildType.isDebuggable()) {
filename += '-debug';
} else {
filename += '-vc-' + variant.versionCode
}
filename += '.apk'
output.outputFile = new File(
output.outputFile.parent,
filename
)
}
}
productFlavors{
staging{
applicationId = 'com.myapp.beta'
manifestPlaceholders = [activityLabel:"myapp.STAGING"]
multiDexEnabled true
}
production {
applicationId = 'com.myapp'
manifestPlaceholders = [activityLabel:"myapp"]
multiDexEnabled true
}
instrTest {
applicationId = 'com.myapp'
manifestPlaceholders = [activityLabel:"myapp"]
multiDexEnabled true
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-release.pro'
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-debug.pro'
}
}
sourceSets {
main{
java.srcDirs = ['src/main/java']
assets.srcDirs = ['src/main/assets']
}
productionDebug{
assets.srcDirs = ['src/main/assets', 'src/test/assets']
}
stagingDebug{
assets.srcDirs = ['src/main/assets', 'src/test/assets']
}
staging {
java.srcDirs = ['src/staging/java']
}
production{
java.srcDirs = ['src/production/java']
}
instrTest{
assets.srcDirs = ['src/main/assets', 'src/test/assets']
java.srcDirs = ['src/instrTest/java']
manifest.srcFile 'src/instrTest/AndroidManifest.xml'
res.srcDirs = ['src/instrTest/','src/instrTest/res']
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:support-v4:23.+'
compile 'com.android.support:recyclerview-v7:23.+'
compile 'com.android.support:support-v4:23.+'
compile 'com.android.support:cardview-v7:23.+'
compile 'com.android.support:support-annotations:22.2.0'
compile 'com.android.support:design:22.2.1'
compile 'com.google.android.gms:play-services-analytics:8.1.0'
compile 'com.google.android.gms:play-services-gcm:8.1.0'
compile 'com.google.guava:guava:19.0-rc1'
compile 'com.urbanairship.android:urbanairship-sdk:6.3.+'
compile 'com.googlecode.libphonenumber:libphonenumber:7.0.10'
compile 'com.mcxiaoke.volley:library:1.0.18'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'biz.source_code:base64coder:2010-09-21'
compile 'org.iban4j:iban4j:3.0.4'
compile 'com.romainpiel.shimmer:library:1.4.0#aar'
compile 'org.apmem.tools:layouts:1.9#aar'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.tsums.androidcookiejar:androidcookiejar:1.0#aar'
compile 'com.squareup.okhttp3:okhttp:3.0.0-RC1'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.7.1'
compile 'com.google.code.gson:gson:2.6.2'
compile 'io.reactivex:rxjava:1.1.0'
compile 'io.reactivex:rxandroid:1.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'me.dm7.barcodescanner:zxing:1.8.4'
testCompile 'junit:junit:4.12'
testCompile 'org.easytesting:fest:1.0.16'
testCompile ('com.squareup:fest-android:1.0.8'){
exclude module: 'support-v4'
}
testCompile 'org.robolectric:robolectric:3.0'
testCompile "org.mockito:mockito-core:1.+"
compile project(':cropimage')
compile project(':viewpagerindicator')
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
}
I've also tried to run the tasks from terminal with --stack option and got:
Caused by: java.lang.IllegalArgumentException: value (172858) > 0x0000ffff
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:148)
at com.android.builder.internal.packaging.zip.ZipField.write(ZipField.java:228)
at com.android.builder.internal.packaging.zip.StoredEntry.toHeaderData(StoredEntry.java:651)
at com.android.builder.internal.packaging.zip.ZFile.writeEntry(ZFile.java:944)
at com.android.builder.internal.packaging.zip.ZFile.update(ZFile.java:858)
at com.android.builder.internal.packaging.zip.ZFile.close(ZFile.java:900)
at com.android.builder.internal.packaging.zfile.ApkZFileCreator.close(ApkZFileCreator.java:128)
at com.google.common.io.Closer.close(Closer.java:214)
at com.android.builder.internal.packaging.IncrementalPackager.close(IncrementalPackager.java:343)
at com.google.common.io.Closer.close(Closer.java:214)
at com.android.build.gradle.tasks.PackageAndroidArtifact.doTask(PackageAndroidArtifact.java:448)
at com.android.build.gradle.tasks.PackageAndroidArtifact.doIncrementalTaskAction(PackageAndroidArtifact.java:580)
at com.android.build.gradle.tasks.PackageApplication.doIncrementalTaskAction(PackageApplication.java:82)
at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:108)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:244)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:220)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:231)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:209)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
... 14 more
I am not certain but I'm pretty sure it's a bug in Android Studio 2.2, and do not have enough reputation to make a comment. Killing Java(.exe) fixes it.

Categories

Resources