android - AndroidAnnotations processing fails in IntelliJ because R.java isn't generated -
i think there's problem intellij when generates r.java file, leads problem in androidannotations because can't resolve resource id layout.
here's activity:
package com.airlocksoftware.canvastest; import android.app.activity; import android.os.bundle; import com.googlecode.androidannotations.annotations.eactivity; @eactivity(r.layout.main) public class myactivity extends activity { /** * called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); } }
what's weird if comment out annotation, , setcontentview(r.layout.main)
, works fine though r.java never imported.
by way, layout simple "hello world". nothing weird going on there.
no matter do, can't androidannotations generate canvasactivity_.java
. pom.xml looks this:
<?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/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupid>com.airlocksoftware.canvastest</groupid> <artifactid>canvastest</artifactid> <version>1.0-snapshot</version> <properties> <project.build.sourceencoding>utf-8</project.build.sourceencoding> <android.version>4.2.2_r2</android.version> <android.platform>17</android.platform> <androidannotations.version>2.7.1</androidannotations.version> <java.version>1.6</java.version> </properties> <repositories> <repository> <id>local-repo</id> <url>file:///${env.home}/.m2/repository</url> </repository> </repositories> <dependencies> <dependency> <groupid>android</groupid> <artifactid>android</artifactid> <version>${android.version}</version> <scope>provided</scope> </dependency> <dependency> <groupid>com.googlecode.androidannotations</groupid> <artifactid>androidannotations</artifactid> <version>${androidannotations.version}</version> <scope>provided</scope> </dependency> <dependency> <groupid>com.googlecode.androidannotations</groupid> <artifactid>androidannotations-api</artifactid> <version>${androidannotations.version}</version> </dependency> </dependencies> <build> <plugins> <plugin> <artifactid>maven-compiler-plugin</artifactid> <version>2.5.1</version> <configuration> <source>${java.version}</source> <target>${java.version}</target> </configuration> </plugin> <plugin> <groupid>com.jayway.maven.plugins.android.generation2</groupid> <artifactid>android-maven-plugin</artifactid> <version>3.4.0</version> <configuration> <sdk> <platform>${android.platform}</platform> </sdk> <undeploybeforedeploy>true</undeploybeforedeploy> </configuration> <extensions>true</extensions> </plugin> </plugins> </build> </project>
the annotation processing set shown in screenshot.
basically setup processor path point jar files in local maven repo, described here.
the projects sources set like shown in screenshot.
no matter how make / rebuild project, nothing ever shows in gen/aa (and can't reference canvasactivity_.java) ran mvn clean install project root, fails stacktrace.
info] build failure [info] ------------------------------------------------------------------------ [info] total time: 4.363s [info] finished at: sat may 18 15:53:06 mdt 2013 [info] final memory: 11m/81m [info] ------------------------------------------------------------------------ [error] failed execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project canvasproto: compilation failure: compilation failure: [error] /users/matthewbbishop/clients/proto/canvasproto/src/main/java/com/airlocksoftware/canvasproto/canvasactivity.java:[6,38] cannot find symbol [error] symbol : class r [error] location: package com.airlocksoftware.canvasproto [error] /users/matthewbbishop/clients//proto/canvasproto/src/main/java/com/airlocksoftware/canvasproto/canvasactivity.java:[11,12] package r not exist [error] /users/matthewbbishop/clients/proto/canvasproto/src/main/java/com/airlocksoftware/canvasproto/canvasactivity.java:[14,15] package r not exist [error] error: unexpected error. please report issue on androidannotations, following content: java.lang.runtimeexception: java.lang.reflect.invocationtargetexception [error] @ com.googlecode.androidannotations.helper.annotationhelper.extractannotationparameter(annotationhelper.java:293) [error] @ com.googlecode.androidannotations.helper.annotationhelper.extractannotationresidvalueparameter(annotationhelper.java:269) [error] @ com.googlecode.androidannotations.helper.idvalidatorhelper.residsexist(idvalidatorhelper.java:45) [error] @ com.googlecode.androidannotations.validation.eactivityvalidator.validate(eactivityvalidator.java:55) [error] @ com.googlecode.androidannotations.validation.modelvalidator.validate(modelvalidator.java:56) [error] @ com.googlecode.androidannotations.androidannotationprocessor.validateannotations(androidannotationprocessor.java:414) [error] @ com.googlecode.androidannotations.androidannotationprocessor.processthrowing(androidannotationprocessor.java:364) [error] @ com.googlecode.androidannotations.androidannotationprocessor.process(androidannotationprocessor.java:341) [error] @ com.sun.tools.javac.processing.javacprocessingenvironment.callprocessor(javacprocessingenvironment.java:627) [error] @ com.sun.tools.javac.processing.javacprocessingenvironment.discoverandrunprocs(javacprocessingenvironment.java:556) [error] @ com.sun.tools.javac.processing.javacprocessingenvironment.doprocessing(javacprocessingenvironment.java:701) [error] @ com.sun.tools.javac.main.javacompiler.processannotations(javacompiler.java:987) [error] @ com.sun.tools.javac.main.javacompiler.compile(javacompiler.java:727) [error] @ com.sun.tools.javac.main.main.compile(main.java:353) [error] @ com.sun.tools.javac.main.main.compile(main.java:279) [error] @ com.sun.tools.javac.main.main.compile(main.java:270) [error] @ com.sun.tools.javac.main.compile(main.java:87) [error] @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) [error] @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) [error] @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) [error] @ java.lang.reflect.method.invoke(method.java:597) [error] @ org.codehaus.plexus.compiler.javac.javaccompiler.compileinprocess0(javaccompiler.java:551) [error] @ org.codehaus.plexus.compiler.javac.javaccompiler.compileinprocess(javaccompiler.java:526) [error] @ org.codehaus.plexus.compiler.javac.javaccompiler.compile(javaccompiler.java:167) [error] @ org.apache.maven.plugin.abstractcompilermojo.execute(abstractcompilermojo.java:678) [error] @ org.apache.maven.plugin.compilermojo.execute(compilermojo.java:128) [error] @ org.apache.maven.plugin.defaultbuildpluginmanager.executemojo(defaultbuildpluginmanager.java:101) [error] @ org.apache.maven.lifecycle.internal.mojoexecutor.execute(mojoexecutor.java:209) [error] @ org.apache.maven.lifecycle.internal.mojoexecutor.execute(mojoexecutor.java:153) [error] @ org.apache.maven.lifecycle.internal.mojoexecutor.execute(mojoexecutor.java:145) [error] @ org.apache.maven.lifecycle.internal.lifecyclemodulebuilder.buildproject(lifecyclemodulebuilder.java:84) [error] @ org.apache.maven.lifecycle.internal.lifecyclemodulebuilder.buildproject(lifecyclemodulebuilder.java:59) [error] @ org.apache.maven.lifecycle.internal.lifecyclestarter.singlethreadedbuild(lifecyclestarter.java:183) [error] @ org.apache.maven.lifecycle.internal.lifecyclestarter.execute(lifecyclestarter.java:161) [error] @ org.apache.maven.defaultmaven.doexecute(defaultmaven.java:319) [error] @ org.apache.maven.defaultmaven.execute(defaultmaven.java:156) [error] @ org.apache.maven.cli.mavencli.execute(mavencli.java:537) [error] @ org.apache.maven.cli.mavencli.domain(mavencli.java:196) [error] @ org.apache.maven.cli.mavencli.main(mavencli.java:141) [error] @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) [error] @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) [error] @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) [error] @ java.lang.reflect.method.invoke(method.java:597) [error] @ org.codehaus.plexus.classworlds.launcher.launcher.launchenhanced(launcher.java:290) [error] @ org.codehaus.plexus.classworlds.launcher.launcher.launch(launcher.java:230) [error] @ org.codehaus.plexus.classworlds.launcher.launcher.mainwithexitcode(launcher.java:409) [error] @ org.codehaus.plexus.classworlds.launcher.launcher.main(launcher.java:352) [error] caused by: java.lang.reflect.invocationtargetexception [error] @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) [error] @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) [error] @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) [error] @ java.lang.reflect.method.invoke(method.java:597) [error] @ com.googlecode.androidannotations.helper.annotationhelper.extractannotationparameter(annotationhelper.java:287) [error] ... 46 more [error] caused by: java.lang.annotation.annotationtypemismatchexception: incorrectly typed data found annotation element public abstract int com.googlecode.androidannotations.annotations.eactivity.value() (found data of type int) [error] @ com.sun.tools.javac.model.annotationproxymaker$valuevisitor$1.generateexception(annotationproxymaker.java:243) [error] @ sun.reflect.annotation.annotationinvocationhandler.invoke(annotationinvocationhandler.java:56) [error] @ $proxy16.value(unknown source) [error] ... 51 more
honestly i'm @ loss now. if has idea of do, amazing. thanks!
edit: here's stub r.java generated intellij.
/*___generated_by_idea___*/ package com.airlocksoftware.canvastest; /* stub using ide only. not r class packed apk */ public final class r { }
its because pom.xml
missing following:
<packaging>apk</packaging>
without r.java
file not generated.
add top of pom.xml
follows:
<?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/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupid>com.airlocksoftware.canvastest</groupid> <artifactid>canvastest</artifactid> <version>1.0-snapshot</version> <packaging>apk</packaging> /* ... */ /* rest fine */ /* ... */
Comments
Post a Comment