Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am trying to get working R.java generation to project in gen folder. Actually, the application builds, when using maven build, however eclipse finds error, because it can't resolve R.java file (which actually is being put in /target/generated-sources/r/R.java location after each build). What is the suggested way to solve the problem?

like image 955
LordTwaroog Avatar asked Jul 29 '10 08:07

LordTwaroog


2 Answers

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.

like image 153
Pascal Thivent Avatar answered Nov 18 '22 04:11

Pascal Thivent


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.

like image 33
Ronald Avatar answered Nov 18 '22 04:11

Ronald