1

I want to add this project as library to my project in android studio. this is what I tried,

I have my project directory as f:/my project/my app/src and my library in f:/my project/my library/src

I import the module (the library) by going to file > import module > selecting the library then I got to file > project structure > modules > dependencies tab > select my project > add module dependency apply ok and then done

however when I use the code from the library I get the usual syntax error (the class ... could not be found)

also I noticed this popup (see image)

enter image description here

I am new to android studio or intelliJ, how do I fix this. Thanks!

6
  • If you are a novice, I recommend to use eclipse and adt. Android studio is not stable yet and you will get many problems with it. Commented Jun 7, 2013 at 11:50
  • I have used eclipse for a month now, but I want to try android studio Commented Jun 7, 2013 at 11:51
  • 1
    I used eclipse, I used IntelliJ idea, it is simple to work with both, but android studio - I had many problems and I decided to wait for stable release. Commented Jun 7, 2013 at 11:54
  • 1
    I suppose a simple task like adding a project as library is not much of a big deal and android studio should be stable at doing that Commented Jun 8, 2013 at 6:16
  • also is the process I mentioned above correct Commented Jun 8, 2013 at 6:17

1 Answer 1

1

Edit the settings.gradle file (in directory f:/my project), it must contains something like this:

include 'my app','my library'

If this file don't exists: create it manually. The settings.gradle contains the list of gradle modules in a multi-module project.

Then you must add the dependency to your library in app. To do so edit the my app/build.gradle and add this line :

dependencies {
    compile project(':my library')
}

I also notice that you don't use default structure for your projects (i.e. you put the code in src/ instead of src/main/java) so you will have to overwrite some values of the default fileSet in the build.gradle of your projects. Be sure to have something like this in my app/build.gradle and my library/build.gradle :

android {
    sourceSets {
        main {
            java.srcDirs = ['src']
        }
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.