My project structure looks like this:
-project
--settings.gradle
--build.gradle
--src
--libA
---src
---build.gradle
--libB
---src
---build.gradle
--libC
----build.gradle
Main build.gradle has this dependencies:
dependencies {
compile project('libA')
compile project('libB')
compile project('libC')
}
LibA LibB and LibC are library project.
The problem: LibraryC depends on LibraryA and Library B. When I compile I get errors that Library C cannot find symbols of Library A or B.
When I try to add this to build.gradle of LibC
compile project('libA')
I get an error that the path is not found. I did not find a way to specify a path if both project are on the same sub hierarchy.
libC/build.gradle needs to have:
dependencies {
compile project(":libA")
compile project(":libB")
}
":libA" is an absolute project path. The leading ":" denotes the root project.
In most cases, the root project doesn't have any source code, and doesn't declare any dependencies.
Related
i have created an android library AAR in android studio 2.1.3 in which i use the following dependencies:
compile 'com.google.android.gms:play-services-vision:9.4.0+'
compile 'com.google.android.gms:play-services-wearable:9.4.0+'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.3'
now i am using this aar in an application but those dependencies were failing unless i add them to the dependencies of the new app.
i search here and i found that i need to add the following line:
compile (project(':LIBNAME-release')) {transitive = true}
but this didn't work. is there something i missed? or is it related to the obfuscation i did to the aar file? or is it a must to add these dependencies to the app?
Try to compile you project first:
dependencies {
compile project(':Name-Of-Your-Project')
}
This is Ashton Engberg's suggestion from that post
Currently, my Android app project compiles against a local library project like so:
// build.gradle
dependencies {
compile project(':Library-Project')
compile files('libs/library.jar') // Resolve into this if Library-Project is not available
}
The local library project builds into library.jar and is placed in the libs folder.
Is there a way to fallback on the library.jar artifact if the local project is not present without commenting compile project(':Library-Project') in lieu of compiling against the jar?
Used a more dynamic approach for which dependency should actually get compiled.
dependencies {
// Check if the local project exists, and compile against that if it does
if ( new File("/Library-Project").exists() )
{
compile project(':Library-Project')
}
// Local project DNE, compile against JAR file
else
{
compile files('libs/library.jar')
}
}
Another way to automatically compile all JAR files in the /libs folder is by adding the following line within your dependencies block:
compile fileTree(include: ['*.jar'], dir: 'libs')
I downloaded this library to use in my app, however, I can't get Android Studio to do the gradle build now. Anytime I try, I get "error:configuration with name 'default' not found". I've tried several other StackOverflow answers, but I still can't compile.
My dependencies (from build.gradle Module: app)
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:support-v4:22.1.1'
compile project(":aFileDialog")
}
My settings.gradle:
include ':app'
include ':aFileDialog'
I have the library file in the root under "aFileDialog"
How can I get this to build with the library?
You have add path to your aFileDialog library in your settings.gradle
Make sure that folder you point to includes build.gradle file
include ':app'
include ':aFileDialog'
project(':aFileDialog').projectDir = new File(settingsDir, 'aFileDialog')
or (judging from the library folder structure on GitHub)
project(':aFileDialog').projectDir = new File(settingsDir, 'aFileDialog/library')
I found a tutorial that worked: http://www.theappguruz.com/tutorial/library-project-module-as-dependency-in-android-studio/
In addition to the instructions given, I had to add the following line to my Manifest:
tools:replace = "icon, label"
I carefully followed the steps that were listed here:
http://overlap2d.com/making-physics-based-side-scroller-project-setup-part-1/
include 'desktop', 'core', 'Overlap2dRuntime'
project(':Overlap2dRuntime').projectDir = new File(settingsDir, '../overlap2d-runtime-libgdx-master')
and this:
project(":core") {
apply plugin: "java"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "com.badlogicgames.box2dlights:box2dlights:1.2"
compile project(":Overlap2dRuntime")
}
}
After syncing gradle, I got BUILD SUCCESSFUL.
My folder: overlap2d-runtime-libgdx-master is located in the same parent directory as my folder for my project.
However, when I try to access Overlap2DStage, Android Studio tells me that it cannot find the symbol Overlap2DStage! I can't import any of the classes that I've set the dependency for!
Okay, the key to this issue is removing the other Settings.gradle file in the library!
Check out this link: https://code.google.com/p/android/issues/detail?id=65915
I'm new in the world Gradle.
I created the form "MyApp" and the module "Library".
Inside the module "Library" I have a. Jar inside the Libs folder and inside I build.gradle:
dependencies {
compile FileTree (dir: 'libs', includes: ['*. jar'])
}
But the. Jar goes into error during compilation:
Error: (108, 9) error: can not find symbol class JAXBContext.
What is wrong?
thanks