已生成M​​aven + AndroidAnnotations但无法访问的类

时间:2013-03-20 11:00:06

标签: android maven android-annotations

好的。

我正在尝试使用maven和maven创建一个完美构建的项目。

目前我正面临着这个类生成的问题,并且工作正常,只要在实际的java代码中没有引用。

意思是,如果我在documentation创建一个例子就可以了。

一旦我做了像

这样的事情
  

意图i =新意图(SettingsActivity _);

然后构建失败并带有

  

无法在项目InterestingFind上执行目标org.apache.maven.plugins:maven-compiler-plugin:3.0:compile(default-compile):   编译失败找不到符号

cannot find symbol
symbol:   variable DerpActivity_
location: class be.company.android.DisplayMapActivity

但是,生成的文件确实生成了,如附图所示,但是当在Eclipse视图中查看项目时,它们仅被视为普通文件夹,而不是“源文件夹”。

这可能解释了为什么他们没有被接受,但让我有点头疼。 我克隆了一个android原型,即发布版本。

如果您以某种方式认为可以帮助我解决这个问题,请提供帮助!Project structure

  

  http://maven.apache.org/maven-v4_0_0.xsd">       4.0.0

<parent>
    <groupId>be.idamediafoundry</groupId>
    <artifactId>InterestingFind-parent</artifactId>
    <version>1.0-SNAPSHOT</version>
</parent>

<groupId>be.idamediafoundry</groupId>
<artifactId>InterestingFind</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>InterestingFind - Application</name>
<properties>
    <androidannotations.version>3.0-SNAPSHOT</androidannotations.version>
</properties>

<repositories>
    <repository>
        <id>snapshots-repository</id>
        <name>Sonatype oss snapshot repo</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android</artifactId>
    </dependency>
    <dependency>
        <groupId>de.akquinet.android.androlog</groupId>
        <artifactId>androlog</artifactId>
    </dependency>
    <!-- JSON -->
    <dependency>
        <groupId> org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>1.9.5</version>
    </dependency>
    <!-- AndroidAnnotations -->
    <dependency>
        <groupId>org.androidannotations</groupId>
        <artifactId>androidannotations</artifactId>
        <version>${androidannotations.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.androidannotations</groupId>
        <artifactId>androidannotations-api</artifactId>
        <version>${androidannotations.version}</version>
    </dependency>

    <!-- Needed for androidannotations -->
    <dependency>
        <groupId>org.springframework.android</groupId>
        <artifactId>spring-android-rest-template</artifactId>
        <version>${spring-android-version}</version>
    </dependency>

    <!-- Google Play Services : Should be compiled and added to local repo -->
    <dependency>
        <groupId>com.google.android.gms</groupId>
        <artifactId>google-play-services</artifactId>
        <version>5</version>
        <type>apklib</type>
    </dependency>
</dependencies>

<build>
    <plugins>


        <plugin>
        <groupId>com.jayway.maven.plugins.android.generation2</groupId>
        <artifactId>android-maven-plugin</artifactId>
        <version>3.5.1</version>
        <inherited>true</inherited>
        <extensions>true</extensions>
        <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>15</platform>
            </sdk>
            <undeployBeforeDeploy>true</undeployBeforeDeploy>
        </configuration>
    </plugin>

        <plugin>
            <artifactId>versions-maven-plugin</artifactId>
            <groupId>org.codehaus.mojo</groupId>
            <version>2.0</version>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-eclipse-plugin</artifactId>
            <version>2.9</version>
            <configuration>
                <additionalProjectnatures>
                    <projectnature>com.android.ide.eclipse.adt.AndroidNature</projectnature>
                    <projectnature>org.eclipse.jdt.core.javanature</projectnature>
                </additionalProjectnatures>
            </configuration>
        </plugin>
    </plugins>
</build>

<profiles>
    <profile>
        <id>release</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>com.pyx4me</groupId>
                    <artifactId>proguard-maven-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>process-classes-with-proguard</id>
                            <phase>process-classes</phase>
                            <goals>
                                <goal>proguard</goal>
                            </goals>
                            <configuration>
                                <proguardVersion>4.4</proguardVersion>
                                <maxMemory>256m</maxMemory>
                                <injar>classes</injar>
                                <libs>
                                    <lib>${rt.jar.path}</lib>
                                    <lib>${jsse.jar.path}</lib>
                                </libs>
                                <obfuscate>true</obfuscate>
                                <addMavenDescriptor>false</addMavenDescriptor>
                                <proguardInclude>${project.basedir}/proguard.conf</proguardInclude>
                            </configuration>
                        </execution>
                    </executions>
                    <dependencies>
                        <dependency>
                            <groupId>net.sf.proguard</groupId>
                            <artifactId>proguard</artifactId>
                            <version>4.4</version>
                            <scope>runtime</scope>
                        </dependency>
                    </dependencies>
                </plugin>
                <plugin>
                    <artifactId>maven-jarsigner-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>sign-application-apk</id>
                            <phase>package</phase>
                            <goals>
                                <goal>sign</goal>
                                <goal>verify</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>zipalign-application-apk</id>
                            <phase>package</phase>
                            <goals>
                                <goal>zipalign</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <release>true</release>
                        <zipalign>
                            <verbose>true</verbose>
                            <inputApk>${project.build.directory}/${project.artifactId}-${project.version}.apk</inputApk>
                            <outputApk>${project.build.directory}/${project.artifactId}-${project.version}-signed-aligned.apk</outputApk>
                        </zipalign>
                        <sign>
                            <debug>false</debug>
                        </sign>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>

                    <configuration>
                        <artifacts>
                            <artifact>
                                <file>${project.build.directory}/proguard_map.txt</file>
                                <type>map</type>
                                <classifier>release</classifier>
                            </artifact>
                        </artifacts>
                    </configuration>
                    <executions>
                        <execution>
                            <id>attach-signed-aligned</id>
                            <phase>package</phase>
                            <goals>
                                <goal>attach-artifact</goal>
                            </goals>
                        </execution>
                        <execution>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>add-source</goal>
                            </goals>
                            <configuration>
                                <sources>
                                    <source>${project.basedir}/target/generated-sources/annotations</source>
                                </sources>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

父Pom:

  

  http://maven.apache.org/maven-v4_0_0.xsd">       4.0.0

<groupId>be.idamediafoundry</groupId>
<artifactId>InterestingFind-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>InterestingFind - Parent</name>

<modules>
    <module>InterestingFind</module>
    <module>InterestingFind-it</module>
</modules>

<properties>
    <platform.version>4.1.1.4</platform.version>
    <android-plugin>3.5.1</android-plugin>
    <spring-android-version>1.0.1.RELEASE</spring-android-version>
    <sign.keystore>${project.basedir}/my-release-key.keystore</sign.keystore>
    <sign.alias>
    </sign.alias>
    <sign.storepass>
    </sign.storepass>
    <sing.keypass>
    </sing.keypass>

</properties>

<repositories>
    <repository>
        <id>codehaus-snapshots</id>
        <url>http://snapshots.repository.codehaus.org</url>
    </repository>

</repositories>

<dependencyManagement>
    <dependencies>

        <dependency>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <version>3.5.1</version>
        </dependency>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>${platform.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android-test</artifactId>
            <version>${platform.version}</version>
            <scope>provided</scope>
        </dependency>

        <!-- Androlog is a logging and reporting library for Android -->
        <dependency>
            <groupId>de.akquinet.android.androlog</groupId>
            <artifactId>androlog</artifactId>
            <version>1.0.5</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>provided</scope>
        </dependency>

    </dependencies>


</dependencyManagement>

<build>
    <pluginManagement>
        <plugins>

            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>3.5.1</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>15</platform>
                    </sdk>
                    <undeployBeforeDeploy>true</undeployBeforeDeploy>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
                <extensions>true</extensions>
            </plugin>
            <plugin>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>1.0</version>
            </plugin>
            <plugin>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-jarsigner-plugin</artifactId>
                <version>1.2</version>
                <inherited>true</inherited>
                <configuration>
                    <removeExistingSignatures>true</removeExistingSignatures>
                    <archiveDirectory />
                    <archive>${project.build.directory}/${project.build.finalName}.${project.packaging}</archive>
                    <verbose>true</verbose>
                    <certs>true</certs>
                    <keystore>${sign.keystore}</keystore>
                    <alias>${sign.alias}</alias>
                    <storepass>${sign.storepass}</storepass>
                    <keypass>${sign.keypass}</keypass>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.pyx4me</groupId>
                <artifactId>proguard-maven-plugin</artifactId>
                <version>2.0.4</version>
                <dependencies>
                    <dependency>
                        <groupId>net.sf.proguard</groupId>
                        <artifactId>proguard</artifactId>
                        <version>4.4</version>
                        <scope>runtime</scope>
                    </dependency>
                </dependencies>
                <configuration>
                    <proguardVersion>4.4</proguardVersion>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

<profiles>
    <profile>
        <id>release</id>
        <activation>
            <property>
                <name>performRelease</name>
                <value>true</value>
            </property>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <version>${android-plugin}</version>
                    <configuration>
                        <release>true</release>
                    </configuration>
                </plugin>

                <plugin>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>enforce-signing-properties</id>
                            <goals>
                                <goal>enforce</goal>
                            </goals>
                            <configuration>
                                <rules>
                                    <requireProperty>
                                        <property>sign.keystore</property>
                                        <message>The 'sign.keystore' property is missing. It must
                                            contain the path to the
                                            keystore used to sign the
                                            application.
                                        </message>
                                    </requireProperty>
                                    <requireFilesExist>
                                        <files>
                                            <file>${sign.keystore}</file>
                                        </files>
                                        <message>The 'sign.keystore' property does not point to a
                                            file. It must contain the
                                            path to the keystore used to sign
                                            the application.
                                        </message>
                                    </requireFilesExist>
                                    <requireProperty>
                                        <property>sign.alias</property>
                                        <message>The 'sign.alias' property is missing. It must
                                            contain the key alias used to
                                            sign the application.
                                        </message>
                                    </requireProperty>
                                    <requireProperty>
                                        <property>sign.storepass</property>
                                        <message>The 'sign.storepass' property is missing. It must
                                            contain the password of
                                            the keystore used to sign the
                                            application.
                                        </message>
                                    </requireProperty>
                                    <requireProperty>
                                        <property>sign.keypass</property>
                                        <message>The 'sign.keypass' property is missing. It must
                                            contain the password of the
                                            key used to sign the application.
                                        </message>
                                    </requireProperty>
                                </rules>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
    <profile>
        <id>linux</id>
        <activation>
            <os>
                <family>unix</family>
            </os>
        </activation>
        <properties>
            <rt.jar.path>${java.home}/jre/lib/rt.jar</rt.jar.path>
            <jsse.jar.path>${java.home}/jre/lib/jsse.jar</jsse.jar.path>
        </properties>
    </profile>
    <!-- mac profile has to be after unix since running on mac will trigger 
        both -->
    <profile>
        <id>mac</id>
        <activation>
            <os>
                <family>mac</family>
            </os>
        </activation>
        <properties>
            <!-- absolute path -->
            <!--<rt.jar.path>/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Classes/classes.jar</rt.jar.path> -->
            <!-- or with JAVA_HOME /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/ -->
            <rt.jar.path>${java.home}/../Classes/classes.jar</rt.jar.path>
            <jsse.jar.path>${java.home}/../Classes/jsse.jar</jsse.jar.path>
        </properties>
    </profile>
    <profile>
        <id>windows</id>
        <activation>
            <os>
                <family>windows</family>
            </os>
        </activation>
        <properties>
            <rt.jar.path>${java.home}/jre/lib/rt.jar</rt.jar.path>
            <jsse.jar.path>${java.home}/jre/lib/jsse.jar</jsse.jar.path>
        </properties>
    </profile>
</profiles>

编辑:更新后的广告 修改:已上传Log file

2 个答案:

答案 0 :(得分:0)

嗯......在你的maven-processor-plugin配置中,你正在使用AA处理器的旧包命名(即:com.googlecode.androidannotations.AndroidAnnotationProcessor)。

当您使用3.0-SNAPSHOT时,您应该修改它以使用新的:org.androidannotations.AndroidAnnotationProcessor

另外,我不确定你真的需要这个插件才能让AA工作。

答案 1 :(得分:0)

似乎问题是由依赖关系未解决引起的。

起初,Maven甚至没有报告这个缺失的依赖项,直到我开始从我的pom中删除了我为解决此问题而添加的内容。

现在,解释依赖关系没有得到自动解决的原因是中央maven存储库中没有这样的工件。

因此,我添加了以下存储库:

<repositories>
    <!-- For developing with Android ROME Feed Reader -->
    <repository>
        <id>android-rome-feed-reader-repository</id>
        <name>Android ROME Feed Reader Repository</name>
        <url>https://android-rome-feed-reader.googlecode.com/svn/maven2/releases</url>
    </repository>
</repositories>

导致“隐藏”依赖关系得到解决。

似乎需要这种依赖性
    <!-- Needed for androidannotations REST interface-->
    <dependency>
        <groupId>org.springframework.android</groupId>
        <artifactId>spring-android-rest-template</artifactId>
        <version>${spring-android-version}</version>
    </dependency>

Spring docs报告说,我们所说的“隐藏依赖关系”需要其余模板的RSS和Atom提要支持。

这更令人讨厌的是,由AA注释的初始活动得到了很好的创建和解决。只要我没有引用生成的类,例如对于导航,然后它编译并运行。 从我尝试在代码中使用class_的那一刻起,它沿着这条路走下去。

希望这有帮助!