dex 在 Android 上为 Scala 进行 ant 构建时失败
注意:对项目进行一些修改后,我可以使用以下命令再次构建: https: //github.com/imsizon/ant-android-scala 。对于任何在 Android 上构建 Scala 遇到困难的人来说,这是一个好的开始。
我正在使用 ant 在 Android SDK 的修订版 12 中构建 scala(按照此处的说明进行操作:http://www.assembla.com/wiki/show/scala-ide/Developing_for_Android。)一切都很顺利,直到我升级到最新的 Android SDK(修订版 14)后,现在我得到以下输出:
Buildfile: /Users/matt/Documents/workspace/ScalaEclipseAndroid/build.xml
-set-mode-check:
-set-debug-files:
-set-debug-mode:
-debug-obfuscation-check:
-setup:
[echo] Gathering info for ScalaEclipseAndroid...
[setup] Android SDK Tools Revision 14
[setup] Project Target: Google APIs
[setup] Vendor: Google Inc.
[setup] Platform Version: 2.1
[setup] API level: 7
[setup] ------------------
[setup] Resolving library dependencies:
[setup] No library dependencies.
[setup] ------------------
[setup] WARNING: Attribute minSdkVersion in AndroidManifest.xml (4) is lower than the project target API level (7)
-build-setup:
[echo] Creating output directories if needed...
-pre-build:
-code-gen:
[echo] ----------
[echo] Handling aidl files...
[aidl] No aidl files to compile.
[echo] ----------
[echo] Handling RenderScript files...
[renderscript] No renderscript files to compile.
[echo] ----------
[echo] Handling Resources...
[aapt] No changed resources. R.java and Manifest.java untouched.
-pre-compile:
-compile:
[scalac] Compiling 0 scala and 1 java source files to /Users/matt/Documents/workspace/ScalaEclipseAndroid/bin/classes
[javac] /Development/android-sdk-mac_x86/tools/ant/build.xml:615: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[scalac] Compiling 0 scala and 1 java source files to /Users/matt/Documents/workspace/ScalaEclipseAndroid/bin/classes
-post-compile:
-obfuscate:
-dex:
[dex] Converting compiled files and external libraries into /Users/matt/Documents/workspace/ScalaEclipseAndroid/bin/classes.dex...
[dx] UNEXPECTED TOP-LEVEL ERROR:
[dx] java.lang.AssertionError
[dx] at com.android.dx.dex.code.OutputFinisher.findExpandedOpcodeForInsn(OutputFinisher.java:525)
[dx] at com.android.dx.dex.code.OutputFinisher.calculateReservedCount(OutputFinisher.java:466)
[dx] at com.android.dx.dex.code.OutputFinisher.reserveRegisters(OutputFinisher.java:402)
[dx] at com.android.dx.dex.code.OutputFinisher.finishProcessingAndGetList(OutputFinisher.java:358)
[dx] at com.android.dx.dex.code.DalvCode.finishProcessingIfNecessary(DalvCode.java:108)
[dx] at com.android.dx.dex.code.DalvCode.getInsns(DalvCode.java:185)
[dx] at com.android.dx.dex.file.CodeItem.place0(CodeItem.java:223)
[dx] at com.android.dx.dex.file.OffsettedItem.place(OffsettedItem.java:242)
[dx] at com.android.dx.dex.file.MixedItemSection.placeItems(MixedItemSection.java:312)
[dx] at com.android.dx.dex.file.DexFile.toDex0(DexFile.java:543)
[dx] at com.android.dx.dex.file.DexFile.toDex(DexFile.java:216)
[dx] at com.android.dx.command.dexer.Main.writeDex(Main.java:574)
[dx] at com.android.dx.command.dexer.Main.run(Main.java:218)
[dx] at com.android.dx.command.dexer.Main.main(Main.java:174)
[dx] at com.android.dx.command.Main.main(Main.java:95)
BUILD FAILED
/Development/android-sdk-mac_x86/tools/ant/build.xml:772: The following error occurred while executing this line:
/Development/android-sdk-mac_x86/tools/ant/build.xml:774: The following error occurred while executing this line:
/Development/android-sdk-mac_x86/tools/ant/build.xml:786: The following error occurred while executing this line:
/Development/android-sdk-mac_x86/tools/ant/build.xml:248: null returned: 3
错误本身不包含太多信息,而且我对 Ant 不是最好的。如果有人能够阐明这个问题,我们将不胜感激。
NOTE: with a little modification to the project I was able to build again using this: https://github.com/imsizon/ant-android-scala . For anyone having trouble building Scala on Android it's a good start.
I was building scala in revision 12 of the Android SDK using ant (followed the instructions here: http://www.assembla.com/wiki/show/scala-ide/Developing_for_Android.) All was going well until I upgraded to the latest Android SDK (revision 14.) now I get the following output:
Buildfile: /Users/matt/Documents/workspace/ScalaEclipseAndroid/build.xml
-set-mode-check:
-set-debug-files:
-set-debug-mode:
-debug-obfuscation-check:
-setup:
[echo] Gathering info for ScalaEclipseAndroid...
[setup] Android SDK Tools Revision 14
[setup] Project Target: Google APIs
[setup] Vendor: Google Inc.
[setup] Platform Version: 2.1
[setup] API level: 7
[setup] ------------------
[setup] Resolving library dependencies:
[setup] No library dependencies.
[setup] ------------------
[setup] WARNING: Attribute minSdkVersion in AndroidManifest.xml (4) is lower than the project target API level (7)
-build-setup:
[echo] Creating output directories if needed...
-pre-build:
-code-gen:
[echo] ----------
[echo] Handling aidl files...
[aidl] No aidl files to compile.
[echo] ----------
[echo] Handling RenderScript files...
[renderscript] No renderscript files to compile.
[echo] ----------
[echo] Handling Resources...
[aapt] No changed resources. R.java and Manifest.java untouched.
-pre-compile:
-compile:
[scalac] Compiling 0 scala and 1 java source files to /Users/matt/Documents/workspace/ScalaEclipseAndroid/bin/classes
[javac] /Development/android-sdk-mac_x86/tools/ant/build.xml:615: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[scalac] Compiling 0 scala and 1 java source files to /Users/matt/Documents/workspace/ScalaEclipseAndroid/bin/classes
-post-compile:
-obfuscate:
-dex:
[dex] Converting compiled files and external libraries into /Users/matt/Documents/workspace/ScalaEclipseAndroid/bin/classes.dex...
[dx] UNEXPECTED TOP-LEVEL ERROR:
[dx] java.lang.AssertionError
[dx] at com.android.dx.dex.code.OutputFinisher.findExpandedOpcodeForInsn(OutputFinisher.java:525)
[dx] at com.android.dx.dex.code.OutputFinisher.calculateReservedCount(OutputFinisher.java:466)
[dx] at com.android.dx.dex.code.OutputFinisher.reserveRegisters(OutputFinisher.java:402)
[dx] at com.android.dx.dex.code.OutputFinisher.finishProcessingAndGetList(OutputFinisher.java:358)
[dx] at com.android.dx.dex.code.DalvCode.finishProcessingIfNecessary(DalvCode.java:108)
[dx] at com.android.dx.dex.code.DalvCode.getInsns(DalvCode.java:185)
[dx] at com.android.dx.dex.file.CodeItem.place0(CodeItem.java:223)
[dx] at com.android.dx.dex.file.OffsettedItem.place(OffsettedItem.java:242)
[dx] at com.android.dx.dex.file.MixedItemSection.placeItems(MixedItemSection.java:312)
[dx] at com.android.dx.dex.file.DexFile.toDex0(DexFile.java:543)
[dx] at com.android.dx.dex.file.DexFile.toDex(DexFile.java:216)
[dx] at com.android.dx.command.dexer.Main.writeDex(Main.java:574)
[dx] at com.android.dx.command.dexer.Main.run(Main.java:218)
[dx] at com.android.dx.command.dexer.Main.main(Main.java:174)
[dx] at com.android.dx.command.Main.main(Main.java:95)
BUILD FAILED
/Development/android-sdk-mac_x86/tools/ant/build.xml:772: The following error occurred while executing this line:
/Development/android-sdk-mac_x86/tools/ant/build.xml:774: The following error occurred while executing this line:
/Development/android-sdk-mac_x86/tools/ant/build.xml:786: The following error occurred while executing this line:
/Development/android-sdk-mac_x86/tools/ant/build.xml:248: null returned: 3
The error itself doesn't contian much info and I'm not the best with Ant. If anyone can shed some light on the issue it would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能会遇到 dex 文件中方法总数的 65,535 个限制:Android 问题 20814。在这种情况下,按照您提到的页面上的建议,使用 ProGuard 缩小和优化编译的代码可能会有所帮助。
You might be running into the 65,535 limit on the total number of methods in a dex file: Android issue 20814. In that case, shrinking and optimizing the compiled code with ProGuard may help, as suggested on the pages that you mention.
来自问题:通过对项目进行一些修改,我可以使用以下命令再次构建: https:// github.com/imsizon/ant-android-scala。对于任何在 Android 上构建 Scala 遇到困难的人来说,这是一个好的开始。
From Question: With a little modification to the project I was able to build again using this: https://github.com/imsizon/ant-android-scala. For anyone having trouble building Scala on Android it's a good start.