0

I am using Gradle for Android with Eclipse (NOT Android Studio and please do not suggest to change the IDE).

My project.properties file got this line:

android.library.reference.1=..\\google-play-services_lib

I tried adding this line to build.gradle:

compile project('..\\google-play-services_lib')

When building the project I get this error:

Project with path '..\google-play-services_lib' could not be found in root project 'myProject'.

  1. What am I doing wrong?

  2. How do I define in the build.gradle the jars I've added to the build path?

Gray
  • 108,756
  • 21
  • 270
  • 333
Yonatan Nir
  • 8,303
  • 23
  • 80
  • 156
  • If your intention is to add jars from local files, this might help you: http://stackoverflow.com/questions/20700053/how-to-add-local-jar-file-dependency-to-build-gradle-file. Otherwise, maybe clarify more what you're trying to achieve. – frhd Nov 06 '16 at 16:04
  • I want to add all dependencies which are normally set in Eclipse in the Java Build Path section to Gradle and hopefully stop using the build path and use only Gradle. Also do you know the answer for my first question? – Yonatan Nir Nov 06 '16 at 16:05
  • Do you add them manually in eclipse? As local jars? – frhd Nov 06 '16 at 16:08
  • Regarding 1): The path couldnt be found, obviously. Without telling us where your lib is located, it's hard to tell how to fix it, but it seems that the double ´\\´ would be wrong in any case. You're going up from your root path and then trying to access ´\google-play-services_lib´, which fails. – frhd Nov 06 '16 at 16:12
  • If adding them manually means I've pressed the "Add" button and chose them then yes. Some of them are taken from the libs directory of other projects and some are taken from the extras folder of the sdk – Yonatan Nir Nov 06 '16 at 16:12
  • but that's where the project is located. its in the workspace at the same level as the main project and its being added to the main project as a library project – Yonatan Nir Nov 06 '16 at 16:13
  • Try the docs here (it's really basic stuff at this point): http://www.gubatron.com/blog/2014/07/29/gradle-how-to-add-a-list-of-local-jars-to-the-build-classpath/, and dont forget to include the `eclipse` plugin.. – frhd Nov 06 '16 at 16:17

1 Answers1

2

If you want to compile sources of your library :

1) Put your project library in your root project

Tree is like the following :

RootProject
  +- build.gradle
  +- settings.gradle
  +- Lib1/
      +- build.gradle
      +- ...
  +- Project/
      +- build.gradle
      +- ...

2) Edit your settings.gradle

include ':Lib1'
include ':Project'

3) Add dependency in your Project's build.gradle file

dependencies {
    [...]
    compile project(':Lib1')
}

If you want to add jars :

1) Create a libs folder in your Project's dir

2) Add this dir as reprositories in your gradle file

repositories { 
    flatDir {
        dirs 'libs' 
    } 
}

3) Put your jar in this dir and add dependencies in your Project's build.gradle

dependencies {
    compile(name:'mylib',ext:'jar')
}
Bipi
  • 2,924
  • 1
  • 16
  • 20