0

我在使用 maven 使用 android annotations (v.2.6) 构建项目时遇到问题,使用 eclipse 一切正常。以下是一些项目和错误详细信息:

从 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)

有人遇到这个问题吗?

4

3 回答 3

1

正如我在您创建的问题中提到的,这是 Maven / CodeModel 错误,其中Thread.currentThread().getContextClassLoader()返回 null 的原因我不知道。我即将发布AndroidAnnotations 2.7,这个问题应该不会再出现了。

于 2012-11-03T15:53:06.357 回答
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>

您还需要添加快照存储库:

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

注意:来自 AA v.2.7 发行说明:

API jar 现在是一个单独的工件,androidannotations-api。我们不再使用 api 分类器。

于 2012-11-03T18:19:43.810 回答
-1

我遇到了这个。一种解决方案是将其添加到 pom.xml

    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>annotations</artifactId>
        <version>4.1.1.4</version>
    </dependency>
于 2012-11-02T17:28:44.000 回答