2012-11-02 46 views
0

使用maven構建項目的android anotations(v.2.6)出現問題,使用eclipse所有的作品都很好。下面是一些項目和錯誤的詳細信息:「錯誤:意外的錯誤」使用Android Anotations創建maven時出現

構建配置片斷從POM:

<plugin> 
       <groupId>com.jayway.maven.plugins.android.generation2</groupId> 
       <artifactId>android-maven-plugin</artifactId> 
       <version>3.3.2</version> 
       <inherited>true</inherited> 
       <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> 
      </plugin> 

      <plugin> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>2.5</version> 
       <inherited>true</inherited> 
       <configuration> 
        <source>1.6</source> 
        <target>1.6</target> 
       </configuration> 
       <extensions>true</extensions> 
      </plugin> 

,並在這裏父項目執行mvn clean install後輸出:

[INFO] --- maven-compiler-plugin:2.5:compile (default-compile) @ native-container framework --- 
[INFO] Compiling 102 source files to /Users/vitaliyzasadnyy/Development/repository/androidcontainer/native-container- android/native-container-framework/target/classes 
[INFO] ------------------------------------------------------------- 
[ERROR] COMPILATION ERROR : 
[INFO] ------------------------------------------------------------- 
[ERROR] error: Unexpected error. Please report an issue on AndroidAnnotations, with the following content: java.lang.NullPointerException 
[ERROR]  at com.googlecode.androidannotations.internal.codemodel.JCodeModel.ref(JCodeModel.java:372) 
at com.googlecode.androidannotations.processing.EBeansHolder.refClass(EBeansHolder.java:160) 
at com.googlecode.androidannotations.processing.EBeansHolder$Classes.<init>(EBeansHolder.java:50) 
at com.googlecode.androidannotations.processing.EBeansHolder.<init>(EBeansHolder.java:136) 
at com.googlecode.androidannotations.processing.ModelProcessor.process(ModelProcessor.java:40) 
at com.googlecode.androidannotations.AndroidAnnotationProcessor.processAnnotations(AndroidAnnotationProcessor.java:472) 
at com.googlecode.androidannotations.AndroidAnnotationProcessor.processThrowing(AndroidAnnotationProcessor.java:343) 
at com.googlecode.androidannotations.AndroidAnnotationProcessor.process(AndroidAnnotationProcessor.java:318) 
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:627) 
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:556) 
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:701) 
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:987) 
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727) 
at com.sun.tools.javac.main.Main.compile(Main.java:353) 
at com.sun.tools.javac.main.Main.compile(Main.java:279) 
at com.sun.tools.javac.main.Main.compile(Main.java:270) 
at com.sun.tools.javac.Main.compile(Main.java:87) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
at java.lang.reflect.Method.invoke(Method.java:597) 
at org.codehaus.plexus.compiler.javac.JavacCompiler.compileInProcess0(JavacCompiler.java:559) 
at org.codehaus.plexus.compiler.javac.JavacCompiler.compileInProcess(JavacCompiler.java:534) 
at org.codehaus.plexus.compiler.javac.JavacCompiler.compile(JavacCompiler.java:168) 
at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:678) 
at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128) 
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) 
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) 
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) 
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) 
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) 
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) 
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) 
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) 
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) 
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) 
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) 
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
at java.lang.reflect.Method.invoke(Method.java:597) 
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) 
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) 
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) 
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) /Users/vitaliyzasadnyy/Development/repository/androidcontainer/native-container-android/native-container-framework/src/main/java/com/nravo/framework/activity/MainScreenActivity.java:[44,-1] Unexpected error. Please report an issue on AndroidAnnotations, with the following content: java.lang.NullPointerException 
at com.googlecode.androidannotations.internal.codemodel.JCodeModel.ref(JCodeModel.java:372) 
at com.googlecode.androidannotations.processing.EBeansHolder.refClass(EBeansHolder.java:160) 

有誰碰到這樣的問題呢?

+0

_ 「請AndroidAnnotations報告問題,有以下內容:」 _... – keyser

+0

[創建問題(https://github.com/excilys/ androidannotations /問題/ 374) – zasadnyy

回答

0

隨着Piwai的建議我解決了這個問題,轉移到快照構建的android註釋。爲了切換到快照取代在你的pom.xml當前AA依賴有:

<dependency> 
    <groupId>com.googlecode.androidannotations</groupId> 
    <artifactId>androidannotations</artifactId> 
    <version>2.7-SNAPSHOT</version> 
</dependency> 

<dependency> 
    <groupId>com.googlecode.androidannotations</groupId> 
    <artifactId>androidannotations-api</artifactId> 
    <version>2.7-SNAPSHOT</version> 
</dependency> 

你也需要添加的快照庫:從AA v.2.7:

<repositories> 
    <repository> 
     <id>snapshots-repository</id> 
     <name>Sonatype oss snapshot repo</name> 
     <url>https://oss.sonatype.org/content/repositories/snapshots</url> 
    </repository> 
</repositories> 

注意版本說明:

the API jar is now a separate artifact, androidannotations-api. We do not use the api classifier any more.

-1

我遇到了這個問題。一個解決辦法是正如我在issue you created提到它添加到pom.xml中

<dependency> 
     <groupId>com.google.android</groupId> 
     <artifactId>annotations</artifactId> 
     <version>4.1.1.4</version> 
    </dependency> 
1

,這是Maven的/ CodeModel錯誤中Thread.currentThread().getContextClassLoader()返回null一個原因,我不知道。我即將發佈AndroidAnnotations 2.7,此問題不應再出現。

相關問題