Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use already developed android project [with its resources(xml, images, layout)] into another project directly as .xyz file

I have read lots of questions on this site and come to the decision that if you wish to use your already developed code with its resources in android then you have to use it as a library.

But from the Building Android applications with Gradle tutorial I read something like...

Gradle supports a format called Android ARchive (AAR) . An AAR is similar to a JAR file, but it can contain resources as well as compiled bytecode. This allows that an AAR file is included similar to a JAR file**.

Does it means that we can use .aar file as an .jar file but with facility of using resources also?

Then I have tried to crate .aar file with the help of Android Studio, but .aar file doesn't contain layout XMLs or images -- it contains some layout and resources but it doesn't contain projects other resources file.

At last I am having the only same, annoying, stupid question: Can we use whole project with its resources with only one file like .jar or .aar or any other file format?

like image 760
Bhavana Vadodariya Avatar asked Nov 20 '13 12:11

Bhavana Vadodariya


2 Answers

RajaReddy is quite mistaken. The JAR contains only code; you cannot access resources that way.

Google distributes their own "Google Play Services Library" as an Android library project, containing the binary code in a JAR file in the lib directory, the resources in the res directory, and an UnusedStub class in the src directory. If a better approach were viable yet I think they'd be using it.

UPDATE: While Android Studio is still in beta, it includes (buggy) support for AAR files. Seems this will eventually be the way to go.

like image 104
j__m Avatar answered Oct 17 '22 23:10

j__m


Library projects bin folder contains jar file, copy that jar file in your main Application ( project ) libs folder we can get all the resource folders like this.

Follow these steps !

1) make your library project a normal project by deselecting IsLibrary flag.

2) Execute your project as Android Application. (It will not show any error)

3) you'll find a .jar file in bin folder..

4) Copy .jar in libs folder of your main application.

this will works fine with all the resources.

like image 2
RajaReddy PolamReddy Avatar answered Oct 18 '22 01:10

RajaReddy PolamReddy