how to include lvl-license project with android gradle project - android

I have an android gradle project it's now not compiling because it's looking for license classes so i tried to include them as following in my build.gradle:
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
**compile project(':lvl-licensing').projectDir = new File(projectDir, '../lvl-licensing/library'**)
}
problem is that for some reason i still get this:
A problem occurred evaluating project ':myproject'.
> Project with path ':lvl-licensing' could not be found in project ':myproject'.
how can i include the lvl-license/library project in my project using gradle? why is it complaining? I do have the project in that folder with build.gradle and I can compile that lvl-license/library project separately.
thanks

You have to add the lvl-licensing file to your settings.gradle file as well. Also, that library can't be outside the root directory of your project; it looks like you're trying to place the library in a sibling directory to your project.
If you put the library under your project root, you don't need to do the gymnastics with the path in your compile project statement.

Related

Which third-party dependencies are declared in the build.gradle of this Android Studio project?

I want to convert this Android Studio project into an Eclipse project.
The way to do it is to copy everything in all src packages and res directory from AS project to Eclipse project, and change the Eclipse project's Manifest file by adding all the additional elements from AS project.
The catch is that I have to do this for all the third party dependencies (declared in build.gradle) on which the AS project depends and then add those library projects to this newly created Eclipse project.
Normally I would do it for each library listed in the dependencies section of build.gradle file of AS project. But for this library project, I don't understand what are the dependencies:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
}
I don't understand the first and third line. Please tell me which libraries are declared in first and third line, so that I can copy those projects in Eclipse?
EDIT:
Here is the output of gradlew.bat -q dependencies command:
EDIT 1:
EDIT 2:
For each project module, do the following from the command line:
./gradlew -q dependencies
This will print out a graph of all dependencies the module has.

Configuration with name 'default' not found error on Android Studio

I am trying to test to reference without copying a library Project. So I created two projects one is ProjectA and one is LibraryA. Both projects are located inside the \StudioProjects folder. I am trying to reference LibraryA from ProjectA and I get the error at the title.
Here is settings.gradle from ProjectA
include ':app'
include ':LibraryA'
project(':LibraryA').projectDir = new File('../LibraryA')
Here is dependincies from app build.gradle of ProjectA
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile project(':LibraryA')
}
I am using Android Studio 1.5.1
If I remove compile project(':LibraryA') from dependencies it builds normally, however then I can't referance classes from LibraryA inside ProjectA.
In your settings.gradle (ProjectA) you are referring the wrong folder.
include ':LibraryA'
project(':LibraryA').projectDir = new File('../LibraryA')
Checking your image, the LibraryA folder is a root folder.
Gradle is searching for a "module" build.gradle while in this folder there is a top-level file configuration.
You have to refer to the module inside the LibraryA
project(':LibraryA').projectDir = new File('../LibraryA/app')
Of course you have to pay attention if some tasks or variable are defined in the top-level file (LibraryA). In this case you have to clone them inside your top-level file (ProjectA)
One of your projects does not have a valid gradle file. If your library is not a gradle project convert it to gradle project.
If you add your library as a module and select "gradle" when you are importing i think you'll solve your problem.
I just do not understand what you want to do. But try changing the following line:
project(':LibraryA').projectDir = new File('../ProjectA')

Add Caldroid library in Android Studio

I have a problem when adding Caldroid library on Android Studio. I try many different ways to add but it won't work. I use Android Studio 0.8.2.
First off, I created a root folder called libraries.
I created a new folder caldroid in /libraries.
Then, I pasted the downloaded files in /libraries folder.
Then, I changed the following files.
settings.gradle
include ':app'
include 'libraries:caldroid:library'
build.gradle
dependencies {
compile 'com.android.support:appcompat-v7:20.+'
compile 'com.google.android.gms:play-services:4.0.30'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':libraries:caldroid:library')
}
But I get this error:
Error:Configuration with name 'default' not found.
How to fix this?
I'm late but I faced a similar issue so I thought I'll share how I solved it.
To import an external library to Android Studio, I follow this convention:
Create libs folder inside the app directory. Then copy the required library files to the libs folder. For example, my folder contains actionbarsherlock and caldroid folders.
Caldroid has a library dependency that can be downloaded here, you can see this in the build.gradle file (Also, make sure the gradle files have the correct SDK versions). Download the hirondelle-date4j-1.5.1-sources.jar.
Create libs folder in app/libs/caldroid/. Copy the hirondelle-date4j-1.5.1-sources.jar to app/libs/caldroid/libs/. You may also have to copy android-support-v4.jar from -User_Home-/Android/Sdk/extras/android/support/v4/ to app/libs/caldroid/libs/.
Open app/libs/caldroid/build.gradle and replace compile 'com.darwinsys:hirondelle-date4j:1.5.1' with compile files('libs/hirondelle-date4j-1.5.1-sources.jar').
In Android Studio, open settings.gradle and add this line include ':app:libs:caldroid'. Next, open "build.gradle (Module: app)" and add this line compile project(':app:libs:caldroid') in dependencies.
And that's it, now allow the gradle to "sync" or clean and build your project.
Add this line in your dependencies in build.gradle
compile 'com.roomorama:caldroid:3.0.1'

importing ShowcaseView with gradle

I'm trying to use the ShowcaseView project in my app but can't get the project to build.
when I run 'gradle clean installDebug' I get the following error:
A problem occurred evaluating root project 'hows-it-going'.
Could not find method compile() for arguments [project ':ShowcaseView'] on root project 'hows-it-going'.
I'm using gradle 1.11 and Android Studio 0.54.
I've downloaded the source, and imported the project using file -> Import module -> ShowcaseView
which makes my project structure like:
-project
--app
--ShowcaseView
my settings.gradle file looks like:
include ':app', 'ShowcaseView'
and in my project level build.gradle I have the following:
dependencies {
compile project (':ShowcaseView')
}
Any help with how to include this properly would be much appreciated. Thanks.
The latest version of ShowcaseView is available as a .AAR dependency. To use it, add:
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
}
To your build.gradle file and, under the dependencies block, add:
compile 'com.github.amlcurran.showcaseview:library:5.0.0-SNAPSHOT'
I'll get a stable, non-snapshot, version out soon.
It should actually be
compile 'com.github.amlcurran.showcaseview:library:5.0.0-SNAPSHOT#aar'
That way Maven will use .AAR file
I recently just added ShowcaseView to an Android Studio project, and I hope this can push you in the correct direction.
My file structure looks something like this:
project
app
build.gradle
libraries
showcase
build.gradle
settings.gradle
Add the files from the library
folder
of ShowcaseView to the showcase directory in the libraries
directory.
Add the showcase directory as a module to your project.
Change your app's build.gradle file to include:
dependencies {
compile project(':libraries:showcase')
}
Change your settings.gradle to include:
include ':libraries:showcase'
Sync Project with gradle files
This StackOverflow answer goes over how to do this is much more detail if you have any troubles, but this method works for any library.
The compile dependency on ShowcaseView should likely be defined in app/build.gradle, not in the root project's build.gradle. Unless a project explicitly (configurations block) or implicitly (by applying a plugin such as java) defines a compile configuration, it won't have one, and an attempt to add a compile dependency will result in the error you mentioned.
I added this in build.gradle and it worked
compile 'com.github.amlcurran.showcaseview:library:5.4.3'

How to Import jar file into an Android project?

I am trying to use the loopj library in my Android project. In the project home page it says "Download the latest .jar file from github and place it in your Android apps libs folder". I did that!
As indicated in the documentation of the loopj I try to import it using the following
import com.loopj.android.http;
and nothing happens. It is not even coming up in intellisense.
Am I doing anything wrong?
in the build.gradle file add your jar such as below then rebuild.
dependencies {
compile files('libs/android-async-http-1.4.4.jar')
}
into the build.gradle file add the following::
dependencies {
// ... other dependencies
compile files('libs/<your jar's name here>')
}
Rebuid your project or Run ./gradlew assemble. This should compile the project with the library.
To let the Android Studio load all of your jar files by itself automatically, just write this line in the dependency section
compile fileTree(dir: 'libs', include: ['*.jar'])
This will help android studio to load all of your jar files available in libs folder.

Categories

Resources