Rename classes.jar to <project_name> .jar when creating a library project in android ant

I have an Android application project A, which depends on the project of the Android B library. When I import both projects into Eclipse, I noticed Eclipse Builder (possibly due to the ADT plugin), which compiles the library project and is built as b.jar and saved inside the bin\ folder of project B. It is referenced as b.jar in the classpath A.

But, building it with ant, the ant debug command, the B library project will compile as classes.jar .

Is there a way to rename this file as .jar? I tried to rename it to the build.xml SDK, but then project A does not seem to resolve the classes defined in B. Furthermore, the test project for B does not work, since the Android dex compiler is trying to find the classes.jar file inside in the bin\ folder library project.

Thanks,

+4
source share
4 answers

Create the custom_rules.xml file in the project directory.

 <?xml version="1.0" encoding="UTF-8"?> <project name="custom_rules"> <target name="-post-compile"> <echo level="info">Renaming jar filename</echo> <move file="${out.library.jar.file}"tofile="${out.absolute.dir}/${ant.project.name}.jar"/> </target> </project> 
+4
source

One way to rename the jar file is to add the custom_rules.xml file to the project and override the right property:

 <?xml version="1.0" encoding="UTF-8"?> <project name="custom_rules"> <property name="out.library.jar.file" location="bin/b.jar" /> </project> 

If you are looking for this property name in the build.xml SDK, you will see why this works.

Note. I did not check from which API level custom_rules.xml Android is supported.

+1
source

I added an additional project to the library project: / bin / cp bin / classes.jar bin / $ {project_name} .jar

0
source

The easiest way is to add a line to ant.properties:

 out.library.jar.file=bin/b.jar 

But if project B refers to project A in project-A / ant.properties, for example:

 android.library.reference.1=/path/to/project-B 

then the compiler may complain that it cannot find the characters defined in project B.

0
source

Source: https://habr.com/ru/post/1441154/


All Articles