Error importing Maven Android Android project to Eclipse with ADT 20-ThrowExceptions

Exception or error:

I’m updated the ADT plugin to the last version (20) and the android-sdk tool. Now when I try to import an existent Android Maven to Eclipse raise the exception An internal error occurred during: "Importing Maven projects".
com/android/io/StreamException
, and creates the eclipse project but not like Android project as before. The previous existent (maven android) projects in the workspace works fine.

The Eclipse full exception trace when import the project is the following:

!ENTRY org.eclipse.osgi 2 1 2012-06-29 19:02:34.421
!MESSAGE NLS unused message: LifecycleMappingPropertyPage_this_message in: org.eclipse.m2e.core.ui.internal.messages

!ENTRY org.eclipse.core.jobs 4 2 2012-06-29 19:03:03.953
!MESSAGE An internal error occurred during: "Importing Maven projects".
!STACK 0
java.lang.NoClassDefFoundError: com/android/io/StreamException
    at me.gladwell.eclipse.m2e.android.project.EclipseAndroidProjectFactory.createAndroidProject(EclipseAndroidProjectFactory.java:17)
    at me.gladwell.eclipse.m2e.android.project.EclipseAndroidProjectFactory.createAndroidProject(EclipseAndroidProjectFactory.java:1)
    at me.gladwell.eclipse.m2e.android.AndroidMavenProjectConfigurator.configure(AndroidMavenProjectConfigurator.java:62)
    at org.eclipse.m2e.core.project.configurator.AbstractLifecycleMapping.configure(AbstractLifecycleMapping.java:109)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:414)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.configureNewMavenProject(ProjectConfigurationManager.java:240)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.importProjects(ProjectConfigurationManager.java:156)
    at org.eclipse.m2e.core.ui.internal.wizards.MavenImportWizard$1.doCreateMavenProjects(MavenImportWizard.java:164)
    at org.eclipse.m2e.core.ui.internal.wizards.AbstractCreateMavenProjectsOperation.run(AbstractCreateMavenProjectsOperation.java:73)
    at org.eclipse.m2e.core.ui.internal.wizards.MavenImportWizard$3.runInWorkspace(MavenImportWizard.java:249)
    at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.ClassNotFoundException: com.android.io.StreamException
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 12 more

Can anybody solves it? Is needed an update of the m2e Android connector?

Update:
This my 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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>your.company</groupId>
    <artifactId>my-android-application</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>apk</packaging>
    <name>my-android-application</name>

    <dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>2.3.3</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>${project.artifactId}</finalName>
        <sourceDirectory>src</sourceDirectory>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <version>3.2.0</version>
                    <extensions>true</extensions>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <configuration>
                    <sdk>
                        <!-- platform or api level (api level 4 = platform 1.6)-->
                        <platform>10</platform>
                    </sdk>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project></project>

Thanks.

How to solve:

This is a known issue with the m2e-android plug-in caused due to changes in the ADT API:

https://github.com/rgladwell/m2e-android/issues/89

Please be patient while we find a fix.


Update: The new 0.4.2 release fixes this issue was released today, please run an Eclipse update (Help -> Check for Updates) and let me know if this resolves your problems.

###

edit: Rather than do this, you might now be better off getting Ricardo’s updated project from github, switching to the adt-20 branch, building with Maven, uninstalling the M2E connector as described below, and installing the new M2E connector from me.gladwell.eclipse.m2e.android.update/target/repository as a local repository, also as described below. Thanks, Ricardo!


I had this problem and couldn’t build my project. The only way I got round it was to downgrade ADT to 18.0.0. I couldn’t find a way of doing this through the SDK Manager etc., so this turned out to be a bit of an ordeal – though I quite probably didn’t do it the most sensible way! Anyway, I thought I’d post what I went through in case it helps anyone. I left out the umpteen Eclipse restarts. 🙂

This was on Eclipse 3.7 on Linux.

  • Get the ADT zip: http://dl.google.com/android/ADT-18.0.0.zip
  • Get the Android SDK Tools archive for your OS: http://dl.google.com/android/android-sdk_r18-linux.tgz (replace linux.tgz with windows.zip or macosx.zip – sorry, Stack Overflow only allows me two links in my post!).
  • Disable automatic software updates: Window -> Preferences -> Install/Update -> Automatic Updates, uncheck ‘Automatically find new updates and notify me’.
  • Uninstall Android SDK Tools: Window -> Android SDK Manager, check Android SDK Tools and click ‘Delete 1 package’.
  • Uninstall ADT: Help -> Install New Software -> What is already installed? -> Installed Software, select all the Android* components and the Android Configurator for M2E and click ‘Uninstall’.
  • Extract ADT-18.0.0.zip and install: Help -> Install New Software -> Add -> Local and browse to where you extracted it. Give the local repository a name and click OK, then select it from the ‘Work with’ drop-down and install the available software from it.
  • Extract the tools directory from the android-sdk_r18 archive into your android-sdks directory.
  • Install Android M2E connector: Preferences -> Maven -> Discovery, click ‘Open Catalog’ then select the connector. Deselect any ADT 20.0 features if prompted.

###

Now the andriod maven connector it’s fixed to works with ADT 20+, only needs to install the update from the following update site: http://rgladwell.github.com/m2e-android/updates/master/

###

Just open your file. XML and tab below the “Graphical Layout” (in the case of eclipse).
You still there locate the Android icon that is located on the top right that details the version that is used in my case was using version 18, I selected version 17 and the error disappeared.

Leave a Reply

Your email address will not be published. Required fields are marked *