0

I'm working on an Android app in NetBeans 7.3 (because it's my preferred IDE). It's a Maven project, it has a dependency on ActionBarSherlock and I'm using the android-maven-plugin.

My POM is similar to this one:

<?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>

Everything works fine until I actual want to use the ActionBarSherlock library. NetBeans does not seem to recognize the classes in the apklib (for example com.actionbarsherlock.app.SherlockActivity). I can find the apklib in the tree structure of the project in NetBeans, but it's filed under Non-classpath Dependencies. It does recognize the generated sources of the library (like com.actionbarsherlock.R).

How can I fix this, so that NetBeans does not complain about classes not being found and so that auto-completion works for these classes?

I tried several possible workarounds (1, 2, 3), but they were not working for me. Also I'm pretty sure NetBeans bug 220446 is related

Intrications
  • 16,782
  • 9
  • 50
  • 50
Arno Moonen
  • 1,134
  • 2
  • 10
  • 28
  • 1
    Hello Arno, this might not be what you want to hear but I'd suggest you to migrate to Android Studio or IntellijIDEA as it is way better for Android development, you will get used with it in a few days.. – Cata Jun 29 '13 at 19:58
  • @Cata Android Studio (== Eclipse) is definitely not my preferred IDE. But that's not what this questions about. As I can tell more people had problems with this and I just want to know how it can be fixed. – Arno Moonen Jun 29 '13 at 20:02
  • I've started a new project using [Android Kickstartr](http://androidkickstartr.com/). This project does work, I'm pretty sure one of the mentioned workarounds is used. If I can find the time, I'll experiment with the POM in the question and replacing parts with parts from the new POM that Kickstartr has created. In the mean time, I'd love to hear your suggestions. – Arno Moonen Jun 30 '13 at 12:16
  • @ArnoMoonen Android Studio != Eclipse. Android Studio is based on IntelliJ IDEA: http://developer.android.com/sdk/installing/studio.html – Intrications Jul 17 '13 at 09:24
  • @Intrications When I started developing for Android, Eclipse was the way to go (with the plug-in provided by Google), hence my assumption. However, that still does not solve the problem for NetBeans. – Arno Moonen Jul 17 '13 at 13:32
  • @ArnoMoonen I really recommend giving Android Studio a try, it is vastly better than Eclipse already. NetBeans is never going to work very well because Google have no interest in making it work. – Intrications Jul 17 '13 at 14:55

1 Answers1

0

You should install nbandroid modules which should be able to handle the android classpath for you. http://www.nbandroid.org/

mkleint
  • 2,281
  • 1
  • 14
  • 17
  • I already have version 1.141 of the NB Android plugin installed. So this doesn't solve the problem. – Arno Moonen Jun 30 '13 at 12:12
  • ok, then unfortunately the evaluation from nb.org issue 220446 applies. The generic maven support in netbeans cannot know about maven model modifications done during build execution. You can file an issue against nbandroid I suppose. – mkleint Jun 30 '13 at 16:49