Mando
Mando

Reputation: 11712

Error building android project with gradle from terminal

I have a simple project androidproj which I'm trying to build with Jenkins. That is the reason I'm trying to build it from terminal with gradle. The project consists from:

  1. androidmodule1
  2. androidapp1 (androidapp1 has dependency on androidmodule1)

When I execute the cradle by using the following line:

./gradlew build --stacktrace

I get the following error:

FAILURE: Build failed with an exception.

  • Where: Build file '/Volumes/Storage/Jenkins/jobs/XXX-Android-Compilation/workspace/android/androidmodule1/build.gradle' line: 17

  • What went wrong: A problem occurred evaluating project ':androidmodule1'.

    Ambiguous method overloading for method java.io.File#. Cannot resolve which method to invoke for [null, class java.lang.String] due to overlapping prototypes between: [class java.lang.String, class java.lang.String] [class java.io.File, class java.lang.String]

I found this topic and checked that required SDK is installed, build tools are available:

enter image description here

ANDROID_HOME variable is set:

admin$ echo $ANDROID_HOME /Users/admin/Library/Developer/Xamarin/android-sdk-macosx

My gradle is:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.company.androidmodule1"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

Locally project started just fine. Do you have any suggestions?

Upvotes: 1

Views: 436

Answers (1)

Mando
Mando

Reputation: 11712

It turned our that Jenkins for some reason wasn't able to see configured environment variables. I had to go to Jenkins->Configuration->Environment Variables and manually specify JAVA_HOME & ANDROID_HOME paths:

enter image description here

Upvotes: 1

Related Questions