无法设置Android maven项目。构建失败

时间:2015-02-02 16:56:37

标签: android maven intellij-idea maven-sdk-deployer

我是maven的新手,我正在尝试使用maven设置android项目。

我为java,maven和android sdk设置了路径环境。

由于某些原因,我在尝试mvn clean installmvn clean然后mvn install时,在Maven SDK部署程序中遇到构建失败。

现在,设置过程在API 2.2处停止,并且跳过所有其他步骤。

现在,当我执行mvn clean时,我会得到以下列表:

反应堆摘要:

Maven Android SDK Deployer ......................... SUCCESS [  0.062 s]
Android Platforms .................................. SUCCESS [  0.003 s]
Android Platform 1.5 API 3 ......................... SUCCESS [  0.002 s]
Android Platform 1.6 API 4 ......................... SUCCESS [  0.008 s]
Android Platform 2.1 API 7 ......................... SUCCESS [  0.004 s]
Android Platform 2.2 API 8 ......................... SUCCESS [  0.002 s]
Android Platform 2.3.3 API 10 ...................... SUCCESS [  0.006 s]
Android Platform 3.0 API 11 ........................ SUCCESS [  0.003 s]
Android Platform 3.1 API 12 ........................ SUCCESS [  0.003 s]
Android Platform 3.2 API 13 ........................ SUCCESS [  0.003 s]
Android Platform 4.0 API 14 ........................ SUCCESS [  0.006 s]
Android Platform 4.0.3 API 15 ...................... SUCCESS [  0.006 s]
Android Platform 4.1 API 16 ........................ SUCCESS [  0.003 s]
Android Platform 4.2 API 17 ........................ SUCCESS [  0.008 s]
Android Platform 4.3 API 18 ........................ SUCCESS [  0.002 s]
Android Platform 4.4 API 19 ........................ SUCCESS [  0.003 s]
Android Platform 4.4W API 20 ....................... SUCCESS [  0.004 s]
Android Platform 5.0 API 21 ........................ SUCCESS [  0.002 s]
Android Add-Ons .................................... SUCCESS [  0.003 s]
Android Add-On Google Platform 1.5 API 3 (Maps) .... SUCCESS [  0.012 s]
Android Add-On Google Platform 1.6 API 4 (Maps) .... SUCCESS [  0.003 s]
Android Add-On Google Platform 2.1 API 7 (Maps) .... SUCCESS [  0.006 s]
Android Add-On Google Platform 2.2 API 8 (Maps) .... SUCCESS [  0.002 s]
Android Add-On Google Platform 2.3.3 API 10 (Maps and USB) SUCCESS [  0.003 s]
Android Add-On Google Platform 3.0 API 11 (Maps) ... SUCCESS [  0.003 s]
Android Add-On Google Platform 3.1 API 12 (Maps and USB) SUCCESS [  0.011 s]
Android Add-On Google Platform 3.2 API 13 (Maps and USB) SUCCESS [  0.003 s]
Android Add-On Google Platform 4.0 API 14 (Maps and USB) SUCCESS [  0.003 s]
Android Add-On Google Platform 4.0.3 API 15 (Maps and USB) SUCCESS [  0.008 s]
Android Add-On Google Platform 4.1 API 16 (Maps and USB) SUCCESS [  0.001 s]
Android Add-On Google Platform 4.2 API 17 (Maps and USB) SUCCESS [  0.002 s]
Android Add-On Google Platform 4.3 API 18 (Maps and USB) SUCCESS [  0.003 s]
Android Add-On Google Platform 4.4 API 19 (Maps and USB) SUCCESS [  0.010 s]
Android Add-On Google Platform 5.0 API 21 (Maps and USB) SUCCESS [  0.002 s]
Google Glass Development Kit (GDK) API 19 .......... SUCCESS [  0.003 s]
Android Extras ..................................... SUCCESS [  0.003 s]
Android Compatibility Extra V4 ..................... SUCCESS [  0.002 s]
Android Compatibility Extra V7 Gridlayout Library .. SUCCESS [  0.022 s]
Android Compatibility Extra V7 AppCompat Library ... SUCCESS [  0.003 s]
Android Compatibility Extra V7 Mediarouter Library . SUCCESS [  0.002 s]
Android Compatibility Extra V13 .................... SUCCESS [  0.002 s]
Android Google Play Services Extra ................. SUCCESS [  0.001 s]
Android Google Play Services Extra for Froyo ....... SUCCESS [  0.000 s]
Android Google Play Licensing Extra ................ SUCCESS [  0.002 s]
Android Extras - Apk Expansion ..................... SUCCESS [  0.001 s]
Android Google Play APK Expansion Extra - ZIP ...... SUCCESS [  0.001 s]
Android Google Play APK Expansion Extra - Downloader SUCCESS [  0.001 s]
Android MultiDex ................................... SUCCESS [  0.001 s]
Repositories ....................................... SUCCESS [  0.001 s]
Google M2Repository ................................ SUCCESS [  0.000 s]
Android M2Repository ............................... SUCCESS [  0.001 s]
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 1.867 s
Finished at: 2015-02-02T11:42:53-05:00
Final Memory: 16M/45M
------------------------------------------------------------------------

然后我尝试mvn install我得到了这个:

[INFO] Reactor Summary:
[INFO]
[INFO] Maven Android SDK Deployer ......................... SUCCESS [  0.255 s]
[INFO] Android Platforms .................................. SUCCESS [  0.008 s]
[INFO] Android Platform 1.5 API 3 ......................... SUCCESS [  0.166 s]
[INFO] Android Platform 1.6 API 4 ......................... FAILURE [  0.003 s]
[INFO] Android Platform 2.1 API 7 ......................... SKIPPED
[INFO] Android Platform 2.2 API 8 ......................... SKIPPED

Android平台1.6 API 4之后的所有文件都被跳过,因此我必须使用mvn install -p verno手动安装其他平台。

为了调试这个过程,我使用了`mvn install -e'并得到以下错误日志:

[ERROR] Failed to execute goal org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:read-project-properties (default) on project android-4: Propertie
s file not found: G:\Android SDK\adt-bundle-windows-x86_64-20140702\sdk\platforms\android-4\source.properties -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:read-project-prop
erties (default) on project android-4: Properties file not found: G:\Android SDK\adt-bundle-windows-x86_64-20140702\sdk\platforms\android-4\source.pro
perties
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
        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:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
        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:216)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        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: org.apache.maven.plugin.MojoExecutionException: Properties file not found: G:\Android SDK\adt-bundle-windows-x86_64-20140702\sdk\platforms\
android-4\source.properties
        at org.codehaus.mojo.properties.ReadPropertiesMojo.execute(ReadPropertiesMojo.java:110)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        ... 19 more

不确定我为什么会收到此错误。我还有pom.xml设置来构建一个新项目,但我不能继续这样做,除非Maven Android Deployer设置正确。

我想在intellij中导入项目,所以我想学习maven。 我知道我们可以使用eclipse插件导出现有项目,但我想知道intellij IDE中maven项目的工作情况。

我在这里做错了什么,或者如果有任何替代步骤要使用maven构建android项目,请告诉我,我真的很感激。

1 个答案:

答案 0 :(得分:1)

错误表明您没有安装API 4。通过SDK Manager安装API 4,然后尝试mvn clean install。如果您只想安装特定的SDK,请使用以下命令:

mvn install -P API_VERSION(用您想要的SDK版本替换API_VERSION。例如:4,21。)