Gradle Absolute / Relative Path
Solution 1:
Try this, it would include all JARs in the local repository, so you wouldn't have to specify it every time:
dependencies {
compilefileTree(dir: 'libs', include: ['*.jar'])
}
Also, you should know that when referencing a file via
files("relative/path/to/a.jar")
path is evaluated relative to the buildscript this snippet is in. So when your build.gradle
file is located in /a/project/build.gradle
, then the jar should be in /a/project/relative/path/to/a.jar
.
In a multiproject gradle build you can put the the jar in a folder relative to the root - project and reference it in all subprojects via
rootProject.files("relative/to/root/a.jar")
So take this to account and re-check if your gradle settings are correct.
Solution 2:
If you call URL scheme path, you can use this example:
def path = "file://${projectDir}/ojdbc6.jar"
Solution 3:
Old question, but might help someone. I had the same problem, I had 2 libraries in the project root folder, and it didn't work with relative path. Add ../ before the relative path if your library is in your project's root folder.
implementation fileTree(dir: 'libs', include: ['*.jar'])
...
implementation files('../library_name/libs/some.jar')
Solution 4:
First off in my opinion adding manual libs - if can be avoided - is bad practice because you need to maintain the lib and path yourself.
I had a quick look at the maven repo and it seems they don't have this specific lib there. This is what I'd expect:
compile('com.anypackage.name.PushLinkAndroid-5.3.0.jar')
Since this is probably not up to you than rather to the developer team of https://www.pushlink.com/changelog.xhtml it can't be helped.
Now to your problem: Did you start your build with --stacktrace?
From what I can gather from this
compile files('C:/Users/Kai/AndroidStudioProjects/ProjectA/libs/PushLinkAndroid-5.3.0.jar')
you're using a Windows system. This is troublesome at some points because Gradle expect the paths to look like this:
C:/Users/Kai/AndroidStudioProjects/ProjectA/libs/PushLinkAndroid-5.3.0.jar
My wild guess here is that gradle does something like this when you don't specify the path yourself:
C:\Users\Kai\AndroidStudioProjects\ProjectA\libs/PushLinkAndroid-5.3.0.jar
You can verify the behaviour with this gradle task:
task printBuildDir() {
defbuildDir="${buildDir}"
println buildDir
deffixedDir= buildDir.replaceAll('\\\\', '/')
println fixedDir
}
If my guess is correct, you got a couple of choices:
- Use the full path
- Use a gradle builtin path such as buildDir and replace the \ accordingly to the example (I'm not sure whether this works exactly like my example in dependencies tag, maybe you need to define a global variable yourself)
- Get the developers of PushLink to put this lib up to Maven Repo
Solution 5:
Your libs folder is misplaced. You have to put it under MigraeneBook/app
, not directly under MigraeneBook
.
Post a Comment for "Gradle Absolute / Relative Path"