Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Library projects and having to manually refresh

Tags:

android

If I make changes in my Android Library project I have to manually refresh, and sometimes clean all projects that use the Library. Is this normal? Is there a way around this?

like image 369
jax Avatar asked Jun 28 '10 19:06

jax


People also ask

What is .AAR File?

AAR files can contain Android resources and a manifest file, which allows you to bundle in shared resources like layouts and drawables in addition to Java classes and methods. AAR files can contain C/C++ libraries for use by the app module's C/C++ code.

Where should I add library in Android Studio?

Click on Project files. Copy the jar file to the libs folder. Here, you can see our added jar file under the libs folder. Right-click on the jar file and select Add As Library.


1 Answers

I found a workaround for this issue. The basic idea is to use custom ant builder, because it has ability to refresh any specific resource or whole workspace on clean, manual build or auto-build.

So here are the steps:

1) Create a simple ant file with one empty stub target:

<?xml version="1.0" encoding="UTF-8"?>
<project name="android" >
  <target name="refresh" />
</project>

2) Name it "lib-refresher.xml" and place it into folder where application's .project file is located.

3) Now go to eclipse, find the project that uses android library (not library project itself).

4) For this project go to: Project -> Properties -> Builder

5) Create new builder, select Ant task, select specified "lib-refresher.xml", select build base folder.

6) important - Refresh tab of ant builder task select "Specific resources" and select you library dependent project.

7) important - On Target tabs select "refresh" target for build variants: Clean, Manual Build, Auto Build.

8) important - Save changes, move your new custom ant builder to the top of builders stack.

Now the whole project is going to refresh just before building and lunching application. This will include all changes made to library project into application project. Which is what was needed.

(This can be done the other way around: library project may refresh whole workspace whenever autobuild is launched. This may be a bit overkill, but may solve some harder cases).

like image 118
inazaruk Avatar answered Nov 03 '22 07:11

inazaruk