Moumou
Moumou

Reputation: 1532

Dexguard with Maven and Android Studio doesn't work

I am taking over a project, an Android app, which was developed on Eclipse with the ADT plugin. It also uses maven3, and dexguard to obfuscate code.

As I usually work with Android Studio (AS) I imported the old project in AS. Everything works fine except for Dexguard.

Whenever I want to run the project I get an error saying : No implementation for org.eclipse.aether.impl.VersionResolver was bound.

Here is the full error message:

[ERROR] Failed to execute goal com.saikoa.dexguard.maven:dexguard-maven-plugin:5.5.32:generate-sources (default-generate-sources) on project app-android-genmsecure: Execution default-generate-sources of goal com.saikoa.dexguard.maven:dexguard-maven-plugin:5.5.32:generate-sources failed: Unable to load the mojo 'generate-sources' (or one of its required components) from the plugin 'com.saikoa.dexguard.maven:dexguard-maven-plugin:5.5.32': com.google.inject.ProvisionException: Guice provision errors:
[ERROR] 
[ERROR] 1) No implementation for org.eclipse.aether.impl.VersionResolver was bound.
[ERROR] while locating org.eclipse.aether.internal.impl.DefaultRepositorySystem
[ERROR] at ClassRealm[plugin>com.saikoa.dexguard.maven:dexguard-maven-plugin:5.5.32, parent: sun.misc.Launcher$AppClassLoader@1efde7ba]
[ERROR] at ClassRealm[plugin>com.saikoa.dexguard.maven:dexguard-maven-plugin:5.5.32, parent: sun.misc.Launcher$AppClassLoader@1efde7ba]
[ERROR] while locating org.eclipse.aether.RepositorySystem
[ERROR] while locating com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo
[ERROR] at ClassRealm[plugin>com.saikoa.dexguard.maven:dexguard-maven-plugin:5.5.32, parent: sun.misc.Launcher$AppClassLoader@1efde7ba]
[ERROR] while locating org.apache.maven.plugin.Mojo annotated with @com.google.inject.name.Named(value=com.saikoa.dexguard.maven:dexguard-maven-plugin:5.5.32:generate-sources)
[ERROR] 
[ERROR] 1 error
[ERROR] role: org.apache.maven.plugin.Mojo
[ERROR] roleHint: com.saikoa.dexguard.maven:dexguard-maven-plugin:5.5.32:generate-sources
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.saikoa.dexguard.maven:dexguard-maven-plugin:5.5.32:generate-sources (default-generate-sources) on project app-android-genmsecure: Execution default-generate-sources of goal com.saikoa.dexguard.maven:dexguard-maven-plugin:5.5.32:generate-sources failed: Unable to load the mojo 'generate-sources' (or one of its required components) from the plugin 'com.saikoa.dexguard.maven:dexguard-maven-plugin:5.5.32'
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-generate-sources of goal com.saikoa.dexguard.maven:dexguard-maven-plugin:5.5.32:generate-sources failed: Unable to load the mojo 'generate-sources' (or one of its required components) from the plugin 'com.saikoa.dexguard.maven:dexguard-maven-plugin:5.5.32'
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:115)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 20 more
Caused by: org.apache.maven.plugin.PluginContainerException: Unable to load the mojo 'generate-sources' (or one of its required components) from the plugin 'com.saikoa.dexguard.maven:dexguard-maven-plugin:5.5.32'
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:488)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:92)
    ... 21 more
Caused by: org.codehaus.plexus.component.repository.exception.ComponentLookupException: com.google.inject.ProvisionException: Guice provision errors:

1) No implementation for org.eclipse.aether.impl.VersionResolver was bound.
  while locating org.eclipse.aether.internal.impl.DefaultRepositorySystem
  at ClassRealm[plugin>com.saikoa.dexguard.maven:dexguard-maven-plugin:5.5.32, parent: sun.misc.Launcher$AppClassLoader@1efde7ba]
  at ClassRealm[plugin>com.saikoa.dexguard.maven:dexguard-maven-plugin:5.5.32, parent: sun.misc.Launcher$AppClassLoader@1efde7ba]
  while locating org.eclipse.aether.RepositorySystem
  while locating com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo
  at ClassRealm[plugin>com.saikoa.dexguard.maven:dexguard-maven-plugin:5.5.32, parent: sun.misc.Launcher$AppClassLoader@1efde7ba]
  while locating org.apache.maven.plugin.Mojo annotated with @com.google.inject.name.Named(value=com.saikoa.dexguard.maven:dexguard-maven-plugin:5.5.32:generate-sources)

1 error
      role: org.apache.maven.plugin.Mojo
  roleHint: com.saikoa.dexguard.maven:dexguard-maven-plugin:5.5.32:generate-sources
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:257)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:245)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:455)
    ... 22 more
Caused by: com.google.inject.ProvisionException: Guice provision errors:

1) No implementation for org.eclipse.aether.impl.VersionResolver was bound.
  while locating org.eclipse.aether.internal.impl.DefaultRepositorySystem
  at ClassRealm[plugin>com.saikoa.dexguard.maven:dexguard-maven-plugin:5.5.32, parent: sun.misc.Launcher$AppClassLoader@1efde7ba]
  at ClassRealm[plugin>com.saikoa.dexguard.maven:dexguard-maven-plugin:5.5.32, parent: sun.misc.Launcher$AppClassLoader@1efde7ba]
  while locating org.eclipse.aether.RepositorySystem
  while locating com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo
  at ClassRealm[plugin>com.saikoa.dexguard.maven:dexguard-maven-plugin:5.5.32, parent: sun.misc.Launcher$AppClassLoader@1efde7ba]
  while locating org.apache.maven.plugin.Mojo annotated with @com.google.inject.name.Named(value=com.saikoa.dexguard.maven:dexguard-maven-plugin:5.5.32:generate-sources)

1 error
    at com.google.inject.internal.InjectorImpl$3.get(InjectorImpl.java:974)
    at com.google.inject.Scopes$1$1.get(Scopes.java:59)
    at org.sonatype.guice.bean.locators.LazyBeanEntry.getValue(LazyBeanEntry.java:83)
    at org.sonatype.guice.plexus.locators.LazyPlexusBean.getValue(LazyPlexusBean.java:49)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:253)
    ... 24 more
[ERROR]  

And the pom.xml file :

<?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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>[HIDDEN]</groupId>
    <artifactId>[HIDDEN]</artifactId>
    <version>1.9.0-SNAPSHOT</version>
    <packaging>apk</packaging>
    <name>[HIDDEN]</name>

    <!-- SCM tag for maven releases -->
    <scm>
        <connection>[HIDDEN]</connection>
      <tag>HEAD</tag>
  </scm>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- Android -->
        <android.sdk.path>${env.ANDROID_HOME}</android.sdk.path>
        <android.sdk.platform>17</android.sdk.platform>
    </properties>

    <distributionManagement>
        <!-- Maven Repository to deploy artifact : Nexus -->
        <repository>
            <id>releases</id>
            <name>Internal Releases</name>
            <url>[HIDDEN]</url>
        </repository>
        <snapshotRepository>
            <id>snapshots</id>
            <name>Internal Snapshots</name>
            <url>[HIDDEN]</url>
        </snapshotRepository>
    </distributionManagement>

    <dependencies>
        <!-- Android dependencies -->
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>4.1.1.4</version>
            <scope>provided</scope>
        </dependency>

        <!-- External dependencies -->
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.2</version>
        </dependency>

        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.5</version>
        </dependency>
    </dependencies>

    <build>

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.saikoa.dexguard.maven</groupId>
                    <artifactId>dexguard-maven-plugin</artifactId>
                    <version>5.5.32</version>
                    <extensions>true</extensions>
                </plugin>
                <!-- <plugin> -->
                <!-- <groupId>com.jayway.maven.plugins.android.generation2</groupId> -->
                <!-- <artifactId>android-maven-plugin</artifactId> -->
                <!-- <version>3.8.0</version> -->
                <!-- </plugin> -->
            </plugins>
        </pluginManagement>

        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <groupId>com.saikoa.dexguard.maven</groupId>
                <artifactId>dexguard-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <dexguardConfig>dexguard-project-debug.txt</dexguardConfig>
                    <release>false</release>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.4.3</version>
                <configuration>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <execution>
                        <id>add-source</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>src/main/java</source>
                                <source>src/main/native</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.5</version>
                        <configuration>
                            <!-- During release:perform, enable the "release" profile -->
                            <releaseProfiles>release</releaseProfiles>
                        </configuration>
            </plugin>
             <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                 <version>2.10.3</version>
                <configuration>
                    <failOnError>false</failOnError>
                </configuration>
            </plugin>

        </plugins>
    </build>

    <profiles>
        <profile>
            <!-- Profile release : will be activated during release. Will obfuscate and process the code -->
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.saikoa.dexguard.maven</groupId>
                        <artifactId>dexguard-maven-plugin</artifactId>
                        <extensions>true</extensions>
                        <configuration>
                            <release>true</release>
                            <dexguardConfig>dexguard-project-release.txt</dexguardConfig>
                        </configuration>
                    </plugin>

                </plugins>
            </build>
        </profile>
        <profile>
            <!-- Customer profile, to rename the package name. -->
            <id>ncr</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.saikoa.dexguard.maven</groupId>
                        <artifactId>dexguard-maven-plugin</artifactId>
                        <configuration>
                            <renameManifestPackage>[HIDDEN]</renameManifestPackage>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <!-- Customer profile, to rename the package name. -->
            <id>[HIDDEN]</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.saikoa.dexguard.maven</groupId>
                        <artifactId>dexguard-maven-plugin</artifactId>
                        <configuration>
                            <renameManifestPackage>[HIDDEN]</renameManifestPackage>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

Tell me if you need anything else.

Thanks for your help.

Upvotes: 2

Views: 792

Answers (1)

Barend
Barend

Reputation: 17419

Aether is the Eclipse library for working with Maven repositories within Eclipse. I suppose it makes sense that this system would not be available in Android Studio. I don't have a solution to that immediate problem. I suppose it may be possible to write an IntellIJ plugin that exposes Aether, but really, that's way unreasonable :).

Converting a Maven project to Gradle should be fairly straight forward, since the directory structure is already there and Gradle can handle custom Maven repositories.

DexGuard has good Gradle support, we're using it at my place of work and it's painless. My advice is to just upgrade the build system from Maven to Gradle and never look back.

Upvotes: 1

Related Questions