Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't build project, problems with gradle?

I'm trying to switch from eclipse to android studio for my android development. However, I still haven't found the right way to import my existing project. I don't know if it is important: but I'm using a mac

I did the export step in eclipse, imported this gradle build in Android Studio, but when I try to build my project, it gives me this error:

Gradle: 
FAILURE: Could not determine which tasks to execute.
* What went wrong:
Task 'assembleDebug' not found in project ':ProjectName'.
* Try:
Run gradle tasks to get a list of available tasks.

Could not execute build using Gradle installation '/Users/<username>/Development/Build/gradle-1.6'.

This is the build.gradle file that eclipse gave me:

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

dependencies {
    compile project(':ProjectName:library:ActionBarSherlock')
    compile project(':ProjectName:library:facebook')
    compile files('../../../../../../../ProjectName/libs/gcm.jar')
    compile files('../../../../../../../ProjectName/libs/libGoogleAnalyticsV2.jar')
    compile files('../../../../../../../ProjectName/libs/commons-lang3-3.1.jar')
    compile files('../../../../../../../ProjectName/libs/actionbarsherlock-plugin-maps-4.2.0.jar')
    compile files('../../../../../../../NiteOwl/libs/volley.jar')
    compile project(':ProjectName:library:PullToRefresh')
    compile project(':ProjectName:library:google-play-services_lib')
}

    android {
    compileSdkVersion 17
    buildToolsVersion "17"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 17
    }
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        instrumentTest.setRoot('tests')
    }
}

I've seen a lot of possible solutions, but none of them worked for me, any idea what I'm doing wrong?

The path to the project has no spaces in it

jar libraries => ProjectName/libs

android libraries => ProjectName/library

all of this was working in eclipse

like image 442
Quentin Avatar asked Jul 03 '13 20:07

Quentin


2 Answers

We recently moved our project to gradle as well. We ran into issues due to the library projects.

To solve it we added a settings.gradle file in the root of your project with

include ':libs:actionbarsherlock'
include ':yourprojectname'

Add all your library projects from eclipse into the settings.gradle

We also made a build.gradle file for each of the library Projects.

AFAIK the export from eclipse doesn't deal well with library projects.

like image 112
Stewart Avatar answered Sep 25 '22 20:09

Stewart


In the build.gradle at the root of your project (the one that's probably mostly empty), add the following line:

task assemble{}

Found at https://code.google.com/p/android/issues/detail?id=57531

like image 45
ItsJason Avatar answered Sep 21 '22 20:09

ItsJason