注入错误:com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo

时间:2014-12-30 05:35:25

标签: android maven

我正在尝试使用Apache Maven 3.2.1和Java版本1.7.0_55在Mac(OS版本Yosemite)上生成基本的Android项目。我按照http://stand.spree.de/wiki_details_maven_archetypes跟踪了“ANDROID-RELEASE ARCHETYPE”,如下所示:

mvn archetype:generate -DarchetypeArtifactId=android-release -DarchetypeGroupId=de.akquinet.android.archetypes -DarchetypeVersion=1.0.11 -DgroupId=com.uluvit -DartifactId=UluvitAndroid -Dpackage=com.uluvit 

我从UluvitAndroid目录中的mvn clean install收到以下错误:

[INFO] Scanning for projects...
Downloading: http://repo.maven.apache.org/maven2/com/jayway/maven/plugins/android/generation2/android-maven-plugin/3.6.0/android-maven-plugin-3.6.0.pom
Downloaded: http://repo.maven.apache.org/maven2/com/jayway/maven/plugins/android/generation2/android-maven-plugin/3.6.0/android-maven-plugin-3.6.0.pom (21 KB at 25.7 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/com/simpligility/maven/progressive-company-super-pom/0.6.0/progressive-company-super-pom-0.6.0.pom
Downloaded: http://repo.maven.apache.org/maven2/com/simpligility/maven/progressive-company-super-pom/0.6.0/progressive-company-super-pom-0.6.0.pom (24 KB at 86.0 KB/sec)

...

Downloading: http://repo.maven.apache.org/maven2/org/json/json/20080701/json-20080701.jar
Downloaded: http://repo.maven.apache.org/maven2/org/json/json/20080701/json-20080701.jar (37 KB at 48.9 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpcore/4.0.1/httpcore-4.0.1.jar (169 KB at 87.7 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/xpp3/xpp3/1.1.4c/xpp3-1.1.4c.jar (118 KB at 69.4 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpclient/4.0.1/httpclient-4.0.1.jar (285 KB at 104.5 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/com/google/android/android/4.1.1.4/android-4.1.1.4.jar (12645 KB at 199.2 KB/sec)
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ UluvitAndroid ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:copy-resources (default) @ UluvitAndroid ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/mosofsky/Developer/UluvitAndroid/UluvitAndroid/src/templates/res
[INFO] 
[INFO] --- android-maven-plugin:3.6.0:generate-sources (default-generate-sources) @ UluvitAndroid ---
[WARNING] Error injecting: com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo
java.lang.NoClassDefFoundError: Lorg/sonatype/aether/RepositorySystem;
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Class.java:2397)
    at java.lang.Class.getDeclaredFields(Class.java:1806)
    at com.google.inject.spi.InjectionPoint.getInjectionPoints(InjectionPoint.java:661)
    at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:366)
    at com.google.inject.internal.ConstructorBindingImpl.getInternalDependencies(ConstructorBindingImpl.java:165)
    at com.google.inject.internal.InjectorImpl.getInternalDependencies(InjectorImpl.java:609)
    at com.google.inject.internal.InjectorImpl.cleanup(InjectorImpl.java:565)
    at com.google.inject.internal.InjectorImpl.initializeJitBinding(InjectorImpl.java:551)
    at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:865)
    at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:790)
    at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:278)
    at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:210)
    at com.google.inject.internal.InjectorImpl.getProviderOrThrow(InjectorImpl.java:986)
    at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1019)
    at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:982)
    at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1032)
    at org.eclipse.sisu.space.AbstractDeferredClass.get(AbstractDeferredClass.java:48)
    at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:86)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:55)
    at com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.java:70)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:100)
    at org.eclipse.sisu.plexus.PlexusLifecycleManager.onProvision(PlexusLifecycleManager.java:133)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:109)
    at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:55)
    at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:68)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:47)
    at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:997)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1047)
    at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:993)
    at com.google.inject.Scopes$1$1.get(Scopes.java:59)
    at org.eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.java:82)
    at org.eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.java:51)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:260)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:252)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:462)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:120)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    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:108)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
    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:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.lang.ClassNotFoundException: org.sonatype.aether.RepositorySystem
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:235)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
    ... 57 more
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] UluvitAndroid - Parent ............................ SUCCESS [  0.228 s]
[INFO] UluvitAndroid - Application ....................... FAILURE [01:05 min]
[INFO] UluvitAndroid-it - Integration tests .............. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:36 min
[INFO] Finished at: 2014-12-29T21:11:43-08:00
[INFO] Final Memory: 11M/91M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.6.0:generate-sources (default-generate-sources) on project UluvitAndroid: Execution default-generate-sources of goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.6.0:generate-sources failed: A required class was missing while executing com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.6.0:generate-sources: Lorg/sonatype/aether/RepositorySystem;

由于archetypeGroupId=de.akquinet.android.archetypes带有archetypeArtifactId=android-release,我无法在stackoverflow上找到此错误的任何答案。

3 个答案:

答案 0 :(得分:3)

迈克尔和弗雷德解决方案的结合使我与Maven 3.3.3一起工作:

      <plugin>
        <groupId>com.jayway.maven.plugins.android.generation2</groupId>
        <artifactId>android-maven-plugin</artifactId>
        <version>3.8.2</version>
        <extensions>true</extensions>
        <configuration>
          <sdk>
            <platform>17</platform>
          </sdk>
        </configuration>
      </plugin>

平台17是我在Android SDK中安装的API版本。

答案 1 :(得分:2)

我在我的pom.xml中解决了这个问题:

<properties>
    <android.maven.version>3.8.2</android.maven.version>
</properties>

答案 2 :(得分:1)

根据https://code.google.com/p/maven-android-plugin/issues/detail?id=395,可能的解决办法似乎是从Maven 3.2.5降级到3.0.5。

这似乎让我超越了上面的错误但后来遇到了另一个问题:Error building Android project with Maven: Platform/API level 16 not available