0

我試圖編譯Android項目生產與Maven .apk文件(我沒有使用過Android Studio,我使用的IntelliJ IDEA)的Android SDK/Maven的配置問題

1 - 我已經下載這line command tool至極我猜是SDK管理器,我已經提取了一個名爲Android的文件夾,提取結果產生一個名爲工具的文件夾。

2 - 我執行/Android/tools/android.sh,它顯示的SDK管理器並開始下載:

  • Android SDK工具
  • Android SDK中Plataform工具
  • Andoird SDK構建工具
  • 的Android 4.2(API16)

下載完成後,它會創建新的文件夾(我剛剛打造的 「工具」 folde上/ Android的R和 「Android的密鑰庫」):

New folders

3-在〜/ .bashrc的ANDROID PATH我編輯如下:

export ANDROID_HOME='/home/myUser/Android' 
export PATH=$PATH:$ANDROID_HOME/tools 
export PATH=$PATH:$ANDROID_HOME/platform-tools 

問題1:¿是ANDROID_HOME指向SDK路徑?

當我試圖讓「MVN乾淨安裝」我的Android項目中我得到這個錯誤:

[INFO] /usr/lib/jvm/java-7-oracle/jre/bin/java [-Xmx1024M, -jar, /home/nb022/Android/build-tools/22.0.1/lib/dx.jar, --dex, --output=/home/nb022/workspace/cl.claro/android/antica-sessmobile-android2/target/classes.dex, /home/nb022/.m2/repository/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar, /home/nb022/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar, /home/nb022/.m2/repository/antica/external/cordova/3.7.2/cordova-3.7.2.jar, /home/nb022/workspace/cl.claro/android/antica-sessmobile-android2/target/classes, /home/nb022/.m2/repository/commons-pool/commons-pool/1.3/commons-pool-1.3.jar, /home/nb022/.m2/repository/antica/base/antica-base-commons/4.16/antica-base-commons-4.16-jdk6.jar, /home/nb022/.m2/repository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar, /home/nb022/.m2/repository/ch/acra/acra/4.5.0/acra-4.5.0.jar, /home/nb022/.m2/repository/de/mindpipe/android/android-logging-log4j/1.0.3/android-logging-log4j-1.0.3.jar, /home/nb022/.m2/repository/com/google/android/android/4.1.1.4/android-4.1.1.4.jar, /home/nb022/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar, /home/nb022/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar, /home/nb022/.m2/repository/org/apache/velocity/velocity/1.7/velocity-1.7.jar, /home/nb022/.m2/repository/org/json/json/20080701/json-20080701.jar, /home/nb022/.m2/repository/antica/core/antica-core-mobile/4.75/antica-core-mobile-4.75.jar, /home/nb022/.m2/repository/xpp3/xpp3/1.1.4c/xpp3-1.1.4c.jar, /home/nb022/.m2/repository/org/khronos/opengl-api/gl1.1-android-2.1_r1/opengl-api-gl1.1-android-2.1_r1.jar, /home/nb022/.m2/repository/xerces/xmlParserAPIs/2.6.2/xmlParserAPIs-2.6.2.jar] 
[INFO] warning: Ignoring InnerClasses attribute for an anonymous inner class 
[INFO] (org.apache.commons.logging.impl.LogFactoryImpl$1) that doesn't come with an 
[INFO] associated EnclosingMethod attribute. This class was probably produced by a 
[INFO] compiler that did not target the modern .class file format. The recommended 
[INFO] solution is to recompile the class from source, using an up-to-date compiler 
[INFO] and without specifying any "-target" type options. The consequence of ignoring 
[INFO] this warning is that reflective operations on this class will incorrectly 
[INFO] indicate that it is *not* an inner class. 
[INFO] warning: Ignoring InnerClasses attribute for an anonymous inner class 
[INFO] (org.apache.commons.logging.impl.LogFactoryImpl$2) that doesn't come with an 
[INFO] associated EnclosingMethod attribute. This class was probably produced by a 
[INFO] compiler that did not target the modern .class file format. The recommended 
[INFO] solution is to recompile the class from source, using an up-to-date compiler 
[INFO] and without specifying any "-target" type options. The consequence of ignoring 
[INFO] this warning is that reflective operations on this class will incorrectly 
[INFO] indicate that it is *not* an inner class. 
[INFO] warning: Ignoring InnerClasses attribute for an anonymous inner class 
[INFO] (org.apache.commons.logging.impl.LogFactoryImpl$3) that doesn't come with an 
[INFO] associated EnclosingMethod attribute. This class was probably produced by a 
[INFO] compiler that did not target the modern .class file format. The recommended 
[INFO] solution is to recompile the class from source, using an up-to-date compiler 
[INFO] and without specifying any "-target" type options. The consequence of ignoring 
[INFO] this warning is that reflective operations on this class will incorrectly 
[INFO] indicate that it is *not* an inner class. 
[INFO] warning: Ignoring InnerClasses attribute for an anonymous inner class 
[INFO] (org.apache.commons.logging.impl.SimpleLog$1) that doesn't come with an 
[INFO] associated EnclosingMethod attribute. This class was probably produced by a 
[INFO] compiler that did not target the modern .class file format. The recommended 
[INFO] solution is to recompile the class from source, using an up-to-date compiler 
[INFO] and without specifying any "-target" type options. The consequence of ignoring 
[INFO] this warning is that reflective operations on this class will incorrectly 
[INFO] indicate that it is *not* an inner class. 
[INFO] warning: Ignoring InnerClasses attribute for an anonymous inner class 
[INFO] (org.apache.commons.logging.impl.WeakHashtable$1) that doesn't come with an 
[INFO] associated EnclosingMethod attribute. This class was probably produced by a 
[INFO] compiler that did not target the modern .class file format. The recommended 
[INFO] solution is to recompile the class from source, using an up-to-date compiler 
[INFO] and without specifying any "-target" type options. The consequence of ignoring 
[INFO] this warning is that reflective operations on this class will incorrectly 
.... 

NFO] and without specifying any "-target" type options. The consequence of ignoring 
[INFO] this warning is that reflective operations on this class will incorrectly 
[INFO] indicate that it is *not* an inner class. 
[INFO] 
[INFO] trouble processing "javax/xml/namespace/QName.class": 
[INFO] 
[INFO] Ill-advised or mistaken usage of a core class (java.* or javax.*) 
[INFO] when not building a core library. 
[INFO] 
[INFO] This is often due to inadvertently including a core library file 
[INFO] in your application's project, when using an IDE (such as 
[INFO] Eclipse). If you are sure you're not intentionally defining a 
[INFO] core class, then this is the most likely explanation of what's 
[INFO] going on. 
[INFO] 
[INFO] However, you might actually be trying to define a class in a core 
[INFO] namespace, the source of which you may have taken, for example, 
[INFO] from a non-Android virtual machine project. This will most 
[INFO] assuredly not work. At a minimum, it jeopardizes the 
[INFO] compatibility of your app with future versions of the platform. 
[INFO] It is also often of questionable legality. 
[INFO] 
[INFO] If you really intend to build a core library -- which is only 
[INFO] appropriate as part of creating a full virtual machine 
[INFO] distribution, as opposed to compiling an application -- then use 
[INFO] the "--core-library" option to suppress this error message. 
[INFO] 
[INFO] If you go ahead and use "--core-library" but are in fact 
[INFO] building an application, then be forewarned that your application 
[INFO] will still fail to build or run, at some point. Please be 
[INFO] prepared for angry customers who find, for example, that your 
[INFO] application ceases to function once they upgrade their operating 
[INFO] system. You will be to blame for this problem. 
[INFO] 
[INFO] If you are legitimately using some code that happens to be in a 
[INFO] core package, then the easiest safe alternative you have is to 
[INFO] repackage that code. That is, move the classes in question into 
[INFO] your own package namespace. This means that they will never be in 
[INFO] conflict with core system classes. JarJar is a tool that may help 
[INFO] you in this endeavor. If you find that you cannot do this, then 
[INFO] that is an indication that the path you are on will ultimately 
[INFO] lead to pain, suffering, grief, and lamentation. 
[INFO] 
[INFO] 1 error; aborting 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 19.901s 
[INFO] Finished at: Fri Feb 24 14:46:58 CLT 2017 
[INFO] Final Memory: 22M/218M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.6.1:dex (default-dex) on project antica-sessmobile-android2: MojoExecutionException: ANDROID-040-001: Could not execute: Command = /bin/sh -c cd /home/nb022/workspace/cl.claro/android/antica-sessmobile-android2 && /usr/lib/jvm/java-7-oracle/jre/bin/java -Xmx1024M -jar /home/nb022/Android/build-tools/22.0.1/lib/dx.jar --dex --output=/home/nb022/workspace/cl.claro/android/antica-sessmobile-android2/target/classes.dex /home/nb022/.m2/repository/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar /home/nb022/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar /home/nb022/.m2/repository/antica/external/cordova/3.7.2/cordova-3.7.2.jar /home/nb022/workspace/cl.claro/android/antica-sessmobile-android2/target/classes /home/nb022/.m2/repository/commons-pool/commons-pool/1.3/commons-pool-1.3.jar /home/nb022/.m2/repository/antica/base/antica-base-commons/4.16/antica-base-commons-4.16-jdk6.jar /home/nb022/.m2/repository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar /home/nb022/.m2/repository/ch/acra/acra/4.5.0/acra-4.5.0.jar /home/nb022/.m2/repository/de/mindpipe/android/android-logging-log4j/1.0.3/android-logging-log4j-1.0.3.jar /home/nb022/.m2/repository/com/google/android/android/4.1.1.4/android-4.1.1.4.jar /home/nb022/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar /home/nb022/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar /home/nb022/.m2/repository/org/apache/velocity/velocity/1.7/velocity-1.7.jar /home/nb022/.m2/repository/org/json/json/20080701/json-20080701.jar /home/nb022/.m2/repository/antica/core/antica-core-mobile/4.75/antica-core-mobile-4.75.jar /home/nb022/.m2/repository/xpp3/xpp3/1.1.4c/xpp3-1.1.4c.jar /home/nb022/.m2/repository/org/khronos/opengl-api/gl1.1-android-2.1_r1/opengl-api-gl1.1-android-2.1_r1.jar /home/nb022/.m2/repository/xerces/xmlParserAPIs/2.6.2/xmlParserAPIs-2.6.2.jar, Result = 1 -> [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. 

項目的POM包含此插件:

<plugin> 
      <groupId>com.jayway.maven.plugins.android.generation2</groupId> 
      <artifactId>android-maven-plugin</artifactId> 
      <executions> 
       <execution> 
       <id>manifest-version</id> 
       <goals> 
        <goal>manifest-update</goal> 
       </goals> 
       <configuration> 
        <manifest> 
        <versionCodeAutoIncrement>false</versionCodeAutoIncrement> 
        <versionName>${project.version}</versionName> 
        </manifest> 
       </configuration> 
       </execution> 
      </executions> 
      <configuration> 
       <assetsDirectory>assets</assetsDirectory> 
       <resourceDirectory>res</resourceDirectory> 
       <sdk> 
       <platform>16</platform> 
       </sdk> 
      </configuration> 
      <extensions>true</extensions> 
      <version>3.6.1</version> 
      </plugin> 

這是的清單項目(android:minSdkVersion =「8」android:targetSdkVersion =「16」):

<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:hardwareAccelerated="true" android:installLocation="internalOnly" android:versionCode="305" android:versionName="2.2.4" android:windowSoftInputMode="adjustPan" package="cl.myApp"> 

    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true"/> 

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 
    <uses-permission android:name="android.permission.INTERNET"/> 
    <uses-permission android:name="android.permission.GET_TASKS"/> 
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> 
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/> 
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/> 

    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16"/> 

    <application android:allowBackup="true" android:hardwareAccelerated="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:name="com.myApp.SessMobileApplication"> 

     <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:excludeFromRecents="true" android:label="@string/app_name" android:name="com.myApp.ClaroSessMobile" android:process=":core" android:theme="@android:style/Theme.Black.NoTitleBar"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN"/> 
       <category android:name="android.intent.category.LAUNCHER"/> 
      </intent-filter> 
     </activity> 

     <activity android:label="@string/app_name" android:launchMode="singleInstance" android:name="cl.MyOrg.core.MyApp.activity.SessMobileDialog" android:process=":core" android:theme="@android:style/Theme.Dialog"/> 

     <activity android:name="com.myApp.SplashIntent"/> 
     <activity android:name="com.myApp.ErrorIntent"/> 
     <activity android:name="com.myApp.ErrorNetworkIntent"/> 


     <receiver android:enabled="true" android:exported="true" android:name="cl.MyOrg.core.MyApp.receiver.SessMobileActionReceiver" android:process=":core"> 
      <intent-filter> 
       <action android:name="android.intent.action.BOOT_COMPLETED"/> 
       <action android:name="android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE"/> 
      </intent-filter> 
      <intent-filter> 
       <action android:name="android.intent.action.PACKAGE_REPLACED"/> 
       <data android:scheme="package"/> 
      </intent-filter> 
     </receiver> 

     <service android:name="cl.MyOrg.core.MyApp.services.SessMobileCore" android:process=":core"/> 

     <service android:name="cl.MyOrg.core.MyApp.services.SessMobileNotifier" android:process=":core"> 

     </service> 
    </application> 
</manifest> 

希望你們可以h用這個錯誤幫我一下。目前我使用:

的Apache Maven的3.0.5 Maven的家:/usr/local/apache-maven-3.0.5 Java版本:1.7.0_80,供應商:Oracle公司的Java 家:在/ usr/lib/jvm/java-7-oracle/jre 默認語言環境:es_CL,平臺編碼:UTF-8 操作系統名稱:「linux」,版本:「4.4.0-21-generic」,arch:「amd64」,family :「unix」

IntelliJ IDEA。

+0

最新的Android工具需要Java 8運行。 Java 7不再受支持。 – CrazyCoder

+0

@CrazyCoder請檢查我的編輯。我現在正在使用BuildTools 21。 –

回答

0

我解決這個問題,dowgrading編譯工具的25版本(安卓/累積工具)23.0.3和settign依賴範圍提供

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