Category Archives: android-gradle

Android Gradle Dependency

I'm trying to add the following dependency in my cordova project. However, the dependency is getting ignored during build.

compile 'org.apache.httpcomponents:httpclient:4.5.2'

From stackoverflow answers on similar questions, I realized I've to exclude few modules and groups.

So I made the following changes to dependencies.

compile 'org.apache.httpcomponents:httpclient:4.5.2'
compile ('org.apache.httpcomponents:httpclient:4.5.2'){
    exclude module: 'httpclient' //by artifact name
    exclude group: 'org.apache.httpcomponents' //by group
    exclude group: 'org.apache.httpcomponents', module: 'httpclient' //by both name and group
} 

However, I'm still getting this warning.

WARNING: Dependency org.apache.httpcomponents:httpclient:4.5.2 is ignored for debug as it 
 may be conflicting with the internal version provided by Android.
 In case of problem, please repackage it with jarjar to change the class packages.

As a result of this, all my HTTP commands like HTTP Post, HTTP Client etc are not resolved.

Can someone suggest me what exactly has to be excluded and if any configuration changes are required?

Why code of apache(the library 6.0 removed) can also run on Android M phones without measures?

A strange thing I found:

I have a project used the apache library(like org.apache.http.client.methods...,which is removed in android M).I compile it in SDK 5.0 and it runs success on my nexus 5(run in Android M).

I confirm there is no code like "useLibrary 'org.apache.http.legacy'" in my project.

I decompile my app,can not find the apache codes in dex file...

My IDE:Android Studio 1.5.1 Gradle Plugin Version:1.5.0 Gradle Version:2.12

It is so strange:the project can not build in sdk 6.0,but can run on phone of Android M with out "'useLibrary 'org.apache.http.legacy'".

My first question in stackoverflow and weak in english,thanks for your reading!

Gradle erroneously throwing DuplicateFileException for different files

I'm trying to move an Eclipse project, k9mail, to Android Studio, but I'm getting a build error because gradle thinks two of my JAR files are the same:

Error:Execution failed for task ':transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException:     com.android.builder.packaging.DuplicateFileException: Duplicate files copied in     APK META-INF/DEPENDENCIES
File1: C:\k-9\libs\apache-mime4j-dom-0.7.2.jar
File2: C:\k-9\libs\apache-mime4j-core-0.7.2.jar

Anyone know what's going on?

Android : After enabling proguard org.apache.http is not working

In my application, I just enable the Proguard. After enable where ever the api calling by using org.apache.http is not working.

My targetSDKversion is 23 , so i add the library for using org.apache.htpp

Without proguard the release APK is working fine. But after enabling realse apk is not working fine.

Issue is the api is not calling fine

In my proguard_rule.pro

-dontwarn org.apache.http.**
-dontwarn android.net.**
-keep class org.apache.http.** { *; }

After adding these three line the release apk is generated. Before that i got warning like

Warning:library class org.apache.http.conn.scheme.LayeredSocketFactory extends or implements program class org.apache.http.conn.scheme.SocketFactory

Gradle file

 buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'
    }
    }
    apply plugin: 'android'

    dependencies {
    compile fileTree(include: '*.jar', dir: 'libs')
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.android.support:cardview-v7:21.0.+'
    compile 'com.google.android.gms:play-services-ads:7.8.0'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile('com.android.support:support-v4:21.0.3') {
        exclude module: 'support-v4'
    }
    }

    android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    useLibrary 'org.apache.http.legacy'


    defaultConfig {
        minSdkVersion 11
        targetSdkVersion 23

    }

    buildTypes {
        release {
            // signingConfig signingConfigs.release
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['submodules/linphone/mediastreamer2/java/src','submodules/linphone/java/j2se','submodules/linphone/java/common','submodules/linphone/java/impl','submodules/externals/axmlrpc/src/main/java','submodules/linphone/coreapi/help/java','src']
            resources.srcDirs = ['submodules/linphone/mediastreamer2/java/src','submodules/linphone/java/j2se','submodules/linphone/java/common','submodules/linphone/java/impl','submodules/externals/axmlrpc/src/main/java','submodules/linphone/coreapi/help/java','src']
            aidl.srcDirs = ['submodules/linphone/mediastreamer2/java/src','submodules/linphone/java/j2se','submodules/linphone/java/common','submodules/linphone/java/impl','submodules/externals/axmlrpc/src/main/java','submodules/linphone/coreapi/help/java','src']
            renderscript.srcDirs = ['submodules/linphone/mediastreamer2/java/src','submodules/linphone/java/j2se','submodules/linphone/java/common','submodules/linphone/java/impl','submodules/externals/axmlrpc/src/main/java','submodules/linphone/coreapi/help/java','src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
            jniLibs.srcDir 'libs'

            java.exclude '**/mediastream/MediastreamerActivity.java'
        }

        instrumentTest.setRoot('tests')
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }

    dexOptions {
        javaMaxHeapSize "4g"
        preDexLibraries = false
    }

    }

Can anyone please help me to use org.apache.http in Proguard enabled version

duplicate entry error when using POI with gradle

I started a project which needed the Apache POI library. I pasted them in my build.gradle file and everything seemed fine. Until I build the debug app.

I am getting the following error:

Error:Execution failed for task ':mobile:transformClassesWithJarMergingForDebug'.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/xmlbeans/xml/stream/Location.class

I have tried removing and adding exclude group and module, but nothing has helped. When I do get the debug apk to build, and run the app, the app crashes because org.apache.xmlbeans.XmlOptions is not found when opening a DOCX file. The DOC files work fine.

Here is my build.gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "{application_id}"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"

        // Enabling multidex support.
        multiDexEnabled true


    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        encoding "UTF-8"
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    dexOptions {
        javaMaxHeapSize "4g"
        preDexLibraries = false
    }

    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false

        // set to true to turn off analysis progress reporting by lint
        quiet false
        // if true, stop the gradle build if errors are found
        abortOnError true
        // if true, only report errors
        ignoreWarnings false
        // turn off checking the given issue id's
        disable 'TypographyFractions', 'TypographyQuotes'
        // if true, generate a text report of issues (false by default)
        textReport true
        // location to write the output; can be a file or 'stdout'
        textOutput 'stdout'
        // if true, generate an HTML report (with issue explanations, sourcecode, etc)
        htmlReport true
        // optional path to report (default will be lint-results.html in the builddir)
        htmlOutput file("lint-report.html")
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/INDEX.LIST'
        exclude 'META-INF/services/org.apache.sis.storage.DataStoreProvider'
        exclude 'META-INF/BCKEY.SF'
        exclude 'META-INF/spring.handlers'
        exclude 'META-INF/spring.schemas'
        exclude 'META-INF/services/org.apache.tika.detect.Detector'
        exclude 'META-INF/BCKEY.DSA'
        exclude 'META-INF/services/org.apache.sis.internal.jaxb.TypeRegistration'
        exclude 'META-INF/services/org.apache.tika.parser.Parser'
        exclude 'META-INF/cxf/bus-extensions.txt'
    }

}

repositories{

    mavenCentral()
    maven {url "https://github.com/karussell/mvnrepo/raw/master/releases"}
    maven {url  "http://dl.bintray.com/lukaville/maven"}
    maven {url  "http://dl.bintray.com/dasar/maven"}

}

configurations {
    all*.exclude group: 'ch.qos.logback'
    all*.exclude group: 'org.slf4j', module: 'jcl-over-slf4j'
    all*.exclude group: 'org.slf4j', module: 'jul-to-slf4j'
    all*.exclude group: 'org.slf4j', module: 'log4j-over-slf4j'
    all*.exclude group: 'org.slf4j', module: 'jcl-over-slf4j'
    all*.exclude group: 'org.slf4j', module: 'slf4j-log4j12'
    all*.exclude group: 'org.slf4j', module: 'slf4j-simple'
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    wearApp project(':wear')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:support-annotations:23.1.1'

    compile 'com.getbase:floatingactionbutton:1.10.1'

    compile ('org.slf4j:slf4j-android:1.7.13'){
        exclude group: 'net.sf.log4jdbc'
        exclude group: 'org.slf4j.logger'
    }

    compile 'org.jsoup:jsoup:1.7.3'
    compile 'de.jetwick:snacktory:1.1'

    compile 'com.googlecode.juniversalchardet:juniversalchardet:1.0.3'

    // The material design file browser library
    compile 'com.nbsp:library:1.02'

    // Epub library
    compile 'nl.siegmann.epublib:epub-core:[email protected]'


    // Begin for Office documents dependencies

    compile 'org.apache.xmlbeans:xmlbeans:2.6.0'

    compile ('org.apache.poi:poi:3.13'){
        transitive = false
        exclude group: 'org.apache.xmlbeans'
        exclude module: 'org.apache.xmlbeans'
    }

    compile ('org.apache.poi:poi-ooxml:3.13'){
        transitive = false
        exclude group: 'org.apache.xmlbeans'
        exclude module: 'org.apache.xmlbeans'
    }

    compile ('org.apache.poi:poi-scratchpad:3.13'){
        transitive = false
        exclude group: 'org.apache.xmlbeans'
        exclude module: 'org.apache.xmlbeans'
    }

    compile ('org.apache.tika:tika-core:1.11'){
        transitive = false
        exclude group: 'org.apache.xmlbeans'
    }
    compile ('org.apache.tika:tika-parsers:1.11'){
        transitive = false
        exclude group: 'org.apache.xmlbeans'
        exclude module: 'org.apache.xmlbeans'
    }
    // End for Office documents dependencies

    // PDF document library
    compile 'com.itextpdf:itextpdf:5.5.8'



}

I have checked if there are any other dependencies using the org.apache.xmlbeans dependency, but I haven't found one.

If anybody would have a solution, please feel free to answer the question, but I would appreciate it if you tell us how you come to the answer.

Tim

duplicate entry error when using POI with gradle

I started a project which needed the Apache POI library. I pasted them in my build.gradle file and everything seemed fine. Until I build the debug app.

I am getting the following error:

Error:Execution failed for task ':mobile:transformClassesWithJarMergingForDebug'.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/xmlbeans/xml/stream/Location.class

I have tried removing and adding exclude group and module, but nothing has helped. When I do get the debug apk to build, and run the app, the app crashes because org.apache.xmlbeans.XmlOptions is not found when opening a DOCX file. The DOC files work fine.

Here is my build.gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "{application_id}"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"

        // Enabling multidex support.
        multiDexEnabled true


    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        encoding "UTF-8"
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    dexOptions {
        javaMaxHeapSize "4g"
        preDexLibraries = false
    }

    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false

        // set to true to turn off analysis progress reporting by lint
        quiet false
        // if true, stop the gradle build if errors are found
        abortOnError true
        // if true, only report errors
        ignoreWarnings false
        // turn off checking the given issue id's
        disable 'TypographyFractions', 'TypographyQuotes'
        // if true, generate a text report of issues (false by default)
        textReport true
        // location to write the output; can be a file or 'stdout'
        textOutput 'stdout'
        // if true, generate an HTML report (with issue explanations, sourcecode, etc)
        htmlReport true
        // optional path to report (default will be lint-results.html in the builddir)
        htmlOutput file("lint-report.html")
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/INDEX.LIST'
        exclude 'META-INF/services/org.apache.sis.storage.DataStoreProvider'
        exclude 'META-INF/BCKEY.SF'
        exclude 'META-INF/spring.handlers'
        exclude 'META-INF/spring.schemas'
        exclude 'META-INF/services/org.apache.tika.detect.Detector'
        exclude 'META-INF/BCKEY.DSA'
        exclude 'META-INF/services/org.apache.sis.internal.jaxb.TypeRegistration'
        exclude 'META-INF/services/org.apache.tika.parser.Parser'
        exclude 'META-INF/cxf/bus-extensions.txt'
    }

}

repositories{

    mavenCentral()
    maven {url "https://github.com/karussell/mvnrepo/raw/master/releases"}
    maven {url  "http://dl.bintray.com/lukaville/maven"}
    maven {url  "http://dl.bintray.com/dasar/maven"}

}

configurations {
    all*.exclude group: 'ch.qos.logback'
    all*.exclude group: 'org.slf4j', module: 'jcl-over-slf4j'
    all*.exclude group: 'org.slf4j', module: 'jul-to-slf4j'
    all*.exclude group: 'org.slf4j', module: 'log4j-over-slf4j'
    all*.exclude group: 'org.slf4j', module: 'jcl-over-slf4j'
    all*.exclude group: 'org.slf4j', module: 'slf4j-log4j12'
    all*.exclude group: 'org.slf4j', module: 'slf4j-simple'
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    wearApp project(':wear')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:support-annotations:23.1.1'

    compile 'com.getbase:floatingactionbutton:1.10.1'

    compile ('org.slf4j:slf4j-android:1.7.13'){
        exclude group: 'net.sf.log4jdbc'
        exclude group: 'org.slf4j.logger'
    }

    compile 'org.jsoup:jsoup:1.7.3'
    compile 'de.jetwick:snacktory:1.1'

    compile 'com.googlecode.juniversalchardet:juniversalchardet:1.0.3'

    // The material design file browser library
    compile 'com.nbsp:library:1.02'

    // Epub library
    compile 'nl.siegmann.epublib:epub-core:[email protected]'


    // Begin for Office documents dependencies

    compile 'org.apache.xmlbeans:xmlbeans:2.6.0'

    compile ('org.apache.poi:poi:3.13'){
        transitive = false
        exclude group: 'org.apache.xmlbeans'
        exclude module: 'org.apache.xmlbeans'
    }

    compile ('org.apache.poi:poi-ooxml:3.13'){
        transitive = false
        exclude group: 'org.apache.xmlbeans'
        exclude module: 'org.apache.xmlbeans'
    }

    compile ('org.apache.poi:poi-scratchpad:3.13'){
        transitive = false
        exclude group: 'org.apache.xmlbeans'
        exclude module: 'org.apache.xmlbeans'
    }

    compile ('org.apache.tika:tika-core:1.11'){
        transitive = false
        exclude group: 'org.apache.xmlbeans'
    }
    compile ('org.apache.tika:tika-parsers:1.11'){
        transitive = false
        exclude group: 'org.apache.xmlbeans'
        exclude module: 'org.apache.xmlbeans'
    }
    // End for Office documents dependencies

    // PDF document library
    compile 'com.itextpdf:itextpdf:5.5.8'



}

I have checked if there are any other dependencies using the org.apache.xmlbeans dependency, but I haven't found one.

If anybody would have a solution, please feel free to answer the question, but I would appreciate it if you tell us how you come to the answer.

Tim

EDIT:

When executing this command:

gradlew -q dependencies mobile:dependencies --configuration compile

(output here: http://pastebin.com/7TugFR3J) The org.apache.xmlbeans dependency is only listed once. Might there be a problem relating to any default java component?

EDIT NO.2:

I found that Java has a component like this: javax/xml/stream/Location.class So I think I need to remove it from the build, but I don't know how.

Importing in android studio 5.1

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair; ok
import org.apache.http.client.HttpClient; ok 
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost; ok
import org.apache.http.impl.client.DefaultHttpClient;ok
import org.apache.http.message.BasicNameValuePair;

new in android and I cant import the ff: already search for instructions but still it's not imported in library

Here's my dependencies tab:

enter image description here

Multiple dex files define Lorg/apache/http/Consts with httpcomponents dependency

I am using below imports for my uploader (a module in my project not in app module) :

import org.apache.http.HttpEntity;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.ContentBody;
import org.apache.http.entity.mime.content.FileBody;

httpcore:4.4.2 httpmime:4.5

contains this imports. when i want to compile the code i got below error in my Gradle console.

com.android.dex.DexException: Multiple dex files define Lorg/apache/http/Consts;
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
    at com.android.dx.command.dexer.Main.run(Main.java:277)
    at com.android.dx.command.dexer.Main.main(Main.java:245)
    at com.android.dx.command.Main.main(Main.java:106)

this is my build.gradle of this module :

apply plugin: 'com.android.library'

android {
    compileSdkVersion rootProject.ext.compileSdkVersion as Integer
    buildToolsVersion rootProject.ext.buildToolsVersion as String

    defaultConfig {
        minSdkVersion rootProject.ext.minSdkVersion as Integer
        targetSdkVersion rootProject.ext.targetSdkVersion as Integer
        versionCode rootProject.ext.versionCode as Integer
        versionName rootProject.ext.versionName as String
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile project(':lib-ComponentsUtils')

    compile 'org.apache.httpcomponents:httpcore:4.4.2'
    compile('org.apache.httpcomponents:httpmime:4.5') {
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
    }
    compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
}

Note : i read this question and i am using

exclude group: 'org.apache.httpcomponents', module: 'httpclient'

Gradle exception with ClassLoaderLogManager on Apache Tomcat 7

I'm compiling Android APK files with command line in five servers. The five servers has apache tomcat 7 compiling with a .war jsp app (using java) android apks. My .war jsp file uses gradlew assembleRelease in command line to compile the apks.

In four of my servers it works perfectly but in my linux server i got a exception.

  • Windows Server 2008 -> OK, no exception
  • Windows Server 2008 2 -> OK, no exception
  • OS X -> OK, no exception
  • OX X 2 -> OK, no exception
  • Linux -> Exception

I will add the gradle files of my project below the exception text, but i think this problem is not of my gradle files, it works in four of my servers, so i think it is a problem of my linux server apache tomcat config or something

This is the exception:

Could not load Logmanager "org.apache.juli.ClassLoaderLogManager"
java.lang.ClassNotFoundException: org.apache.juli.ClassLoaderLogManager
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    at java.util.logging.LogManager$1.run(LogManager.java:186)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.util.logging.LogManager.<clinit>(LogManager.java:176)
    at org.gradle.logging.internal.JavaUtilLoggingConfigurer.configure(JavaUtilLoggingConfigurer.java:36)
    at org.gradle.logging.internal.DefaultLoggingConfigurer.configure(DefaultLoggingConfigurer.java:34)
    at org.gradle.logging.internal.LoggingSystemAdapter.setLevel(LoggingSystemAdapter.java:55)
    at org.gradle.logging.internal.LoggingSystemAdapter.on(LoggingSystemAdapter.java:42)
    at org.gradle.logging.internal.DefaultLoggingManager$StartableLoggingSystem.start(DefaultLoggingManager.java:173)
    at org.gradle.logging.internal.DefaultLoggingManager.start(DefaultLoggingManager.java:58)
    at org.gradle.logging.internal.DefaultLoggingManager.start(DefaultLoggingManager.java:29)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:201)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
    at org.gradle.launcher.Main.doAction(Main.java:33)
    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)

These are my gradle files:

Main project gradle file:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

Application module gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'Google Inc.:Google APIs:22'
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.example.launcher"
        minSdkVersion 10
        targetSdkVersion 10
        versionCode 1
        versionName "1.0"
    }

    signingConfigs {
        release {
            storeFile file("dummy")
            storePassword "dummy"
            keyAlias "dummy"
            keyPassword "dummy"
        }
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
            signingConfig signingConfigs.release
        }
        debug {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
        }
    }
}

dependencies {
    compile project(':capLibrary')
}

Library module gradle file:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 'Google Inc.:Google APIs:22'
    buildToolsVersion "22.0.1"

    defaultConfig {
        minSdkVersion 10
        targetSdkVersion 10
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
        }
        debug {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:22.2.1'
    compile 'com.google.android.gms:play-services-analytics:7.8.0'
    compile 'com.google.android.gms:play-services-gcm:7.8.0'
    compile 'com.google.android.gms:play-services-location:7.8.0'
    compile 'com.google.android.gms:play-services-maps:7.8.0'
    compile 'com.google.android.gms:play-services-ads:7.8.0'
    compile fileTree(include: ['*.jar'], dir: 'libs')
}