2011-10-24 43 views
1

注意:通過對項目的一些修改,我可以使用以下代碼重新編譯:https://github.com/imsizon/ant-android-scala。對於在Android上構建Scala有困難的人來說,這是一個好的開始。dex在Android上面爲Scala編譯時失敗

我是建立在階螞蟻使用了Android SDK的修訂12(按照說明在這裏: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 

錯誤本身並不能說明很多信息,我不是最好的螞蟻。如果任何人都可以在這個問題上談一談,那將是非常感謝。

+1

這看起來像dx代碼中的斷言,這聽起來可能是dx中的一個錯誤。我會快速瀏覽堆棧跟蹤代碼中的該位置,看看我能否確定交易是什麼 – JesusFreke

+0

它看起來並不像r14的源代碼目前可用 - 而且我對OutputFinisher類似乎不匹配你的堆棧跟蹤,這意味着它在r14中被修改。所以。我沒有多少可以說atm,除此之外,這似乎是dx中的一個錯誤,在r14中引入。 – JesusFreke

+0

如果你真的想嘗試跟蹤它,你可以反編譯dx jar,並看看引發斷言的代碼,看看你能否確定原因。 – JesusFreke

回答

2

對於dex文件中的方法總數,您可能會遇到65,535個限制:Android issue 20814。在這種情況下,使用ProGuard縮小和優化編譯後的代碼可能會有所幫助,正如您提到的頁面上所建議的那樣。

+0

還有[問題7147](http://code.google.com/p/android/issues/detail?id=7147) –