jjzjj

android - Maven + AndroidAnnotations 生成但无法访问类

coder 2023-12-24 原文

好的。

我正在尝试创建一个可以通过使用 maven 且仅使用 maven 来完美构建的项目。

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

意思是,如果我在 documentation 中创建一个示例它有效。

一旦我做了类似的事情

Intent i = new Intent(SettingsActivity_);

然后构建失败

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project InterestingFind: Compilation failure cannot find symbol

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

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

这也许可以解释为什么它们没有被拾取,但让我有点头疼。 我克隆了一个 android 原型(prototype),发布版本。

如果您认为可以帮助我解决这个问题,请提供帮助!

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>

编辑:更新 pom。 编辑:已上传 Log file

最佳答案

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

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

此外,我不确定您是否真的需要这个插件来使 AA 工作。

关于android - Maven + AndroidAnnotations 生成但无法访问类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15521639/

有关android - Maven + AndroidAnnotations 生成但无法访问类的更多相关文章

  1. ruby - 使用 RubyZip 生成 ZIP 文件时设置压缩级别 - 2

    我有一个Ruby程序,它使用rubyzip压缩XML文件的目录树。gem。我的问题是文件开始变得很重,我想提高压缩级别,因为压缩时间不是问题。我在rubyzipdocumentation中找不到一种为创建的ZIP文件指定压缩级别的方法。有人知道如何更改此设置吗?是否有另一个允许指定压缩级别的Ruby库? 最佳答案 这是我通过查看ruby​​zip内部创建的代码。level=Zlib::BEST_COMPRESSIONZip::ZipOutputStream.open(zip_file)do|zip|Dir.glob("**/*")d

  2. ruby - 为什么我可以在 Ruby 中使用 Object#send 访问私有(private)/ protected 方法? - 2

    类classAprivatedeffooputs:fooendpublicdefbarputs:barendprivatedefzimputs:zimendprotecteddefdibputs:dibendendA的实例a=A.new测试a.foorescueputs:faila.barrescueputs:faila.zimrescueputs:faila.dibrescueputs:faila.gazrescueputs:fail测试输出failbarfailfailfail.发送测试[:foo,:bar,:zim,:dib,:gaz].each{|m|a.send(m)resc

  3. ruby-on-rails - 由于 "wkhtmltopdf",PDFKIT 显然无法正常工作 - 2

    我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-

  4. ruby-on-rails - 无法使用 Rails 3.2 创建插件? - 2

    我对最新版本的Rails有疑问。我创建了一个新应用程序(railsnewMyProject),但我没有脚本/生成,只有脚本/rails,当我输入ruby./script/railsgeneratepluginmy_plugin"Couldnotfindgeneratorplugin.".你知道如何生成插件模板吗?没有这个命令可以创建插件吗?PS:我正在使用Rails3.2.1和ruby​​1.8.7[universal-darwin11.0] 最佳答案 随着Rails3.2.0的发布,插件生成器已经被移除。查看变更日志here.现在

  5. ruby-on-rails - 在混合/模块中覆盖模型的属性访问器 - 2

    我有一个包含模块的模型。我想在模块中覆盖模型的访问器方法。例如:classBlah这显然行不通。有什么想法可以实现吗? 最佳答案 您的代码看起来是正确的。我们正在毫无困难地使用这个确切的模式。如果我没记错的话,Rails使用#method_missing作为属性setter,因此您的模块将优先,阻止ActiveRecord的setter。如果您正在使用ActiveSupport::Concern(参见thisblogpost),那么您的实例方法需要进入一个特殊的模块:classBlah

  6. ruby - 无法运行 Rails 2.x 应用程序 - 2

    我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby​​:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r

  7. ruby-on-rails - 如何优雅地重启 thin + nginx? - 2

    我的瘦服务器配置了nginx,我的ROR应用程序正在它们上运行。在我发布代码更新时运行thinrestart会给我的应用程序带来一些停机时间。我试图弄清楚如何优雅地重启正在运行的Thin实例,但找不到好的解决方案。有没有人能做到这一点? 最佳答案 #Restartjustthethinserverdescribedbythatconfigsudothin-C/etc/thin/mysite.ymlrestartNginx将继续运行并代理请求。如果您将Nginx设置为使用多个上游服务器,例如server{listen80;server

  8. ruby - 在 jRuby 中使用 'fork' 生成进程的替代方案? - 2

    在MRIRuby中我可以这样做:deftransferinternal_server=self.init_serverpid=forkdointernal_server.runend#Maketheserverprocessrunindependently.Process.detach(pid)internal_client=self.init_client#Dootherstuffwithconnectingtointernal_server...internal_client.post('somedata')ensure#KillserverProcess.kill('KILL',

  9. ruby-on-rails - 无法在centos上安装therubyracer(V8和GCC出错) - 2

    我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e

  10. ruby - 续集在添加关联时访问many_to_many连接表 - 2

    我正在使用Sequel构建一个愿望list系统。我有一个wishlists和itemstable和一个items_wishlists连接表(该名称是续集选择的名称)。items_wishlists表还有一个用于facebookid的额外列(因此我可以存储opengraph操作),这是一个NOTNULL列。我还有Wishlist和Item具有续集many_to_many关联的模型已建立。Wishlist类也有:selectmany_to_many关联的选项设置为select:[:items.*,:items_wishlists__facebook_action_id].有没有一种方法可以

随机推荐