Cordova测试应用程序(android) - 在Eclipse中构建和运行,失败了&cordova build'

时间:2015-03-14 13:16:36

标签: android cordova ant

我正在运行 cordova create 的基本cordova示例。 即使将其导入eclipse并且命中运行正常(模拟器或设备),在CLI中使用 cordova build 也会失败。

命令 android ant cordova 在命令行上正常运行。

Java版:

  

java版“1.8.0_40”

Ant版本:

  

2014年5月9日编译的Apache Ant(TM)版本1.9.4

Cordova版本:

  

4.3.0

Android平台版本:

  

已安装的平台:android 3.7.1

主项目和子项目(CordovaLib)都在project.properties中设置为 android-21 。但是我已经尝试了从19到22的每个组合。我也尝试过使用JDK 1.7而不是1.8但是同样的结果。

我已将/ AndroidSDKDirectory / tools / ant /中的ant的build.xml设置为1.8。我也试过1.6和1.7 - 结果相同

错误输出为:

Running command: /media/data/Code/TestCordova/platforms/android/cordova/build 
Buildfile: /media/data/Code/TestCordova/platforms/android/build.xml

-set-mode-check:

-set-debug-files:

-check-env:
[checkenv] Android SDK Tools Revision 24.1.2
[checkenv] Installed at /usr/local/android-sdk-linux

-setup:
 [echo] Project Name: MainActivity
[gettype] Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 21.1.2
 [echo] Resolving Build Target for MainActivity...
[gettarget] Project Target:   Android 5.0.1
[gettarget] API level:        21
 [echo] ----------
 [echo] Creating output directories if needed...
[mkdir] Created dir: /media/data/Code/TestCordova/platforms/android/ant-build/rsObj
[mkdir] Created dir: /media/data/Code/TestCordova/platforms/android/ant-build/rsLibs
 [echo] ----------
 [echo] Resolving Dependencies for MainActivity...
[dependency] Library dependencies:
[dependency] 
[dependency] ------------------
[dependency] Ordered libraries:
[dependency] 
[dependency] ------------------
 [echo] ----------
 [echo] Building Libraries with 'debug'...

nodeps:

-set-mode-check:

-set-debug-files:

-check-env:
[checkenv] Android SDK Tools Revision 24.1.2
[checkenv] Installed at /usr/local/android-sdk-linux

-setup:
 [echo] Project Name: MainActivity
[gettype] Project Type: Android Library

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 21.1.2
 [echo] Switching between debug and non debug build: Deleting previous compilation output...
[delete] Deleting directory /media/data/Code/TestCordova/platforms/android/CordovaLib/ant-build/classes
 [echo] Resolving Build Target for MainActivity...
[gettarget] Project Target:   Android 5.0.1
[gettarget] API level:        21
 [echo] ----------
 [echo] Creating output directories if needed...
[mkdir] Created dir: /media/data/Code/TestCordova/platforms/android/CordovaLib/ant-build/rsObj
[mkdir] Created dir: /media/data/Code/TestCordova/platforms/android/CordovaLib/ant-build/rsLibs
[mkdir] Created dir: /media/data/Code/TestCordova/platforms/android/CordovaLib/ant-build/classes
 [echo] ----------
 [echo] Resolving Dependencies for MainActivity...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency] 
[dependency] ------------------

-code-gen:
[mergemanifest] No changes in the AndroidManifest files.
 [echo] Handling aidl files...
 [aidl] No AIDL files to compile.
 [echo] ----------
 [echo] Handling RenderScript files...
 [echo] ----------
 [echo] Handling Resources...
 [aapt] No changed resources. R.java and Manifest.java untouched.
 [echo] ----------
 [echo] Handling BuildConfig class...
[buildconfig] Build type changed: Generating new BuildConfig class.

-pre-compile:

-compile:
[javac] Compiling 98 source files to /media/data/Code/TestCordova/platforms/android/CordovaLib/ant-build/classes
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
 [echo] Creating library output jar file...
  [jar] Building jar: /media/data/Code/TestCordova/platforms/android/CordovaLib/ant-build/classes.jar

-post-compile:

-obfuscate:

-dex:
 [echo] Library project: do not convert bytecode...

-crunch:
[crunch] Crunching PNG Files in source dir: /media/data/Code/TestCordova/platforms/android/CordovaLib/res
[crunch] To destination dir: /media/data/Code/TestCordova/platforms/android/CordovaLib/ant-build/res
[crunch] Crunched 0 PNG files to update cache

-package-resources:
 [echo] Library project: do not package resources...

-package:
 [echo] Library project: do not package apk...

-post-package:

-do-debug:
 [echo] Library project: do not create apk...
[propertyfile] Updating property file: /media/data/Code/TestCordova/platforms/android/CordovaLib/ant-build/build.prop
[propertyfile] Updating property file: /media/data/Code/TestCordova/platforms/android/CordovaLib/ant-build/build.prop
[propertyfile] Updating property file: /media/data/Code/TestCordova/platforms/android/CordovaLib/ant-build/build.prop
[propertyfile] Updating property file: /media/data/Code/TestCordova/platforms/android/CordovaLib/ant-build/build.prop

-post-build:

debug:

-code-gen:
[mergemanifest] Found modified input file
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
 [echo] Handling aidl files...
 [aidl] No AIDL files to compile.
 [echo] ----------
 [echo] Handling RenderScript files...
 [echo] ----------
 [echo] Handling Resources...
 [aapt] Found modified input file
 [aapt] Generating resource IDs...
 [echo] ----------
 [echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.

-pre-compile:
 [echo] Set jars path to: /media/data/Code/TestCordova/platforms/android/CordovaLib/ant-build/classes.jar

-compile:
[javac] Compiling 3 source files to /media/data/Code/TestCordova/platforms/android/ant-build/classes

-post-compile:

-obfuscate:

-dex:
  [dex] input: /media/data/Code/TestCordova/platforms/android/ant-build/classes
  [dex] input: /media/data/Code/TestCordova/platforms/android/CordovaLib/ant-build/classes.jar
  [dex] Pre-Dexing /media/data/Code/TestCordova/platforms/android/CordovaLib/ant-build/classes.jar -> classes-bb9056b40692a004458ab6a86f70278c.jar
   [dx] 
   [dx] UNEXPECTED TOP-LEVEL EXCEPTION:
   [dx] com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
   [dx]     at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
   [dx]     at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
   [dx]     at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
   [dx]     at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
   [dx]     at com.android.dx.command.dexer.Main.processClass(Main.java:704)
   [dx]     at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
   [dx]     at com.android.dx.command.dexer.Main.access$300(Main.java:83)
   [dx]     at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
   [dx]     at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
   [dx]     at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
   [dx]     at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
   [dx]     at com.android.dx.command.dexer.Main.processOne(Main.java:632)
   [dx]     at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
   [dx]     at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
   [dx]     at com.android.dx.command.dexer.Main.run(Main.java:246)
   [dx]     at com.android.dx.command.dexer.Main.main(Main.java:215)
   [dx]     at com.android.dx.command.Main.main(Main.java:106)
   [dx] ...while parsing com/squareup/okhttp/Address.class
   [dx] 
   [dx] 1 error; aborting

BUILD FAILED
/usr/local/android-sdk-linux/tools/ant/build.xml:892: The following error occurred while executing this line:
/usr/local/android-sdk-linux/tools/ant/build.xml:894: The following error occurred while executing this line:
/usr/local/android-sdk-linux/tools/ant/build.xml:906: The following error occurred while executing this line:
/usr/local/android-sdk-linux/tools/ant/build.xml:283: null returned: 1

Total time: 2 seconds

/media/data/Code/TestCordova/platforms/android/cordova/node_modules/q/q.js:126
                throw e;
                      ^
Error code 1 for command: ant with args: debug,-f,/media/data/Code/TestCordova/platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
ERROR building one of the platforms: Error: /media/data/Code/TestCordova/platforms/android/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: /media/data/Code/TestCordova/platforms/android/cordova/build: Command failed with exit code 8
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)

考虑到Google停止了ADT开发并且Android Studio与Cordova不能很好地兼容,我试图摆脱Eclipse并且只使用CLI进行开发,所以我真的需要让它工作。非常感谢任何帮助。

0 个答案:

没有答案