Gradle execution failed for task - android

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.

Related

How to solve could not find method compile() for arguments com.android.support:recyclerview-v7:25.3.1?

In my android studio build gradle is failed i dont know how so then i check the log and i saw this error
Error:Could not find method compile() for arguments
[com.android.support:recyclerview-v7:25.3.1] on object of type
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Please install the Android Support Repository from the Android SDK
Manager. Open Android SDK Manager
then i check it but android support respository is already installed version 47.0.0 i restart android studio but it shows same error how i solve this error from android studio please help me to solve this problem?
I think something is wrong on my build gradle but i cant get it where is wrong or what happens
here is my build gradle sample-------
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven {
url "https://github.com/Blox/blox-android-sdk-releases/raw/master/"
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.android.tools.build:gradle:2.3.0'
ext {
compileSdkVersion = 23
buildToolsVersion = "23.0.2"
minSdkVersion = 14
targetSdkVersion = 23
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
lintAbortOnError = false
// Blox SDK version
ext.qbSdkVersion = '3.3.1'
ext.versionName = '3.3.0'
ext.testRunnerVersion = "0.4.1"
// Dependency versions
playServicesVersion = '10.2.1'
supportV4Version = '23.1.1'
appcompatV7Version = '23.1.1'
recyclerviewV7Version = '23.2.1'
supportAnnotationsVersion = '23.1.1'
designVersion = '23.1.1'
uilVersion = '1.9.0'
glideVersion = '3.6.1'
pullToRefreshVersion = '3.2.3'
stickyListHeaders = '2.7.0'
robotoTextViewVersion = '2.4.3'
stickersVersion = '0.7.3'
crashlyticsVersion = '2.2.2'
}
compile "com.android.support:recyclerview-v7:25.3.1"
compile "com.android.support:recyclerview-v7:27.1.1"
compile "com.android.support:cardview-v7:23.+"
compile "com.android.support:support-annotations:${rootProject.supportAnnotationsVersion}"
compile "com.navercorp.pulltorefresh:library:${rootProject.pullToRefreshVersion}#aar"
compile("com.crashlytics.sdk.android:crashlytics:${rootProject.crashlyticsVersion}#aar") {
transitive = true;
}
compile 'com.github.bumptech.glide:glide:3.6.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
// Blox SDK version
qbSdkVersion = '3.3.1'
versionName = '3.4.1'
testRunnerVersion = "0.4.1"
allprojects {
repositories {
maven { url 'http://maven.pipe.com/artifactory/factory' }
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
}`
Android \ build gradle
`apply plugin: 'com.android.application'
android {
// signingConfigs {
// config {
// keyAlias 'abc'
// keyPassword 'abc'
// storeFile file(D:\Users\Lake\Desktop\myap_keystore\myap.jks)
// storePassword 'abc'
// }
// defaultConfig {
// applicationId "abcd.com.myap"
// minSdkVersion 19
// targetSdkVersion 23
// versionCode 1
// versionName "1.0"
// }
// }
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "abc.com.myap"
minSdkVersion 23
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable true
// signingConfig signingConfigs.config
resValue "string", "versionName", "Blox WebRTC\nBuild version " + defaultConfig.getVersionName()
signingConfig signingConfigs.debug
}
}
// debug {
resValue "string", "versionName", "Blox WebRTC\nBuild version " + defaultConfig.getVersionName()
signingConfig signingConfigs.debug
}
// signingConfig signingConfigs.config
// debuggable true
// }
}
}
def pipeSdkVersion = '0.15.1'
dependencies {
compile "com.blox-android-sdk-videochat-webrtc:$rootProject.qbSdkVersion"
compile(project(":sample-core"))
// online dependencies, from remote repository, aar files
compile fileTree(include: ['*.jar'], dir: 'libs')
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-core:9.2.0'
compile 'com.android.support:design:25.3.1'
compile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-appindexing:9.8.0'
compile 'com.android.support:gridlayout-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.google.android.gms:play-services:11.0.4'
compile 'com.github.apl-devs:intro:v4.2.2'
compile("vc908.stickers:sfactory:$pipeSdkVersion") {
transitive = true;
}
compile("vc908.stickers:gcmintegration:$pipeSdkVersion") {
transitive = true;
}
compile("vc908.stickers:jpushintegration:$pipeSdkVersion") {
transitive = true;
}
compile files('libs/StartAppInApp-3.6.3.jar')
compile 'com.blox:blox-android-sdk-core:2.5.1'
compile('com.blox:blox-android-sdk-chat:2.5.1#aar') {
transitive = true
}
compile "com.blox:blox-android-sdk-chat:$rootProject.qbSdkVersion"
compile "com.blox:quickblox-android-sdk-content:$rootProject.qbSdkVersion"
compile "com.blox:quickblox-android-sdk-customobjects:$rootProject.qbSdkVersion"
compile "com.blox:quickblox-android-sdk-location:$rootProject.qbSdkVersion"
compile ("com.blox:blox-android-sdk-messages:$rootProject.qbSdkVersion" )
compile "com.github.johnkil.android-robototextview:robototextview:${rootProject.robotoTextViewVersion}"
apply plugin: 'com.google.gms.google-services'
}
`
[NOTE:I am using javascript snippets here for showing code properly]
Replace compile with implementation and you should be good.
(compile was recently deprecated and replaced by implementation or api)
You are adding these dependencies to build.gradle(Project)
compile "com.android.support:recyclerview-v7:25.3.1"
compile "com.android.support:recyclerview-v7:27.1.1"
compile "com.android.support:cardview-v7:23.+"
compile "com.android.support:support-annotations:${rootProject.supportAnnotationsVersion}"
compile "com.navercorp.pulltorefresh:library:${rootProject.pullToRefreshVersion}#aar"
compile("com.crashlytics.sdk.android:crashlytics:${rootProject.crashlyticsVersion}#aar") {
transitive = true;
}
compile 'com.github.bumptech.glide:glide:3.6.1'
Instead put dependencies in build.gradle(Module:app) and replace compile with implementation as 'compile' is obsolete and has been replaced with 'implementation'
i changed dependencies with the code:
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Worked for me

Execution failed for task ':app:transformClassesWithInstantRunForClientDebug'

The error
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.neenbedankt.android-apt'
dependencies {
compile project(':venuemap')
// compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
// compile "com.android.support:support-v4:$rootProject.supportLibraryVersion"
// compile "com.android.support:design:$rootProject.supportLibraryVersion"
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:support-v4:25.1.0'
// compile "com.google.android.gms:play-services:$rootProject.playServicesVersion"
compile "com.google.android.gms:play-services-location:$rootProject.playServicesVersion"
compile "com.google.android.gms:play-services-maps:$rootProject.playServicesVersion"
compile "com.google.android.gms:play-services-plus:$rootProject.playServicesVersion"
compile "com.squareup.retrofit2:retrofit:$rootProject.retrofitVersion"
compile "com.squareup.retrofit2:converter-gson:$rootProject.retrofitVersion"
compile "com.squareup.okhttp3:okhttp:$rootProject.okhttpVersion"
compile "com.squareup.okhttp3:logging-interceptor:$rootProject.okhttpVersion"
compile 'com.google.maps.android:android-maps-utils:0.4.4'
// compile 'com.google.maps.android:android-maps-utils:0.4+'
// compile 'com.google.maps.android:android-maps-utils:0.5+'
compile 'net.hockeyapp.android:HockeySDK:4.1.1'
compile 'com.flurry.android:analytics:6.5.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0#aar'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'org.parceler:parceler-api:1.1.9'
compile 'com.github.jd-alexander:library:1.1.0'
compile 'com.android.support:multidex:1.0.0'
compile "com.google.firebase:firebase- core:$rootProject.playServicesVersion"
compile 'com.facebook.android:facebook-android-sdk:4.+'
// annotationProcessor 'org.parceler:parceler:1.1.9'
compile('com.crashlytics.sdk.android:answers:1.4.0#aar') {
transitive = true;
}
}
android {
def defaultApplicationId = "com.yamo.android"
def defaultVersionName = "1.1.7"
def buildNumber = "53" // increment when merging with master
def defaultVersionCode = Integer.parseInt(buildNumber)
def buildNumberSuffix = " (" + buildNumber + ")"
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
applicationId defaultApplicationId
versionCode defaultVersionCode
versionName defaultVersionName
vectorDrawables.useSupportLibrary = true
// multiDexEnabled true
}
signingConfigs {
debug {
storeFile rootProject.file("keystore/debug.keystore")
}
release {
storeFile rootProject.file("keystore/release.keystore")
storePassword "password"
keyAlias "locassa"
keyPassword "password"
}
}
buildTypes {
debug {
minifyEnabled true
useProguard false
signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
useProguard true
shrinkResources true
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
live {
versionName defaultVersionName + buildNumberSuffix
}
client {
versionName defaultVersionName + "-CLIENT" + buildNumberSuffix
applicationId defaultApplicationId
}
internal {
versionName defaultVersionName + "-INTERNAL" + buildNumberSuffix
applicationId defaultApplicationId + ".internal"
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
}
//apply from:
rootProject.file('config/checkstyle/checkstyle.gradle')
apply plugin: 'com.google.gms.google-services'
}
When building app, I have got this error.
I am using android studio 2.3.3.
CompileSdkVersion is 26 and buildToolsVersion is 26.0.2.
And my gradle version is 2.3.3.
I have been searching the solution about this problem for several days but I didn't find anything on google.
Please help me to resolve this error. Thanks a lot!
This is your Problem :
compile 'com.facebook.android:facebook-android-sdk:4.+'
Use this :
compile 'com.facebook.android:facebook-android-sdk:4.4.0'

android gradle build - run task before assembleRelease or assembleLive

Below is my build.gradle file for app.
build.gradle
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' }
google()
}
android {
signingConfigs {
liveSigning {
keyAlias 'xxxxxxx'
keyPassword 'xxxxxx'
storeFile file('D:\\xxxxx\\xxxxxxx\\xxxxx\\xxxx.jks')
storePassword 'xxxxxxx'
}
}
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
useLibrary 'org.apache.http.legacy'
sourceSets.main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [];
}
defaultConfig {
applicationId rootProject.ext.applicationId
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.compileSdkVersion
versionCode rootProject.ext.versionCode
versionName rootProject.ext.versionName
multiDexEnabled true
resConfigs "en"
vectorDrawables.useSupportLibrary true
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.liveSigning
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
task ndkBuild(type: Exec) {
commandLine rootProject.ext.ndkPath, '-C', file('src/main').absolutePath
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
lintOptions {
abortOnError false
}
productFlavors {
live {
minSdkVersion rootProject.ext.minSdkVersion
applicationId rootProject.ext.applicationId
signingConfig signingConfigs.liveSigning
targetSdkVersion rootProject.ext.compileSdkVersion
versionCode rootProject.ext.versionCode
versionName rootProject.ext.versionName
resConfigs "en"
}
}
flavorDimensions "default"
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
//compile files('libs/gson-2.2.4.jar')
compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
compile "com.android.support:cardview-v7:${rootProject.ext.supportLibVersion}"
compile "com.android.support:design:${rootProject.ext.supportLibVersion}"
compile files('libs/cordova-5.jar')
compile files('libs/org.apache.commons.io.jar')
compile files('libs/httpmime-4.2.3.jar')
compile files('libs/jsoup-1.7.3.jar')
compile files('libs/activation.jar')
compile project(':libraries:EventBus')
compile project(':libraries:PDFViewCtrlTools')
compile project(':libraries:imageannotations')
compile project(':libraries:bottom-bar')
compile project(':libraries:tooltip')
compile('com.crashlytics.sdk.android:crashlytics:2.5.2#aar') {
transitive = true;
}
compile files('libs/glide-3.6.1.jar')
//compile 'com.roughike:bottom-bar:2.2.0'
compile project(':libraries:k4l-video-trimmer')
compile 'com.android.support:multidex:1.0.1'
compile 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.0.1'
compile 'com.google.firebase:firebase-messaging:10.2.0'
compile 'me.relex:circleindicator:1.2.2'
compile 'com.daimajia.swipelayout:library:1.2.0#aar'
compile 'org.apache.commons:commons-collections4:4.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
}
apply plugin: 'com.google.gms.google-services'
Before I generate signed APK to upload for google play store , I want to execute command line code. And by using that command line program i want to do some pre release activity like disable logs of NDK, change url to live website and etc. So how can I execute it before assembleLive or assembleRelease ? I don't want to execute that command line code before "assembleDebug". I want to execute it only before "assembleLive or assembleRelease".
I added below code to my gradle file and it works like a charm.
task prelivetask (type: Exec) {
commandLine 'cmd','/C', 'start', 'change.cmd'
}
tasks.whenTaskAdded { task ->
if (task.name == 'assembleRelease' || task.name == 'assembleLive') {
task.dependsOn prelivetask
}
}

./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.

Could not normalize path for file '\ …'1

here i add more information ! i have met this question when i import the project into the Android Studio! Could you help me to make it think you very much!`````````````````````````````````````````````````````````
Caused by: org.gradle.api.UncheckedIOException: Could not normalize path for file '\\ ...'.
at org.gradle.api.internal.file.AbstractFileResolver.normalise(AbstractFileResolver.java:141)
at org.gradle.api.internal.file.AbstractFileResolver.resolve(AbstractFileResolver.java:83)
at org.gradle.api.internal.file.AbstractFileResolver.resolve(AbstractFileResolver.java:63)
at org.gradle.api.internal.file.AbstractFileResolver.convertObjectToURI(AbstractFileResolver.java:177)
at org.gradle.api.internal.file.AbstractFileResolver.resolveUri(AbstractFileResolver.java:168)
at org.gradle.api.internal.artifacts.repositories.DefaultMavenArtifactRepository.getUrl(DefaultMavenArtifactRepository.java:65)
at org.gradle.api.internal.artifacts.repositories.DefaultMavenArtifactRepository_Decorated.getUrl(Unknown Source)
at org.gradle.api.internal.artifacts.repositories.DefaultMavenArtifactRepository.createRealResolver(DefaultMavenArtifactRepository.java:97)
at org.gradle.api.internal.artifacts.repositories.DefaultMavenArtifactRepository.createResolver(DefaultMavenArtifactRepository.java:93)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ResolveIvyFactory.create(ResolveIvyFactory.java:91)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultArtifactDependencyResolver.createComponentSource(DefaultArtifactDependencyResolver.java:114)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultArtifactDependencyResolver.access$100(DefaultArtifactDependencyResolver.java:56)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultArtifactDependencyResolver$1.execute(DefaultArtifactDependencyResolver.java:81)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultArtifactDependencyResolver$1.execute(DefaultArtifactDependencyResolver.java:78)
at org.gradle.internal.Transformers$4.transform(Transformers.java:137)
at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyContextManager.withIvy(DefaultIvyContextManager.java:61)
at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyContextManager.withIvy(DefaultIvyContextManager.java:39)
at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultArtifactDependencyResolver.resolve(DefaultArtifactDependencyResolver.java:78)
at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver$1.run(CacheLockingArtifactDependencyResolver.java:41)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:192)
at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:175)
at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:106)
at org.gradle.cache.internal.DefaultCacheFactory$ReferenceTrackingCache.useCache(DefaultCacheFactory.java:187)
at org.gradle.api.internal.artifacts.ivyservice.DefaultCacheLockingManager.useCache(DefaultCacheLockingManager.java:64)
at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver.resolve(CacheLockingArtifactDependencyResolver.java:39)
at org.gradle.api.internal.artifacts.ivyservice.DefaultConfigurationResolver.resolve(DefaultConfigurationResolver.java:91)
at org.gradle.api.internal.artifacts.ivyservice.SelfResolvingDependencyConfigurationResolver.resolve(SelfResolvingDependencyConfigurationResolver.java:40)
at org.gradle.api.internal.artifacts.ivyservice.ShortCircuitEmptyConfigurationResolver.resolve(ShortCircuitEmptyConfigurationResolver.java:52)
at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver.resolve(ErrorHandlingConfigurationResolver.java:43)
... 83 more
Caused by: java.io.IOException: Invalid argument
at java.io.WinNTFileSystem.canonicalize0(Native Method)
at java.io.WinNTFileSystem.canonicalize(WinNTFileSystem.java:428)
at java.io.File.getCanonicalPath(File.java:618)
at java.io.File.getCanonicalFile(File.java:643)
at org.gradle.api.internal.file.AbstractFileResolver.normalise(AbstractFileResolver.java:98)
... 112 more
here is the gradle
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "io.itit.ititeducation"
minSdkVersion 19
targetSdkVersion 21
versionCode 43
versionName "1.5.3"
}
buildTypes {
debug {
// Disable fabric build ID generation for debug builds
ext.enableCrashlytics = false
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
android.applicationVariants.all {
variant ->
variant.outputs.each {
output ->
output.outputFile = new File(output.outputFile.parent, "科达智慧教育_io.itit.ititeducation_v"
+ defaultConfig.versionName + "_" + defaultConfig.versionCode + ".apk");
}
}
dexOptions {
maxProcessCount 8
javaMaxHeapSize "4g"
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
repositories {
maven { url '// ...' }
maven { url 'https://jitpack.io' }
flatDir {
dirs 'libs'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile('com.mikepenz:materialdrawer:5.1.2#aar') {
transitive = true
}
compile files('libs/zxing.jar')
compile files('libs/jg_filter_sdk_1.1.jar')
compile files('libs/wup-1.0.0.E-SNAPSHOT.jar')
compile files('libs/Xg_sdk_v2.42_20160111_1539.jar')
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.github.afollestad.material-dialogs:core:0.8.5.8'
compile 'com.github.afollestad.material-dialogs:commons:0.8.5.8'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'com.android.support:design:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:cardview-v7:23.3.0'
compile 'me.imid.swipebacklayout.lib:library:1.0.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'cn.trinea.android.common:trinea-android-common:4.2.15'
compile 'com.github.orhanobut:logger:1.12'
compile 'org.xutils:xutils:3.3.25'
compile 'de.greenrobot:greendao:2.1.0'
compile 'com.github.rey5137:material:1.2.2'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'in.srain.cube:ultra-ptr:1.0.11'
compile 'com.romainpiel.shimmer:library:1.4.0#aar'
compile 'com.mikepenz:iconics-core:2.5.10#aar'
compile 'com.mikepenz:google-material-typeface:2.2.0.1.original#aar'
compile 'com.mikepenz:material-design-iconic-typeface:2.2.0.1#aar'
compile 'com.github.qiujuer:genius:2.4.0'
compile 'com.tonicartos:superslim:0.4.13'
compile 'com.github.dexafree:materiallist:3.2.+'
compile 'com.github.dmytrodanylyk.shadow-layout:library:1.0.3'
compile 'com.liulishuo.filedownloader:library:0.2.0'
compile 'com.duwei.pinwheel:pinwheel:0.1'
compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
compile 'se.emilsjolander:stickylistheaders:2.7.0'
compile 'com.baoyz.swipemenulistview:library:1.3.0'
compile 'com.github.dmytrodanylyk.circular-progress-button:library:1.1.3'
compile 'com.umeng.analytics:analytics:latest.integration'
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.github.panwrona:DownloadProgressBar:1.1'
compile 'com.github.traex.rippleeffect:library:1.3'
compile files('libs/photo_library.jar')
compile files('libs/videocache.jar')
compile project(':videolib')
compile project(':itit_lib')
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
}
the other
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'me.tatarka:gradle-retrolambda:3.3.0-beta4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
the other three modules
1
apply plugin: 'com.android.library'
dependencies {
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 21
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
jniLibs.srcDirs = ['libs']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
2
apply plugin: 'com.android.library'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName "1.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.alibaba:fastjson:1.2.8'
compile files('libs/gson-2.2.4.jar')
compile 'com.github.lazylibrary:lazylibrary:1.0.2'
compile 'com.android.support:design:23.3.0'
compile 'com.github.orhanobut:logger:1.12'
compile 'cn.trinea.android.common:trinea-android-common:4.2.15'
compile 'com.github.afollestad.material-dialogs:core:0.8.5.8'
compile 'com.github.afollestad.material-dialogs:commons:0.8.5.8'
compile 'com.mikepenz:iconics-core:2.5.10#aar'
compile 'com.mikepenz:google-material-typeface:2.2.0.1.original#aar'
compile 'com.mikepenz:material-design-iconic-typeface:2.2.0.1#aar'
compile 'com.github.rey5137:material:1.2.2'
compile 'com.joooonho:selectableroundedimageview:1.0.1'
compile('com.mikepenz:materialdrawer:5.1.2#aar') {
transitive = true
}
compile project(':videolib')
}
3
apply plugin: 'java'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'de.greenrobot:greendao-generator:2.1.0'
}
remove "maven { url '// ...' }" line from your build.gradle
repositories {
**maven { url '// ...' }**
maven { url 'https://jitpack.io' }
flatDir {
dirs 'libs'
}
}

Categories

Resources