Maven with Android - R.java file generation (Eclipse)

ぐ巨炮叔叔 提交于 2019-12-02 22:00:49

The recommended way is to use the Maven Integration for Android Development Tools and the Maven Android Plugin provides instructions. From the Eclipse Integration page:

Introduction

Android's official development effort provides solid support for Eclipse integration, and we'd like to make sure maven-android-plugin helps bridge Maven, Android, and Eclipse. This page will help us collect information on what works and doesn't work

The solution

To make maven-android-plugin work well in Eclipse with ADT, this is what you need:

  1. Go to the M2Eclipse Android Integration project page and install the tools listed under Requirements.
  2. Of course, set up update-site url and install the M2Eclipse Android Integration plugin in Eclipse. * Get version 0.2.2 or later. It should be under the category 'Maven Integration for Android Development Tools'.
  3. In Eclipse, to bring in your Maven Android projects, choose File -> Import... -> Maven -> Existing Maven Projects.

So jump to the M2Eclipse Android Integration project page and then to the Getting Started guide for very detailed instructions.

With the right tooling, the directory of the generated code should be added automatically as source directory under Eclipse.

Ronald

I had the same problem and just found the solution.

Reason was that I started with a new workspace in which I imported my mavenized android projects. Since it was a new workspace, it didn't contain the SDK location in the preferences.

Once that was setup, all was well.

Also remember that you must have the following code in your eclipse .project file:

<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
    <arguments>
    </arguments>
</buildCommand>
<buildCommand>
    <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
    <arguments>
    </arguments>
</buildCommand>

Other option is disable maven dependency, and add external library in your android project

  • commons-httpclient-3.1.jar
  • spring-android-rest-template-1.0.0.M2.jar
  • jackson-core-asl-1.7.2.jar
  • jackson-mapper-asl-1.7.2.jar

and remove pom.xml,then build project, and run as > Android Application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!