This Question is Answered

2 "helpful" answers available (2 pts)
4 Replies Last post: Mar 22, 2013 8:19 PM by Colin Madere  
Colin Madere Newbie 12 posts since
Jul 17, 2003
Currently Being Moderated

Mar 8, 2013 8:40 PM

IDEA + Android + Maven = various library and resource resolution problems

Here is the setup:

OSX 10.8.2, Maven 3.0.4, IDEA 12.0.4

 

Current example is an "apklib" project, since that is what my real project is, but this does not seem to be limited to that type.

 

Create project in IDEA as an Android project, then add the included pom.xml and run the maven "compile" phase within IDEA.  Compiles and ultimately the app runs correctly, but:

 

1) Resources found in the local project do not resolve (nor do they resolve in projects that depend on this project).  While I don't usually ever use the IDEA "build", I did to see what it would do and it resulted in the 3 errors you see in the bottom left of the screenshot that are saying it can't find the resources referenced in the AndroidManifest.xml (the file IDEA generated and the value in strings.xml that IDEA generated).  This appears to be the same as this issue that was closed since the person didn't respond in a month (it seems): http://youtrack.jetbrains.com/issue/IDEA-97269

 

Screen Shot 2013-03-08 at 11.18.05 AM.png

 

 

2) If you are doing development in a full Maven environment and need for it to have access to all the Android SDK resources like me, you may have deployed them all to your local or remote Maven repository using "maven-android-sdk-deployer" (https://github.com/mosabua/maven-android-sdk-deployer).  Since Google won't/isn't putting all and up-to-date libraries in Maven Central, you have to use this and change the namespace for some resources (the couple that ARE in Maven Central) to just "android" instead of "com.google.android".  If you do this, you wind up with IDEA not being able to resolve the libraries for things that depend on "com.android.google" and not resolving classes, even though when you compile there is no problem.

 

Here is an example depending on the latest version of android (which to do so using Maven you must use the deployer to be able to do, since 4.2 is NOT in Maven Central) and the very popular Sherlock and ViewPageIndicator libraries:

pom.xml:

 

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example.deptest</groupId>
    <artifactId>deptest</artifactId>
    <version>1.0.0</version>
    <packaging>apklib</packaging>
    <name>IDEA Android apklib dependency test</name>

    <dependencies>
        <dependency>
            <groupId>android</groupId>
            <artifactId>android</artifactId>
            <version>4.2_r1</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>support-v4</artifactId>
            <version>r7</version>
        </dependency>

        <dependency>
            <groupId>com.viewpagerindicator</groupId>
            <artifactId>library</artifactId>
            <version>2.4.1</version>
            <type>apklib</type>
        </dependency>

        <dependency>
            <groupId>com.actionbarsherlock</groupId>
            <artifactId>actionbarsherlock</artifactId>
            <version>4.2.0</version>
            <type>apklib</type>
        </dependency>

    </dependencies>

    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
            </plugin>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>3.5.1</version>
                <inherited>true</inherited>
                <configuration>
                    <sdk><platform>17</platform></sdk>
                </configuration>
                <extensions>true</extensions>
            </plugin>
        </plugins>
    </build>
</project>


 

Which results in, for example, the main Activity of my project (initially created by default with IDEA) not being able to resolve the fact that my main class is in fact a grandchild of Activity, since it's inheriting from the Sherlock class which is not getting resolved due to some confusing inability for it to resolve it's dependency through "com.google.android"... it's as if it is trying to use the depended-upon project's namespace for the library rather than just using the available tree of dependencies and their true namespace (rather than the namespace as defined in the maven <dependency> tag).  Such projects also compile and run fine, so maven is properly handling the dependency and resolution of transitive dependencies.

 

11:36:49 AM Error when importing module '~apklib-com.viewpagerindicator_library_2.4.1': Cannot resolve artifact com.google.android:android
11:36:49 AM Error when importing module '~apklib-com.viewpagerindicator_library_2.4.1': Cannot resolve artifact commons-logging:commons-logging
11:36:49 AM Error when importing module '~apklib-com.viewpagerindicator_library_2.4.1': Cannot resolve artifact org.apache.httpcomponents:httpclient
11:36:49 AM Error when importing module '~apklib-com.viewpagerindicator_library_2.4.1': Cannot resolve artifact org.apache.httpcomponents:httpcore
11:36:49 AM Error when importing module '~apklib-com.viewpagerindicator_library_2.4.1': Cannot resolve artifact commons-codec:commons-codec
11:36:49 AM Error when importing module '~apklib-com.viewpagerindicator_library_2.4.1': Cannot resolve artifact org.khronos:opengl-api
11:36:49 AM Error when importing module '~apklib-com.viewpagerindicator_library_2.4.1': Cannot resolve artifact xerces:xmlParserAPIs
11:36:49 AM Error when importing module '~apklib-com.viewpagerindicator_library_2.4.1': Cannot resolve artifact xpp3:xpp3
11:36:49 AM Error when importing module '~apklib-com.viewpagerindicator_library_2.4.1': Cannot resolve artifact org.json:json
11:36:50 AM Error when importing module '~apklib-com.actionbarsherlock_actionbarsherlock_4.2.0': Cannot resolve artifact com.google.android:android
11:36:50 AM Error when importing module '~apklib-com.actionbarsherlock_actionbarsherlock_4.2.0': Cannot resolve artifact commons-logging:commons-logging
11:36:50 AM Error when importing module '~apklib-com.actionbarsherlock_actionbarsherlock_4.2.0': Cannot resolve artifact org.apache.httpcomponents:httpclient
11:36:50 AM Error when importing module '~apklib-com.actionbarsherlock_actionbarsherlock_4.2.0': Cannot resolve artifact org.apache.httpcomponents:httpcore
11:36:50 AM Error when importing module '~apklib-com.actionbarsherlock_actionbarsherlock_4.2.0': Cannot resolve artifact commons-codec:commons-codec
11:36:50 AM Error when importing module '~apklib-com.actionbarsherlock_actionbarsherlock_4.2.0': Cannot resolve artifact org.khronos:opengl-api
11:36:50 AM Error when importing module '~apklib-com.actionbarsherlock_actionbarsherlock_4.2.0': Cannot resolve artifact xerces:xmlParserAPIs
11:36:50 AM Error when importing module '~apklib-com.actionbarsherlock_actionbarsherlock_4.2.0': Cannot resolve artifact xpp3:xpp3
11:36:50 AM Error when importing module '~apklib-com.actionbarsherlock_actionbarsherlock_4.2.0': Cannot resolve artifact org.json:json

 

 

Looking for a resolution to theses issues, since these two (particularly the latter since it means piles of my code have lost the benefit of an IDE) make it likely I have to not use IDEA, which I have up to this point very much enjoyed. :/

 

I have done numerous refreshes, rebuilding of projects, etc, and nothing fixes these issues for me.

 

I will gladly file issues once I verify these are not the result of something I have set up wrong (and if I do, it's still probably an issue that someone this familiar with IDEA, Android and Maven would have this problem).

 

Thanks!

Eugene Kudelevsky JetBrains 192 posts since
Jun 19, 2009
Currently Being Moderated
Mar 13, 2013 9:49 PM in response to: Colin Madere
Re: IDEA + Android + Maven = various library and resource resolution problems

Hello,

 

Sorry about the delay. Could you please attach the iml files you get after full reimporting and your pom.xml files? If you wouldn't like to to attach them here, you may send them to me by email: Eugene.Kudelevsky at jetbrains.com

Eugene Kudelevsky JetBrains 192 posts since
Jun 19, 2009
Currently Being Moderated
Mar 22, 2013 7:36 PM in response to: Colin Madere
Re: IDEA + Android + Maven = various library and resource resolution problems

We've made lots of fixes in the code importing apklib dependencies from Maven, please try to use the latest 12.1 EAP http://confluence.jetbrains.com/display/IDEADEV/IDEA+12.1+EAP

More Like This

  • Retrieving data ...