我正在尝试编译一个android项目来生成带有maven的.apk(我没有使用Android Studio,我正在使用IntelliJ的想法)
1-我已经下载了这个line command tool我猜是SDK Manager,我在一个名为Android的文件夹中提取,提取结果会生成一个名为tools的文件夹。
2-我执行/Android/tools/android.sh,它显示SDK Manager并开始下载:
下载完成后,它会在/ Android上创建新文件夹(我只是创建“tools”文件夹和“android-keystore”):
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路径?
当我尝试对我的android项目进行'mvn clean install'时,我收到此错误:
[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.
Project的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>
希望你们能帮我解决这个错误。目前我正在使用:
Apache Maven 3.0.5 Maven home:/usr/local/apache-maven-3.0.5 Java版本:1.7.0_80,供应商:Oracle Corporation Java home:/ usr / lib / jvm / java-7-oracle / jre 默认语言环境:es_CL,平台编码:UTF-8 操作系统名称:“linux”,版本:“4.4.0-21-generic”,arch:“amd64”,family:“unix”
IntelliJ IDEA。
答案 0 :(得分:0)
我解决了这个问题,将buildTools(Android / build-tools)的版本从25降级到23.0.3,并将依赖范围设置为提供
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>