不会生成R.java(android maven插件)
我尝试了不同的目标<代码>mvn包导致不会生成R.java(android maven插件),android,maven,Android,Maven,我尝试了不同的目标mvn包导致包R不存在,mvn android:generate sources导致构建成功,但不会创建R.java 我想将我的类打包到一个jar容器(不是apk)中,因为我想在其他项目中将它用作库 AndroidManifest.xml:(最小设置,因为没有活动) pom.xml: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-
包R不存在
,mvn android:generate sources
导致构建成功
,但不会创建R.java
我想将我的类打包到一个jar容器(不是apk)中,因为我想在其他项目中将它用作库
AndroidManifest.xml:(最小设置,因为没有活动)
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>
4.0.0
com.example
迈里布
0.0.1-快照
UTF-8
com.google.android
安卓
2.2.1
假如
org.apache.maven.plugins
maven编译器插件
2.5.1
1.6
1.6
com.jayway.maven.plugins.android.generation2
安卓maven插件
3.4.0
真的
唯一的资源是
/res/layout/example.xml
android maven插件无法从android库项目生成功能齐全的jar(包含所有编译的类文件、资源、清单等)
AndroidMaven插件给出的解决方案是,它只是库项目的一个zip(具有相同的目录结构,包含原始java文件、资源、清单等)。我已经解释了更多关于apklib如何工作的内容,对于一些示例项目,请查看
安卓maven插件所能做的最远的事情是一个jar,它只包含编译过的类文件,没有资源,默认的apklib构建生命周期涵盖了这一点,并与.apklib文件一起生成
android.library=true
target=android-8
<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>