Appcelerator Android 构建失败而 运行 dexer

Appcelerator Android build fails while running dexer

我正在尝试通过命令行 Android 构建 Appcelerator 项目,使用 appc run -b 后跟选项 1 for Android.

此操作最初按预期进行,但随后在 Running dexer 期间无限期挂起并最终耗尽内存并产生以下错误:

  [INFO]  Running dexer: /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/java "-Xmx512M" "-XX:-UseGCOverheadLimit"     "-Djava.ext.dirs=/Users/almcd/Library/android-sdk-macosx/  platform-tools" "-jar" "/Users/almcd/Library/    android-sdk-macosx/build-tools/23.0.1/lib/dx.jar" "--dex" "--output=/Users/almcd/Documents/Appcelerator_Studio_Workspace/    uktvplay_mobile/build/  android/bin/classes.dex" "/Users/almcd/Documents/Appcelerator_Studio_Workspace/uktvplay_mobile/build/    android/bin/classes" "/Users/almcd/Library/Application Support/Titanium/mobilesdk/  osx/5.5.1.GA/android/lib/titanium-verify.jar"     "/Users/almcd/Documents/Appcelerator_Studio_Workspace/uktvplay_mobile/modules/android/com.tripvi.drawerlayout/1.4.2/    drawerlayout.jar" "/Users/  almcd/Documents/Appcelerator_Studio_Workspace/uktvplay_mobile/modules/android/    com.brightcove.uktv/1.4.0/tibrightcove.jar" "/Users/almcd/Documents/Appcelerator_Studio_Workspace/uktvplay_mobile/  modules/    android/com.brightcove.uktv/1.4.0/lib/FWAdManager.jar" "/Users/almcd/Documents/Appcelerator_Studio_Workspace/uktvplay_mobile/    modules/android/com.brightcove.uktv/1.4.0/lib/  android-exoplayer-player-4.6.3.jar" "/Users/almcd/Documents/    Appcelerator_Studio_Workspace/uktvplay_mobile/modules/android/com.brightcove.uktv/1.4.0/lib/android-freewheel-plugin-4.6.3.jar" "/  Users/    almcd/Documents/Appcelerator_Studio_Workspace/uktvplay_mobile/modules/android/com.brightcove.uktv/1.4.0/lib/    android-sdk-4.6.3.jar" "/Users/almcd/Documents/  Appcelerator_Studio_Workspace/uktvplay_mobile/modules/android/    com.brightcove.uktv/1.4.0/lib/android-widevine-plugin-4.6.3.jar" "/Users/almcd/Documents/Appcelerator_Studio_Workspace/      uktvplay_mobile/modules/android/com.brightcove.uktv/1.4.0/lib/com.google.exoplayer-1.5.2.1.jar" "/Users/almcd/Documents/    Appcelerator_Studio_Workspace/uktvplay_mobile/modules/android/  com.brightcove.uktv/1.4.0/lib/spring-appstreaming-android-1.2.3.jar" "/Users/    almcd/Documents/Appcelerator_Studio_Workspace/uktvplay_mobile/modules/android/com.brightcove.uktv/1.4.0/lib/      spring-util-android.jar" "/Users/almcd/Documents/Appcelerator_Studio_Workspace/uktvplay_mobile/modules/android/    analytics.google/3.1.0/analytics.google.jar" "/Users/almcd/Documents/  Appcelerator_Studio_Workspace/uktvplay_mobile/modules/    android/analytics.google/3.1.0/lib/google-play-services.jar" "/Users/almcd/Documents/Appcelerator_Studio_Workspace/    uktvplay_mobile/  modules/android/com.alcoapps.actionbarextras/1.6.9/actionbarextras.jar" "/Users/almcd/Library/Application     Support/Titanium/mobilesdk/osx/5.5.1.GA/android/kroll-v8.jar" "/Users/almcd/Library/  Application Support/Titanium/mobilesdk/    osx/5.5.1.GA/android/modules/titanium-analytics.jar" "/Users/almcd/Library/Application Support/Titanium/mobilesdk/osx/5.5.1.GA/    android/  aps-analytics.jar" "/Users/almcd/Library/Application Support/Titanium/mobilesdk/osx/5.5.1.GA/android/modules/    titanium-android.jar" "/Users/almcd/Library/Application Support/Titanium/mobilesdk/  osx/5.5.1.GA/android/jaxen-1.1.1.jar" "/Users    /almcd/Library/Application Support/Titanium/mobilesdk/osx/5.5.1.GA/android/ti-commons-codec-1.3.jar" "/Users/almcd/    Library/Application Support/  Titanium/mobilesdk/osx/5.5.1.GA/android/kroll-common.jar" "/Users/almcd/Library/Application Support/    Titanium/mobilesdk/osx/5.5.1.GA/android/titanium.jar" "/Users/almcd/Library/Application   Support/Titanium/mobilesdk/osx/5.5.1.GA/    android/modules/titanium-filesystem.jar" "/Users/almcd/Library/Application Support/Titanium/mobilesdk/osx/5.5.1.GA/android/    modules/  titanium-app.jar" "/Users/almcd/Library/Application Support/Titanium/mobilesdk/osx/5.5.1.GA/android/modules/    titanium-ui.jar" "/Users/almcd/Library/Application Support/Titanium/mobilesdk/  osx/5.5.1.GA/android/    nineoldandroids-appc-2.4.0.jar" "/Users/almcd/Library/Application Support/Titanium/mobilesdk/osx/5.5.1.GA/android/modules/    titanium-media.jar" "/Users/almcd/Library/  Application Support/Titanium/mobilesdk/osx/5.5.1.GA/android/modules/    titanium-appcompat.jar" "/Users/almcd/Library/Application Support/Titanium/mobilesdk/osx/5.5.1.GA/android/      android-support-v4.jar" "/Users/almcd/Library/Application Support/Titanium/mobilesdk/osx/5.5.1.GA/android/    android-support-v7-appcompat.jar" "/Users/almcd/Library/Application Support/Titanium/  mobilesdk/osx/5.5.1.GA/android/modules/    titanium-cardview.jar" "/Users/almcd/Library/Application Support/Titanium/mobilesdk/osx/5.5.1.GA/android/    cardview-v7-23.0.1.jar" "/Users/almcd/  Library/Application Support/Titanium/mobilesdk/osx/5.5.1.GA/android/modules/    titanium-locale.jar" "/Users/almcd/Library/Application Support/Titanium/mobilesdk/osx/5.5.1.GA/android/modules/      titanium-network.jar" "/Users/almcd/Library/Application Support/Titanium/mobilesdk/osx/5.5.1.GA/android/modules/    titanium-xml.jar" "/Users/almcd/Library/Application Support/Titanium/mobilesdk/  osx/5.5.1.GA/android/modules/titanium-utils.jar"     "/Users/almcd/Library/Application Support/Titanium/mobilesdk/osx/5.5.1.GA/android/modules/titanium-geolocation.jar" "/Users/    almcd/Library/  Application Support/Titanium/mobilesdk/osx/5.5.1.GA/android/modules/titanium-accelerometer.jar" "/Users/    almcd/Library/Application Support/Titanium/mobilesdk/osx/5.5.1.GA/android/modules/  titanium-contacts.jar" "/Users/    almcd/Library/Application Support/Titanium/mobilesdk/osx/5.5.1.GA/android/modules/titanium-map.jar" "/Users/almcd/    Library/Application Support/Titanium/  mobilesdk/osx/5.5.1.GA/android/modules/titanium-calendar.jar" "/Users/almcd/Library/    Application Support/Titanium/mobilesdk/osx/5.5.1.GA/android/modules/titanium-gesture.jar" "/Users/almcd/  Library/Application     Support/Titanium/mobilesdk/osx/5.5.1.GA/android/modules/titanium-platform.jar" "/Users/almcd/Library/Application Support/    Titanium/mobilesdk/osx/5.5.1.GA/android/modules  /titanium-database.jar"
  [ERROR] Failed to run dexer:
  [ERROR]   
  [ERROR] UNEXPECTED TOP-LEVEL ERROR:
  [ERROR] java.lang.OutOfMemoryError: Java heap space
  [ERROR]         at java.io.DataInputStream.<init>(DataInputStream.java:58)
  [ERROR]         at com.android.dx.util.ByteArray$MyDataInputStream.<init>(ByteArray.java:356)
  [ERROR]         at com.android.dx.util.ByteArray.makeDataInputStream(ByteArray.java:260)
  [ERROR]         at com.android.dx.cf.direct.StdAttributeFactory.parseLocalVariables(StdAttributeFactory.java:565)
  [ERROR]         at com.android.dx.cf.direct.StdAttributeFactory.localVariableTable(StdAttributeFactory.java:517)
  [ERROR]         at com.android.dx.cf.direct.StdAttributeFactory.parse0(StdAttributeFactory.java:178)
  [ERROR]         at com.android.dx.cf.direct.AttributeFactory.parse(AttributeFactory.java:96)
  [ERROR]         at com.android.dx.cf.direct.AttributeListParser.parse(AttributeListParser.java:141)
  [ERROR]         at com.android.dx.cf.direct.AttributeListParser.parseIfNecessary(AttributeListParser.java:115)
  [ERROR]         at com.android.dx.cf.direct.AttributeListParser.getList(AttributeListParser.java:106)
  [ERROR]         at com.android.dx.cf.direct.StdAttributeFactory.code(StdAttributeFactory.java:300)
  [ERROR]         at com.android.dx.cf.direct.StdAttributeFactory.parse0(StdAttributeFactory.java:139)
  [ERROR]         at com.android.dx.cf.direct.AttributeFactory.parse(AttributeFactory.java:96)
  [ERROR]         at com.android.dx.cf.direct.AttributeListParser.parse(AttributeListParser.java:141)
  [ERROR]         at com.android.dx.cf.direct.AttributeListParser.parseIfNecessary(AttributeListParser.java:115)
  [ERROR]         at com.android.dx.cf.direct.AttributeListParser.getEndOffset(AttributeListParser.java:96)
  [ERROR]         at com.android.dx.cf.direct.MemberListParser.parse(MemberListParser.java:213)
  [ERROR]         at com.android.dx.cf.direct.MemberListParser.parseIfNecessary(MemberListParser.java:108)
  [ERROR]         at com.android.dx.cf.direct.MethodListParser.getList(MethodListParser.java:54)
  [ERROR]         at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:542)
  [ERROR]         at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
  [ERROR]         at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
  [ERROR]         at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
  [ERROR]         at com.android.dx.command.dexer.Main.parseClass(Main.java:764)
  [ERROR]         at com.android.dx.command.dexer.Main.access00(Main.java:85)
  [ERROR]         at com.android.dx.command.dexer.Main$ClassParserTask.call(Main.java:1684)
  [ERROR]         at com.android.dx.command.dexer.Main.processClass(Main.java:749)
  [ERROR]         at com.android.dx.command.dexer.Main.processFileBytes(Main.java:718)
  [ERROR]         at com.android.dx.command.dexer.Main.access00(Main.java:85)
  [ERROR]         at com.android.dx.command.dexer.Main$FileBytesConsumer.processFileBytes(Main.java:1645)
  [ERROR]         at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
  [ERROR]         at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)

搜索 Failed to run dexer 错误消息会出现一些建议。到目前为止我已经尝试过:

上面的

None 已经解决了错误,但我仍然认为问题出在我的 Android SDK 上。

运行 appc ti setup check 提供以下输出:

uktvplay_mobile->appc ti setup check
Appcelerator Command-Line Interface, version 6.0.0
Copyright (c) 2014-2016, Appcelerator, Inc.  All Rights Reserved.

Enter ctrl-c at any time to quit.

──────────────────┤ Check Environment ├───────────────────

Node.js
  ✓  node               installed (v5.10.1)
  ✓  npm                installed (v3.8.3)

Titanium CLI
  ✓  cli                bleeding edge (v5.0.10)

Titanium CLI Dependencies
  ✓  acs                up-to-date (v1.2.2)
  ✓  alloy              up-to-date (v1.9.4)
  ✓  appc-cli-titanium  up-to-date (v4.2.83)
  ✓  appc-inquirer      up-to-date (v0.1.8)
  ✓  appc-logger        up-to-date (v1.1.27)
  ✓  appc-platform-sdk  up-to-date (v1.3.8)
  ✓  arrow              up-to-date (v1.8.12)
  ✓  async              up-to-date (v1.5.2)
  ✓  chalk              up-to-date (v1.1.3)
  ✓  char-spinner       up-to-date (v1.0.1)
  ✓  columnify          up-to-date (v1.5.4)
  ✓  commander          up-to-date (v2.9.0)
  ✓  debug              up-to-date (v2.3.0)
  ✓  ejs                up-to-date (v2.5.2)
  ✓  fields             up-to-date (v0.1.24)
  ✓  fs-extra           up-to-date (v0.26.7)
  ✓  inquirer           up-to-date (v0.11.4)
  ✓  ip                 up-to-date (v1.1.4)
  ✓  jwt-simple         up-to-date (v0.3.1)
  ✓  lodash             up-to-date (v3.10.1)
  ✓  mkdirp             up-to-date (v0.5.1)
  ✓  node-appc          up-to-date (v0.2.39)
  ✓  node-forge         up-to-date (v0.6.45)
  ✓  npmconf            up-to-date (v2.1.2)
  ✓  plural             up-to-date (v0.2.0)
  ✓  progress           up-to-date (v1.1.8)
  ✓  recursive-readdir  up-to-date (v1.3.0)
  ✓  request            up-to-date (v2.78.0)
  ✓  semver             up-to-date (v5.3.0)
  ✓  tar                up-to-date (v2.2.1)
  ✓  tar.gz             up-to-date (v1.0.2)
  ✓  tiapp.xml          up-to-date (v0.2.2)
  ✓  titanium           up-to-date (v5.0.10)
  ✓  which              up-to-date (v1.2.11)
  ✓  wrench             up-to-date (v1.5.9)

Titanium SDK
  ✓  latest sdk         installed (v6.0.0.GA)
  ✓  selected sdk       up-to-date (v6.0.0.GA)

Mac OS X Environment
  ✓  CLI Tools          installed

iOS Environment
  ✓  Xcode              installed (8.1)
  ✓  iOS SDK            installed (10.1)
  ✓  WWDR cert          installed
  ✓  developer cert     installed (1 found)
  !  distribution cert  not found
  ✓  dev provisioning   installed (5 found)
  ✓  dist provisioning  installed (2 found)

Android Environment
  ✓  sdk                installed (/Users/almcd/Library/android-sdk-macosx)
  !  tools              untested version 24.4.1; may or may not work
  ✓  platform tools     installed (v23.1.0)
  ✓  build tools        installed (v23.0.1)
  ✓  adb                installed /Users/almcd/Library/android-sdk-macosx/platform-tools/adb
  ✓  android            installed /Users/almcd/Library/android-sdk-macosx/tools/android
  ✓  emulator           installed /Users/almcd/Library/android-sdk-macosx/tools/emulator
  ✓  mksdcard           installed /Users/almcd/Library/android-sdk-macosx/tools/mksdcard
  ✓  zipalign           installed /Users/almcd/Library/android-sdk-macosx/build-tools/23.0.1/zipalign
  ✓  aapt               installed /Users/almcd/Library/android-sdk-macosx/build-tools/23.0.1/aapt
  ✓  aidl               installed /Users/almcd/Library/android-sdk-macosx/build-tools/23.0.1/aidl
  ✓  targets            installed (1 found)
  ✓  avds               installed (1 found)
  !  ndk                Android NDK not found

Java Development Kit
  ✓  jdk                installed (v1.8.0)
  ✓  java               installed /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/java
  ✓  javac              installed /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/javac
  ✓  keytool            installed /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/keytool
  ✓  jarsigner          installed /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/jarsigner

Intel® Hardware Accelerated Execution Manager (HAXM)
  ✓  compatible         
  ✓  installed          

Network
  ✓  online             
  -  no proxy server configured 
  ✕  https://www.google.com (HTTP status: 404) is unreachable 
  ✓  Java-based connection test 

Directory Permissions
  ✓  home directory     
  ✓  titanium config directory 
  ✓  titanium sdk install directory 
  ✓  temp directory      

我注意到 Android Environment 下的 tools 指定了警告 untested version 24.4.1; may or may not work。这可能是问题所在吗?但是,旧版本的 Android 工具似乎不再可用(遵循此答案:)。

否则将欢迎任何关于问题可能来源的指导。

关于我的环境的其他详细信息:

我能够通过从项目中逐一删除每个 Titanium 模块并尝试构建来解决这个问题。

就我而言,这个过程最终让我确定了 analytics.google module that I was using as the source of the problem. Replacing this module for the more actively maintained ti.ga 模块修复了它。

发布此答案是希望这种识别错误来源的方法可能对遇到相同问题的任何其他人有用。