0

How would I reference gradle dependencies that are stored in a folder above the build.gradle file?

There must be some syntax for this correct? all the references I see look like

compile ':libs:thirdparty'

but this isn't really what I'm going for

so now I've tried this in my settings.gradle file

include ':app', ':android-volley'

project(':android-volley').projectDir=new File('../../shared-components/android-volley')

where I am trying to link my android-volley project, it is heavily modified so using the maven link will be no good for me, and I want to use these files between this project and other projects I work on

this does not allow my project to "sync" properly any more, and the import statements for volley do not work because it cannot find the dependencies

here is the .iml file Android Studio / IntelliJ creates

<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="whosay" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
 <component name="FacetManager">
  <facet type="android-gradle" name="Android-Gradle">
  <configuration>
    <option name="GRADLE_PROJECT_PATH" value=":android-volley" />
  </configuration>
</facet>
<facet type="java-gradle" name="Java-Gradle">
  <configuration>
    <option name="BUILD_FOLDER_PATH" />
  </configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
  <excludeFolder url="file://$MODULE_DIR$/.gradle" />
  <excludeFolder url="file://$MODULE_DIR$/build" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

what is wrong?

CQM
  • 42,592
  • 75
  • 224
  • 366
  • you'd typically use a settings.gradle file that includes all your projects, and refer to the library directly in the build.gradle file in your main project. (`compile project(':mylibrary')`) – njzk2 Jul 22 '14 at 21:22
  • 2
    Does this help you? http://stackoverflow.com/questions/24658422/android-studio-0-8-1-creating-modules-without-copying-files/24659324#24659324 – Scott Barta Jul 22 '14 at 21:31
  • Are you saying that you want to get some jars from a `lib` directory onto your compile class path? – Peter Niederwieser Jul 22 '14 at 22:17
  • @ScottBarta seems like the right track, but I am still having issues – CQM Jul 29 '14 at 22:18
  • Does it build from the command line? – Scott Barta Jul 29 '14 at 22:31

2 Answers2

0

Open your settings.gradle file and you should see include:app. The "app" part is your main module for your app but say you want to add a gradle library: you would add the lib folder to the same location where the "app" module is stored, then go to settings.gradle and below the include:app, type include:<your lib name here>. Then sync gradle files and you should be good to go. Make sure that the app module and your lib module is using the same android version and sdk version.

Andrew Quebe
  • 2,263
  • 5
  • 25
  • 53
  • I don't like this because I purposefully put my commonly used (and modified) libraries in an external folder so my other apps could use them without copying them, so short of putting it all on Maven or making a git submodule, this seems like a poor solution, is this the only solution? – CQM Jul 22 '14 at 21:28
  • To my knowledge, yes. I find it to be really easy to set up this way. – Andrew Quebe Jul 22 '14 at 21:29
0

Probably you forgot to add dependencies in app build.grade file:

Something like this:

dependencies {
     compile project(path: ':android-volley')
}
phingage
  • 117
  • 1
  • 8