0

I am trying to make use of Android Studio, currently using Eclipse.

I have exported my Library project for gradle, and then imported my exported project into Android Studio. This is successful, however I then can't find how I can go to my main applications project and reference the newly imported library. Everything I've found looking though Android Studio, always seems to be for creating a new library project, not referencing an existing project.

I am using Android Studio 0.4.0.

Thanks for any help you can provide.

UPDATE

I've looked at what @Grennis said, but I do not have a library section under the Project Structure Dialogue. Below is a screenshot of my project structure dialogue.

Project Structure Dialogue

UPDATE 2

I've been trying to modify the gradle files manually, I've read that the library needs to be copied to my project and then reference it within the gradle files. I think this may be sort of working as I kept on getting errors stating that it couldn't find the library, however, I am no longer getting that error and I'm getting a different one instead.

The error is:

A problem occurred configuring project ':MysqlManager'.

Configuration with name 'default' not found.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Below is my settings.gradle

include ':MysqlManager'
include ':Libraries:CritiMon'

Below is my build.gradle file

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

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 19
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:+'
    compile project(':Libraries:CritiMon')
//    compile project(':Libraries:NavigationDrawerManager')
//    compile project(':Libraries:BoardiesITSolutionsLib')
}

Below is a screenshot showing my directory structure

Project structure

Boardy
  • 35,417
  • 104
  • 256
  • 447
  • 1
    possible duplicate of [How to import eclipse library project from github to android studio project?](http://stackoverflow.com/questions/20310164/how-to-import-eclipse-library-project-from-github-to-android-studio-project) – Scott Barta Dec 29 '13 at 03:14

2 Answers2

0

Select your project and then in the menu select File -> Project Structure

In the "Libraries" section you can add existing libraries

Then in the "Modules" section, under the "Dependencies" tab, you can add those libraries to the project.

Greg Ennis
  • 14,917
  • 2
  • 69
  • 74
  • thanks I've looked at what you suggested but I am not sure where I should be going to. I have updated my question with a screenshot of the project structure dialogue – Boardy Dec 29 '13 at 00:54
  • Looks like you only have 1 module there. I assumed you had an application module and a library module? With only one module I'm not sure what you are trying to do. In any case you would select the "Dependencies" tab, the last tab on the right in your screenshot. – Greg Ennis Dec 29 '13 at 00:58
  • The module that is shown is the main application project. When I go to dependencies there is nothing shown when I add a module dependency. I guess because I first need to add the module but this is where I am struggling to find how I add the module to my project from the existing code – Boardy Dec 29 '13 at 01:00
  • You can click the "+" button above your one module to add or import another module. – Greg Ennis Dec 29 '13 at 01:15
  • When I click the + button all I get is a ``New Module`` dialogue which seems to be just for creating new modules, not importing existing code – Boardy Dec 29 '13 at 01:23
  • Not sure what to tell you, looks like you got into a bad state somehow. – Greg Ennis Dec 29 '13 at 01:24
  • @grennis, your instructions don't work for Gradle-based projects, which is the case here. – Scott Barta Dec 29 '13 at 03:08
  • @ScottBarta I have updated my question with some more info that I have tried – Boardy Dec 29 '13 at 14:33
  • I updated my answer with links to identical questions on StackOverflow. – Scott Barta Dec 29 '13 at 16:18