Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Neither path nor baseDir may be null or empty string." error when importing gradle project in Android Studio 0.2.9

NOTE: i can't post links, so i guess you'll need to go here to follow the references. sorry, not my rule.

i'm getting the following error when attempting to import a project into Android Studio 0.2.9:

Could not execute build using Gradle distribution 
'http://services.gradle.org/distributions-snapshots/
gradle-1.8-20130830160653+0000-bin.zip'.
A problem occurred configuring project ':library'.
A problem occurred configuring project ':library'.
Failed to notify project evaluation listener.
Neither path nor baseDir may be null or empty 
string. path='' basedir='<projects folder>/
drag-sort-listview/library'

Consult IDE log for more details (Help | Show Log)

the project was originally a Maven project (1). i opened it in Eclipse ADT, generated a /librabry/build.gradle file per the instructions at (2).

the Eclipse ADT generated build.gradle looked like:

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

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

android {
    compileSdkVersion 7
    buildToolsVersion "17.0.0"

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['']
            resources.srcDirs = ['']
            aidl.srcDirs = ['']
            renderscript.srcDirs = ['']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        instrumentTest.setRoot('tests')
    }
}

i had to change line 6 from

classpath 'com.android.tools.build:gradle:0.4'

to

classpath 'com.android.tools.build:gradle:0.5+'

to get Android Studio to stop saying the versions were miss-matched. i also added a /settings.gradle file containing

include ':library'

and a /local.properties file with the contents

# This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.

# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=/Applications/Android Studio.app/sdk

i then attempted to import the /settings.gradle file by selecting it in the 'File | Import Project...' dialog. i have 'Use Auto-import' checked and 'Use gradle wrapper with verification' option selected in the dialog (3). the full idea.log entry can be viewed at (4).

any help would be greatly appreciated, thanks.

like image 554
nrser Avatar asked Sep 23 '13 08:09

nrser


1 Answers

This will happen if you are using Environment Variables like so:

android {
signingConfigs {
    release {
        storeFile file(RELEASE_STORE_FILE)
        storePassword RELEASE_STORE_PASSWORD
        keyAlias RELEASE_KEY_ALIAS
        keyPassword RELEASE_KEY_PASSWORD
    }
}

And you have not defined those variables in your gradle.properties file located at the root of your project.

To fix this, make sure your variables are defined, here is an example from my gradle.properties file:

RELEASE_STORE_FILE=app_keystore.jks
RELEASE_STORE_PASSWORD=password
RELEASE_KEY_ALIAS=MyAppKey
RELEASE_KEY_PASSWORD=password
like image 129
Dick Lucas Avatar answered Oct 20 '22 01:10

Dick Lucas