2015-07-03 80 views
0

我開始了一個Android項目,默認情況下它是建立與ANT,我想將它升級到Maven這樣我就可以擺脫我與Android SDK有編譯時間問題,並便於圖書館的導入和管理。我所遇到的問題是:Maven的:從螞蟻遷移Android項目到Maven

1)如何修改build.xml文件,以指導其使用Maven。 2)Maven抱怨文件夾結構不對。

這裏是我的build.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<project name="myapp" default="help"> 
<property file="local.properties"/> 
    <property file="ant.properties"/> 
<property environment="env"/> 
    <condition property="sdk.dir" value="${env.ANDROID_HOME}"> 
     <isset property="env.ANDROID_HOME"/> 
    </condition> 
// and more 

所以我相信我不得不修改ant.properties屬性,我怎麼能建議使用Maven?

這是我在這個項目的父目錄粘貼pom.xml的,但是當我嘗試運行mvn編譯,我得到以下錯誤:

Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:4.0.0-rc.2:generate-sources (default-generate-sources) on project gs-maven-android: 
[ERROR] 
[ERROR] Found files or folders in non-standard locations in the project! 
[ERROR] ....This might be a side-effect of a migration to Android Maven Plugin 4+. 
[ERROR] ....Please observe the warnings for specific files and folders above. 
[ERROR] ....Ideally you should restructure your project. 
[ERROR] ....Alternatively add explicit configuration overrides for files or folders. 
[ERROR] ....Finally you could set failOnNonStandardStructure to false, potentially resulting in other failures. 
[ERROR] -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException 

最後,這裏是POM .xml:

<?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/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>org.hello</groupId> 
    <artifactId>MyAPP</artifactId> 
    <version>1.0</version> 
    <packaging>apk</packaging> 
    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 
    </properties> 

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

    <build> 
     <plugins> 
      <plugin> 
       <groupId>com.jayway.maven.plugins.android.generation2</groupId> 
       <artifactId>android-maven-plugin</artifactId> 
       <version>4.0.0-rc.2</version> 
       <configuration> 
        <sdk> 
         <platform>20</platform> 
        </sdk> 
        <undeployBeforeDeploy>true</undeployBeforeDeploy> 
       </configuration> 
       <extensions>true</extensions> 
      </plugin> 
      <plugin> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>3.1</version> 
       <configuration> 
        <source>1.8</source> 
        <target>1.8</target> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 

</project> 

那麼我在這裏做錯了什麼?你能幫忙的話,我會很高興。我在Ubuntu Linux上使用Intellij Idea。謝謝。

回答

0

請升級到完整版本的版本,然後更新後的錯誤消息。最新版本是4.3.0。

該警告是關於源代碼和其他來源位於在非標準的文件夾。你應該使用標準結構。完整版本將顯示錯誤消息,其中包含所有內容的詳細信息。