R.java将不会生成(Android的Maven的插件) [英] R.java will not be generated (android-maven-plugin)
问题描述
我试过不同的目标。 MVN包
的结果包R不存在
, MVN安卓产生来源
的结果使成功
,但没有 R.java
将被创建。
I tried different goals. mvn package
results in package R does not exist
, mvn android:generate-sources
results in BUILD SUCCESS
but no R.java
will be created.
我想我的班打包成一个jar容器(不APK),因为我想用它作为其他项目库。
I would like to pack my classes into a jar container (not apk) because I would like to use it as a library in other projects.
AndroidManifest.xml中:(最小的设置,因为没有活动)
AndroidManifest.xml: (minimal setup, because there are no Activities)
<?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:
default.properties:
android.library=true
target=android-8
pom.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>
的唯一资源是 ./ RES /布局/的example.xml
。
推荐答案
Android的Maven的插件有没有能力生成一个全功能的罐子(包含所有编译的类文件,资源清单等)来自Android的库项目。
android-maven-plugin has no capability to generate a fully functional jar (contains all compiled class file, resources, manifest and etc) from Android library project.
由Android的Maven的插件给出的解决方案是 apklib ,这简直就是图书馆项目的zip(具有相同的目录结构包含原始的Java文件,资源清单等)。我已经解释过一点关于如何apklib作品<一href=\"http://stackoverflow.com/questions/8823392/android-maven-plugin-apklib-mojo-doesnt-include-compiled-r-in-resulting-apklib/8826739#8826739\">in这个答案,对于一些样本项目,请行家-Android-插件样本/ libraryprojects 。
The solution given by android-maven-plugin is apklib, which is simply a zip of the library project (has same directory structure contains raw java file, resource, manifest and etc). I have explained a bit more about how apklib works in this answer, for some sample projects, check out maven-android-plugin-samples/libraryprojects.
最远的Android的Maven的插件可以是一个jar只包含编译的类文件,没有资源,这是由默认&LT覆盖;包装&GT; apklib&LT;包装和GT;构建生命周期,并与.apklib文件一起生成的。
The furthest android-maven-plugin can go is a jar that contains only compiled class file, no resource, this is covered by the default <packaging>apklib<packaging> build life cycle and generated along with the .apklib file.
这篇关于R.java将不会生成(Android的Maven的插件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!