2013-10-05 66 views
0

我想在終端IDE(機器人)運行傑斯,但是當我嘗試運行以下命令:如何將Jess(.jar文件)庫轉換爲.dex文件,或者在Android上運行java類文件?

[email protected]:~/sdcard/myJess$ dx --dex --output=jess.dex Jess71p2/lib/jess.jar 

我得到的消息:

warning: Ignoring InnerClasses attribute for an anonymous inner class that doesn't come with an associated EnclosingMethod attribute. (This class was probably produced by a broken compiler.) 
warning: Ignoring InnerClasses attribute for an anonymous inner class that doesn't come with an associated EnclosingMethod attribute. (This class was probably produced by a broken compiler.) 
warning: Ignoring InnerClasses attribute for an anonymous inner class that doesn't come with an associated EnclosingMethod attribute. (This class was probably produced by a broken compiler.) 
warning: Ignoring InnerClasses attribute for an anonymous inner class that doesn't come with an associated EnclosingMethod attribute. (This class was probably produced by a broken compiler.) 
warning: Ignoring InnerClasses attribute for an anonymous inner class that doesn't come with an associated EnclosingMethod attribute. (This class was probably produced by a broken compiler.) 

UNEXPECTED TOP-LEVEL ERROR: 
java.lang.OutOfMemoryError 
    at java.util.HashMap.makeTable(HashMap.java:569) 
    at java.util.HashMap.doubleCapacity(HashMap.java:589) 
    at java.util.HashMap.put(HashMap.java:419) 
    at com.android.dx.rop.code.RegisterSpec.intern(RegisterSpec.java:71) 
    at com.android.dx.rop.code.RegisterSpec.makeLocalOptional(RegisterSpec.java:124) 
    at com.android.dx.rop.code.RegisterSpec.withReg(RegisterSpec.java:482) 
    at com.android.dx.ssa.SsaRenamer$BlockRenamer$RenamingMapper.map(SsaRenamer.java:325) 
    at com.android.dx.ssa.RegisterMapper.map(RegisterMapper.java:53) 
    at com.android.dx.ssa.NormalSsaInsn.mapSourceRegisters(NormalSsaInsn.java:43) 
    at com.android.dx.ssa.SsaRenamer$BlockRenamer.visitNonMoveInsn(SsaRenamer.java:555) 
    at com.android.dx.ssa.NormalSsaInsn.accept(NormalSsaInsn.java:199) 
    at com.android.dx.ssa.SsaBasicBlock.forEachInsn(SsaBasicBlock.java:957) 
    at com.android.dx.ssa.SsaRenamer$BlockRenamer.process(SsaRenamer.java:341) 
    at com.android.dx.ssa.SsaRenamer$1.visitBlock(SsaRenamer.java:146) 
    at com.android.dx.ssa.SsaMethod.forEachBlockDepthFirstDom(SsaMethod.java:787) 
    at com.android.dx.ssa.SsaRenamer.run(SsaRenamer.java:143) 
    at com.android.dx.ssa.SsaConverter.convertToSsaMethod(SsaConverter.java:53) 
    at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:100) 
    at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:74) 
    at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:269) 
    at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:131) 
    at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:85) 
    at com.android.dx.command.dexer.Main.processClass(Main.java:299) 
    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:278) 
    at com.android.dx.command.dexer.Main.access$100(Main.java:56) 
    at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:229) 
    at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:250) 
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:136) 
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:113) 
    at com.android.dx.command.dexer.Main.processOne(Main.java:247) 
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:183) 
    at com.android.dx.command.dexer.Main.run(Main.java:139) 
    at com.android.dx.command.dexer.Main.main(Main.java:120) 
    at com.android.dx.command.Main.main(Main.java:89) 
    at com.spartacusrex.spartacuside.external.dx.main(dx.java:14) 
    at dalvik.system.NativeStart.main(Native Method) 

我已經嘗試過其他方法,如通過ssh連接到其他機器,但它不可用並且像本地一樣快。 有誰知道解決方案或其他方法?

回答

1

Jess 7與Android不兼容。傑西8將會在任何一天發佈。所以請留意www.jessrules.com。

0

您需要添加--no-strictdx選項,如果你正面臨着內存溢出的異常,你應該編輯dx腳本和擴展內存範圍:

dalvikvm -Xss262912 -Xmx500M -cp $APK com.spartacusrex.spartacuside.external.dx [email protected] 

更改-Xmx500M到您所需的內存

也就是說,直到您停止接收OOM異常。

對於我來說,雖然從JDK的tools.jar中的tools.jar德興,它的極限是-Xmx900M之後,因爲我的手機有大約900-990MBs免費無更多的內存可以分配。

  • 分類文件之後的下一步是重新打包jess.jar中的任何剩餘資源文件,因爲dex文件沒有資源。
  • 觀察該jar文件的內容與java命令或與winrar或任何文件資源管理器,並找到資源文件夾。您可能會找到多個這樣的resources文件夾,將其全部提取出來。
  • 確保您的DEX文件有命名classes.dex然後重新包裝起來的一種新型jess_for_android.jar的所有文件,把所有的資源在同一個目錄樹,因爲他們在原來的jess.jar文件

  • 最後,當您嘗試使用它,使用dalvikvm命令,而不是java否則你會(可能) 得到錯誤:

    dalvikvm -cp path_To_your_repacked_jar Main_className [email protected] 
    

個內存選項-Xss和-Xmx是可選的。

希望這會有所幫助,如果您獲得Jess工具的工作,請提供一個鏈接。