Compile error in Android-MenuDrawer - android

I'm trying to migrate an application developed in Eclipse to Intellij Idea, the application uses ActionBarSherlock and Android-MenuDrawer (SimonVT)
I am having a problem importing the Android-MenuDrawer library using Maven. With ActionBarSherlock compiles fine and I can use it well in a project, but not with MenuDrawer.
When I try to compile with Maven gives me the following error:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /D:/Android/menudrawer/menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java:[854,40] cannot find symbol
symbol: variable LAYOUT_DIRECTION_RTL
location: class net.simonvt.menudrawer.MenuDrawer
[ERROR] /D:/Android/menudrawer/menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java:[861,40] cannot find symbol
symbol: variable LAYOUT_DIRECTION_RTL
location: class net.simonvt.menudrawer.MenuDrawer
[ERROR] /D:/Android/menudrawer/menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java:[873,14] cannot find symbol
symbol: method onRtlPropertiesChanged(int)
[ERROR] /D:/Android/menudrawer/menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java:[882,80] cannot find symbol
symbol: variable LAYOUT_DIRECTION_RTL
location: class net.simonvt.menudrawer.MenuDrawer
[ERROR] /D:/Android/menudrawer/menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java:[871,5] method does not override or implement a method from a supertype
[ERROR] /D:/Android/menudrawer/menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java:[1325,72] cannot find symbol
symbol: variable LAYOUT_DIRECTION_RTL
location: class net.simonvt.menudrawer.MenuDrawer
[ERROR] /D:/Android/menudrawer/menudrawer/src/net/simonvt/menudrawer/ViewHelper.java:[44,57] cannot find symbol
symbol: variable JELLY_BEAN_MR1
location: class android.os.Build.VERSION_CODES
[ERROR] /D:/Android/menudrawer/menudrawer/src/net/simonvt/menudrawer/ViewHelper.java:[45,21] cannot find symbol
symbol: method getLayoutDirection()
location: variable v of type android.view.View
[ERROR] /D:/Android/menudrawer/menudrawer/src/net/simonvt/menudrawer/ViewHelper.java:[48,20] cannot find symbol
symbol: variable LAYOUT_DIRECTION_LTR
location: class android.view.View

I could find the error .
The problem is the dependence of the android sdk , the actal is 4.1.1.4 (api 16) is the last in the maven repository . But the project needs the api 17+
Follow these steps :
1) Download a version of sdk 17+
2) Download the maven-android-sdk-deployer project, and read the instructions for installation
3) Edit the pom.xml file ( the root ) by changing the property 4.1.1.4 and 16
by any of the following , depending on the SDK :
<android.version>4.2.2_r2</android.version>
<android.platform>17</android.platform>
<android.version>4.3_r2</android.version>
<android.platform>18</android.platform>
<android.version>4.4_r1</android.version>
<android.platform>19</android.platform>
and also edit
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${android.version}</version>
</dependency>
by
<dependency>
<groupId>android</groupId>
<artifactId>android</artifactId>
<version>${android.version}</version>
</dependency>
It is also necessary to update the version of maven plugin 3.6.0 to 3.8.0.
Change this:
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<sdk>
<platform>${android.platform}</platform>
</sdk>
</configuration>
<extensions>true</extensions>
</plugin>
by this:
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<sdk>
<platform>${android.platform}</platform>
</sdk>
</configuration>
<extensions>true</extensions>
</plugin>
4) Edit the pom.xml ( the menudrawer folder)
edit the following :
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
</dependency>
by
<dependency>
<groupId>android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
</dependency>
recharge the maven project and compile

Related

Maven Compilation Error package R does not exists

I am getting package R does not exist on building pom.xml file.
Compilation Error is:
[INFO] Compiling 12 source files to E:\My_Work6\AtosListReq\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] E:\My_Work6\MyListReq\src\com\as\dragsortandswipe\DragSortListView.java:[32,23] error: cannot find symbol
[ERROR] symbol: class R
location: package com.as.listreq
E:\My_Work6\MyListReq\src\com\as\dragsortandswipe\DragSortController.java:[17,23] error: cannot find symbol
[ERROR] symbol: class R
location: package com.as.listreq
E:\My_Work6\MyListReq\src\com\as\dragsortandswipe\DragSortListView.java:[406,6] error: package R does not exist
[ERROR] E:\My_Work6\MyListReq\src\com\as\dragsortandswipe\DragSortListView.java:[409,6] error: package R does not exist
[ERROR] E:\My_Work6\MyListReq\src\com\as\dragsortandswipe\DragSortListView.java:[412,6] error: package R does not exist
[ERROR] E:\My_Work6\MyListReq\src\com\as\dragsortandswipe\DragSortListView.java:[419,29] error: package R does not exist
[ERROR] E:\My_Work6\MyListReq\src\com\as\listreq\NextActivity.java:[41,40] error: package R does not exist
[ERROR] E:\My_Work6\MyListReq\src\com\as\listreq\NextActivity.java:[42,43] error: package R does not exist
.
.
.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project MyListReq: Compilation failure: Compilation failure:
[INFO] 58 errors
Below is my pom.xml file:
<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>MyListReq</groupId>
<artifactId>MyListReq</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>MyList</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>r7</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<fork>true</fork>
<executable>C:\Program Files\Java\jdk1.7.0_03\bin\javac.exe
</executable>
</configuration>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<sdk>
<path>${env.ANDROID_HOME}</path>
<platform>17</platform>
</sdk>
</configuration>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
You have added com.jayway.maven.plugins.android.generation2 plugin,
Adding packaging to apklib, like this:
<version>0.0.1-SNAPSHOT</version>
<packaging>apklib</packaging>
That's ok

unable to compile Maven project after switching to ADT

I've switched from Eclipse Indigo to ADT (version 22.3.0)
I compile a project using Maven through command line:
mvn clean install android:deploy android:run
The project compiled fine on my older system and I haven't changed it at all. Now when I import it to ADT I get the "already added" error during compilation:
...
[INFO] UNEXPECTED TOP-LEVEL EXCEPTION:
[INFO] java.lang.IllegalArgumentException: already added: Lcom/sun/activation/registries/LineTokenizer;
[INFO] at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[INFO] at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
[INFO] at com.android.dx.command.dexer.Main.processClass(Main.java:490)
[INFO] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459)
[INFO] at com.android.dx.command.dexer.Main.access$400(Main.java:67)
[INFO] at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:398)
[INFO] at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
[INFO] at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
[INFO] at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
[INFO] at com.android.dx.command.dexer.Main.processOne(Main.java:422)
[INFO] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333)
[INFO] at com.android.dx.command.dexer.Main.run(Main.java:209)
[INFO] at com.android.dx.command.dexer.Main.main(Main.java:174)
[INFO] at com.android.dx.command.Main.main(Main.java:91)
[INFO] 1 error; aborting
...
I don't have X_src files I saw on other replies to this issue. I don't include any library in my lib folder either.
This happens even with basic POM file so I guess that ADT has changed the project somehow so it includes this LineTokenizer twice (I'm not including it anywhere), is this correct?
Does anyone know how to fix this, or to find where the multiple inclusions happen?
Edit:
the POM:
<?xml version="1.0" encoding="UTF-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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my.package</groupId>
<artifactId>android-client</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>Name</name>
<dependencies>
<dependency>
<groupId>com.google.android.services</groupId>
<artifactId>google-play-services</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>com.google.android.support</groupId>
<artifactId>android-support-v4</artifactId>
<version>4</version>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android.analytics</groupId>
<artifactId>analytics</artifactId>
<version>3</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>oauth.signpost</groupId>
<artifactId>signpost-core</artifactId>
<version>1.2.1.1</version>
</dependency>
<dependency>
<groupId>oauth.signpost</groupId>
<artifactId>signpost-commonshttp4</artifactId>
<version>1.2.1.1</version>
</dependency>
<dependency>
<groupId>com.facebook.android</groupId>
<artifactId>facebook-android-sdk</artifactId>
<version>3.5.2</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.flurry</groupId>
<artifactId>FlurryAgent</artifactId>
<version>3.2.2</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.6.0</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<sdk>
<platform>11</platform>
</sdk>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</plugin>
</plugins>
</build>
</project>
The ADT will throw that error if its finds more than one instance of the same package but with different version number to them. Looking at your pom one of your dependencies is adding the LineTokenizer which is not up-to-date in comparison to the one supplied by the compiler. I would suggest you go to the Dependency Hierarchy using the maven POM Editor. This will allow you to select the extraneous dependency, which you can then exclude by right-clicking and selecting "Exclude Maven Artifact..." which will automatically add an <exclusions> element to your POM. This will remove the duplicate JAR from your Eclipse classpath and allow you to build you project. Do a mvn clean install after you done editing the POM though.

Maven cannot find external jar's annotations

I'm converting a simple android app to Maven, and I've hit a snag with a 3rd party jar (ActiveAndroid) that contains an annotation class that I'm using within my code. I've confirmed that the jar does contain the annotations class files, and the jar works fine when I include it in the libs directory, and compile with Eclipse.
Here's my POM.xml:
<?xml version="1.0" encoding="UTF-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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.danh32</groupId>
<artifactId>testapp</artifactId>
<version>1.0</version>
<packaging>apk</packaging>
<name>testapp</name>
<properties>
<platform.version> 4.1.1.4</platform.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${platform.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.actionbarsherlock</groupId>
<artifactId>actionbarsherlock</artifactId>
<version>4.2.0</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>com.activeandroid</groupId>
<artifactId>activeandroid</artifactId>
<version>LATEST</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.5.0</version>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml
</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<nativeLibrariesDirectory>${project.basedir}/src/main/native
</nativeLibrariesDirectory>
<sdk>
<platform>16</platform>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
And here's my compilation error:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.339s
[INFO] Finished at: Wed Apr 10 14:18:51 CDT 2013
[INFO] Final Memory: 17M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project testapp: Compilation failure: Compilation failure:
[ERROR] /Users/danh32/code/android/workspace-android/TestApp/src/com/danh32/testapp/db/DSLocation.java:[9,43] cannot find symbol
[ERROR] symbol : class ConflictAction
[ERROR] location: #interface com.activeandroid.annotation.Column
[ERROR] /Users/danh32/code/android/workspace-android/TestApp/src/com/danh32/testapp/db/DSLocation.java:[15,32] cannot find symbol
[ERROR] symbol : method unique()
[ERROR] location: #interface com.activeandroid.annotation.Column
[ERROR] /Users/danh32/code/android/workspace-android/TestApp/src/com/danh32/testapp/db/DSLocation.java:[15,47] cannot find symbol
[ERROR] symbol : method onUniqueConflict()
[ERROR] location: #interface com.activeandroid.annotation.Column
[ERROR] /Users/danh32/code/android/workspace-android/TestApp/src/com/danh32/testapp/db/DSLocation.java:[15,66] cannot find symbol
[ERROR] symbol : variable ConflictAction
[ERROR] location: class com.danh32.testapp.db.DSLocation
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
I'm just starting out with Maven and compiling Android apps outside of Eclipse, so I'm sure I'm missing something simple. Any nudge in the right direction is highly appreciated!
Thanks!
You're using LATEST. Is it possible you have more than one version of that artifact, and Maven is picking up a different one from Eclipse?
it doesn't look like the active android artifact is available in the Maven Central Repo (see this search). You can install that jar in your own local repository (using mvn install-file but that will only work on your local machine. Alternatively you can deploy that artifact to a repository that you control and reference that in your POM.
Have you considered class version problem? Just speculating, but it could be that the jar was built using 1.6 JDK (target 1.6) Your POM has specified the source and target as 1.5, considering you are also using 1.5 JDK, it is possible that the compiler is simply not able to read the classes in your jar file compiled with 1.6

Maven android build gives compile time errors as if it's building with -target=1.5

During my maven build I'm getting errors like this:
[ERROR] /sandbox/mobile-apps/quickdroid/test/src/com/xxx/MyActivity.java:[14,21] java.util.LinkedHashMap.Entry has private access in java.util.LinkedHashMap
I created a simple test project with one class. This error corresponds to this code:
LinkedHashMap.Entry<String, Object> test;
Intellij compiles this code just fine. If I change the -target=1.5 in my intellij javac parameters then I get the same error. Below in my pom.xml I've specified target 1.6 and verified with the -X parameter that maven is getting this setting. Why do I get errors as if it's still compiling target 1.5?
excerpts from maven -X output:
1.6
.
[DEBUG] (f) source = 1.6
[DEBUG] (f) staleMillis = 0
[DEBUG] (f) target = 1.6
.
[DEBUG] Command line options:
[DEBUG] -d /sandbox/mobile-apps/quickdroid/test/target/classes -classpath {...} -g -nowarn -target 1.6 -source 1.6
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
<groupId>com.xxx.android</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>test</name>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.3.2</version>
<extensions>true</extensions>
<configuration>
<sdk>
<!-- platform or api level (api level 4 = platform 1.6)-->
<platform>11</platform>
</sdk>
</configuration>
</plugin>
<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>
</plugins>
</build>

Not getting annotation processed (generated) sources compiled into apk, using maven

I try to use Maven and androidannotations to build my apk, but independently of any IDE (I'm actually using IntelliJ IDEA and not Eclipse, but I would like to have it entirely IDE-independent, so that it would also work perfectly on any build server).
The annotations seem to get processed properly, but they're not being compiled into the apk, which is where I'm currently stuck.
I try to use the <includes> section in the maven-compiler-plugin, and the path should be correct - it exists and also contains the annotation processed, generated, java class, which is the Android main activity but with a underscore (_) suffix.
There is a wiki page description how to use Maven+Eclipse, but it's too much bound to the Eclipse IDE. https://github.com/excilys/androidannotations/wiki/Building-Project-Maven-Eclipse
so it doesn't help me solve the problem.
This is my pom.xml:
<?xml version="1.0" encoding="UTF-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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>de-mycompany-myproject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>com-mycompany-base-myproject</name>
<prerequisites>
<maven>2.2.1</maven>
</prerequisites>
<properties>
<platform.version>2.3.3</platform.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${platform.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.googlecode.androidannotations</groupId>
<artifactId>androidannotations</artifactId>
<version>2.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.googlecode.androidannotations</groupId>
<artifactId>androidannotations</artifactId>
<classifier>api</classifier>
<version>2.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
<sdk>
<platform>10</platform>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<includes>
<include>${project.basedir}/target/generated-sources/apt/**</include>
<!--<include>target/generated-sources/apt/**</include>-->
</includes>
</configuration>
</plugin>
<plugin>
<artifactId>versions-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<version>1.3.1</version>
</plugin>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.0.5</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<processors>
<processor>com.googlecode.androidannotations.AndroidAnnotationProcessor</processor>
</processors>
</configuration>
</execution>
</executions>
<dependencies/>
</plugin>
</plugins>
</build>
</project>
mvn install even shows me the -s compiler option with the correct path:
[INFO] javac option: -proc:only
[INFO] javac option: -processor
[INFO] javac option: com.googlecode.androidannotations.AndroidAnnotationProcessor
[INFO] javac option: -d
[INFO] javac option: /Users/myuser/path/to/com.mycompany.myproject/target/classes
[INFO] javac option: -s
[INFO] javac option: /Users/myuser/path/to/com.mycompany.myproject/target/generated-sources/apt
[INFO] diagnostic Note: Starting AndroidAnnotations annotation processing
[INFO] diagnostic warning: Supported source version 'RELEASE_6' from annotation processor 'com.googlecode.androidannotations.AndroidAnnotationProcessor' less than -source '1.7'
[INFO] diagnostic Note: Dummy source file: file:///Users/path/to/com.mycompany.myproject/target/generated-sources/apt/dummy1341816057285.java
[INFO] diagnostic Note: AndroidManifest.xml file found: /Users/myuser/path/to/com.mycompany.myproject/AndroidManifest.xml
[INFO] diagnostic Note: Number of files generated by AndroidAnnotations: 1
[INFO] diagnostic Note: Generating source file: com.mycompany.myproject.activity.HelloAndroidActivity_
(The complete log of mvn install is here: http://pastebin.com/6dQkcNXD)
But still running the apk fails with:
E/AndroidRuntime( 6942): Caused by: java.lang.ClassNotFoundException: com.mycompany.myproject.activity.HelloAndroidActivity_ in loader dalvik.system.PathClassLoader
and the annotation processed HelloAndroidActivity_ is not inside the apk / classes.dex.
Found the problem: <extensions>true</extensions> was missing under maven-compiler-plugin:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<includes>
<include>${project.basedir}/target/generated-sources/apt/**</include>
</includes>
</configuration>
<extensions>true</extensions>
</plugin>
After further research, I've determined that my original answer was incorrect.
The problem actually lies in the generated .classpath file. See: https://gist.github.com/cwc/5224145
In that example, broken_cp.xml causes the processed annotations to not be included in the APK when used as .classpath. Changing its contents to that of working_cp.xml and refreshing the project (prompting a build) immediately fixes the APK issue, and I can launch my Android app from Eclipse successfully.
The broken form of the classpath file is regenerated every time I use the Maven > Update Project... project menu option to reload POM files. I'm working around the issue by paying close attention to updates to the .classpath file, and making sure I don't commit a broken version.

Categories

Resources