我正在NetBeans 7.3中开发一个Android应用程序(因为它是我喜欢的IDE)。这是一个Maven项目,它依赖ActionBarSherlock,我使用的是android Maven插件。
我的POM与此类似:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>amnl.example</groupId>
<artifactId>android-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>amnl.example</groupId>
<artifactId>android-app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>Yet Another Android App</name>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.actionbarsherlock</groupId>
<artifactId>actionbarsherlock</artifactId>
<version>4.3.1</version>
<type>apklib</type>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<!-- use the copy resources instead of resources, which adds it to
the eclipse buildpath -->
<phase>initialize</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.basedir}/res</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/src/templates/res</directory>
<targetPath>${project.basedir}/res</targetPath>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<sdk>
<platform>16</platform>
</sdk>
<manifest>
<debuggable>true</debuggable>
</manifest>
</configuration>
<executions>
<execution>
<id>manifestUpdate</id>
<phase>process-resources</phase>
<goals>
<goal>manifest-update</goal>
</goals>
</execution>
<execution>
<id>alignApk</id>
<phase>package</phase>
<goals>
<goal>zipalign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>release</id>
<!-- via this activation the profile is automatically used when the release
is done with the maven release plugin -->
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<executions>
<execution>
<id>signing</id>
<goals>
<goal>sign</goal>
<goal>verify</goal>
</goals>
<phase>package</phase>
<inherited>true</inherited>
<configuration>
<removeExistingSignatures>true</removeExistingSignatures>
<archiveDirectory />
<includes>
<include>${project.build.directory}/${project.artifactId}.apk</include>
</includes>
<keystore>${sign.keystore}</keystore>
<alias>${sign.alias}</alias>
<storepass>${sign.storepass}</storepass>
<keypass>${sign.keypass}</keypass>
<verbose>false</verbose>
</configuration>
</execution>
</executions>
</plugin>
<!-- the signed apk then needs to be zipaligned and we activate proguard
and we run the manifest update -->
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<release>true</release>
<sign>
<debug>false</debug>
</sign>
<zipalign>
<skip>false</skip>
<verbose>true</verbose>
<inputApk>${project.build.directory}/${project.artifactId}.apk</inputApk>
<outputApk>${project.build.directory}/${project.artifactId}-signed-aligned.apk
</outputApk>
</zipalign>
<manifest>
<debuggable>false</debuggable>
<versionCodeAutoIncrement>true</versionCodeAutoIncrement>
</manifest>
<!-- Change to true to skip Proguard -->
<proguard>
<skip>false</skip>
</proguard>
</configuration>
<executions>
<execution>
<id>manifestUpdate</id>
<phase>process-resources</phase>
<goals>
<goal>manifest-update</goal>
</goals>
</execution>
<execution>
<id>alignApk</id>
<phase>package</phase>
<goals>
<goal>zipalign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<configuration>
<artifacts>
<artifact>
<file>${project.build.directory}/${project.artifactId}-signed-aligned.apk</file>
<type>apk</type>
<classifier>signed-aligned</classifier>
</artifact>
<artifact>
<file>${project.build.directory}/proguard/mapping.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>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
在我真正想使用ActionBarSherlock库之前,一切都很好。NetBeans似乎无法识别apklib中的类(例如com.actionbarsherlock.app.SherlockActivity
)。我可以在NetBeans中的项目树结构中找到apklib,但它是在非类路径依赖项下归档的。它确实识别库的生成源(如com.actionbarsherlock.R
)。
我该如何解决这个问题,这样NetBeans就不会抱怨找不到类,并且自动完成对这些类有效?
我尝试了几种可能的解决方案(1、2、3),但它们对我不起作用。此外,我非常确信NetBeans错误220446与有关
您应该安装nbandroid模块,该模块应该能够为您处理android类路径。http://www.nbandroid.org/