gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 11:16:46 25 4
gpt4 key购买 nike

好的。

我正在尝试创建一个可以通过使用 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),发布版本。

如果您认为可以帮助我解决这个问题,请提供帮助! 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>

编辑:更新 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com