can't find build.gradle in Eclipse projects - java

I want to add library to my android project in eclipse but I can't find build.gradle
I tried to install Gradle plugin in eclipse and create new Gradle project but the project is for java not for android
So, how can I create new android project with gradle in eclipse like android studio?
And how to add libraries to my project?

Install gradle on your computer and then open the console.
Go to your project's directory and run the task "gradle init". This will add the files that gradle needs.
To add libraries to you project, add them to the "build.gradle" file and then run "gradle build" task to download them.
PS: as referred in the comments, Eclipse isn't the advisable tool to build an Android project, you should go with Android Studio

Related

How to add an existing java project as a module to an existing Android Studio project

I have two github repositories - one an Android Studio project and another a intellij Idea Java project. Right now i build jar from my java project and use that jar in Android Studio project.
Is there a way I can add my existing java project as a sub-module in my existing Android Studio project so that I do not have to go through the hassle of creating a new jar every time I modify the java project?

Android Studio: How do I find where Gradle has been installed?

I have installed Android Studio but would like to use Gradle to build a simple "hello world" Java application that I have created outside of AS.
I have added the java plugin to my build.gradle file and ran `"gradle build" to try and build the .java file.
However, I am getting the error: "Gradle is not recognised as an internal or external command"
Do I need to install a separate version of Gradle, not bundled with AS to be able to build a java project?
Do I need to install a separate version of Gradle, not bundled with AS to be able to build a java project?
More or less.
There are two ways of using Gradle:
Download and install it, like you would most other development tools
Have a project set up for the Gradle Wrapper (gradlew and gradlew.bat files in the project root, plus the gradle/ directory containing the Wrapper JAR and properties file)
That latter approach will download a private copy of Gradle for this particular project, into the project's .gradle/ directory. This way, different projects can use different versions of Gradle without conflict.
Android Studio takes the latter approach; you can see the files that I mentioned in a newly-created Android Studio project, for example. For your own Java project, I'd do whatever is natural for your IDE that you plan on using for that project.

how to create a jar file from android studio

I have a fairly latest version of android studio, I have created a module under a project which is basically supposed to be a library, when I build it, it creates an ".aar" file , what I want is .jar file as this library is supposed to be used with eclipse as well.
The library contains activity as well, is there any way by which I can create a .jar file which I can use on Eclipse as well Android Studio ?
I have already created this module and tried building , as a result it generated .aar file and not a .jar file.
I found a way to achieve this, plain simple, using Gradle 2.2.1:
task jar(type: Jar, dependsOn: 'assembleRelease') {
from fileTree(dir: 'build/intermediates/classes/release')
}
Place this in your library module.
It will compile it as release and produce a JAR file in: build/libs.
bash gradlew jar or use your IDE to target that jar Gradle task.
aar is not related to AS or eclipse but is an AndroidARchive for Android applications like JavaARchives are for java applications.
Because Android is java based, jars can be used. But to take android specialities into account, like resource bundles, an aar is the right thing to use.
Currently gradle based builds doesnt seems to be allowing to create jar with android studio, I decided to go for Intelij it has necessary option and does what i want , i can use community edition.
***Update****
Even the jar produced by Intelij with resources don't work , obviously its not easy to have a jar with resource , so decided to opt for .aar and hoping that Eclipse also gets support for .aar when gradle supports lands there, as that was my main concern.
Add this in your library's gradle file:
task deleteJar(type: Delete) {
delete 'libs/traylib.jar'
}
task createJar(type: Copy) {
from('build/intermediates/packaged-classes/release/')
into('libs/')
include('classes.jar')
rename('classes.jar', 'traylib.jar')
}
createJar.dependsOn(deleteJar, build)
You need to check path of your generated classes.jar: build/intermediates/packaged-classes/release/
Create lib folder in your lib's root folder if it is not there
Go to gradle build: Android Studio --> View --> Toll Windows --> Gradle
Select your module(:library) --> Tasks --> other --> Double click on createJar task
You can just simply unzip the aar file to get the separated pieces of files.

Add android library project to Android project in Android Studio

I have Android project (main) that has a dependency on Android-library (library) project. I have that in Eclipse where I added library project, but now I want to use Android Studio where I cant find similar option. Is it possible to do it by Gradle where I build library project and main project take that from local repository or I need Maven to do so and if I can then how?
Import your Eclipse library-project (e.g. Facebook library-project), then in your project's settings.gradle refer to Facebook project's module local path in this way:
include ':facebook'
project(':facebook').projectDir = new File(settingsDir, '../facebook/app')

build jar from loopj android-async-http source

I'm trying to build a jar from the https://github.com/loopj/android-async-http source code but have been unsuccessful.
I also tried including the source as a library in my android project in android studio but was unable to.
I want to build from source because the jar's available in maven and in the github repo are too old and I want to use and test some of the new features available in the source.
How can I either build the jar and include the jar in my android studio project or simply properly include the source in my android studio project?
I was able to build the jar myself in ubuntu:
cd android-async-http/library
gradle build
That generated a build directory that contained a jar of the library.
Do you just need a Jar or you want to build the jar yourself. If you are just looking for the jar, they are already compiled and ready to download on this link here.
Looks like github download is not working. Use this link to download the latest android-async-http jar

Categories