R.java will not be generated (android-maven-plugin)

I tried different goals. mvn package result package R does not exist , mvn android:generate-sources leads to BUILD SUCCESS but R.java will R.java .

I would like to pack my classes in a jar container (not apk), because I would like to use it as a library in other projects.

AndroidManifest.xml: (minimal setup because there is no action)

 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example"> <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8" /> </manifest> 

default.properties:

 android.library=true target=android-8 

pom.xml:

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>mylib</artifactId> <version>0.0.1-SNAPSHOT</version> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>com.google.android</groupId> <artifactId>android</artifactId> <version>2.2.1</version> <scope>provided</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.5.1</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <groupId>com.jayway.maven.plugins.android.generation2</groupId> <artifactId>android-maven-plugin</artifactId> <version>3.4.0</version> <extensions>true</extensions> </plugin> </plugins> </build> </project> 

The only resource is ./res/layout/example.xml .

+3
android maven
source share
1 answer

android-maven-plugin is not able to generate a fully functional jar (contains the entire compiled class file, resources, manifest, etc.) from the Android library project.

The solution given by android-maven-plugin, apklib , which is simply a zip library project (has the same directory structure contains a raw java file, resource, manifest, etc.). I explained a bit more about how apklib works in this answer , for some sample projects, Maven-android-plugin-samples / libraryprojects .

The farthest Android-maven plugin is a jar that contains only a compiled class file, no resource covered by the standard packaging <packaging & apklib <packaging> build a life cycle and generate it with the .apklib file.

0
source share

All Articles