dx使用出现的错误总结

使用dx的各种悲剧错误,一直一直搞啊搞,搞了三天之后才把这么个小错误搞定

做程序员不易浮躁啊,还有就是要真的是要锲而不舍啊!!!!!!!

 

错误一:

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: abc.class: file not found
        at com.android.dx.util.FileUtils.readFile(FileUtils.java:55)
        at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.j
ava:134)
        at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java
:109)
        at com.android.dx.command.dexer.Main.processOne(Main.java:422)
        at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333)
        at com.android.dx.command.dexer.Main.run(Main.java:209)
        at com.android.dx.command.dexer.Main.main(Main.java:174)
        at com.android.dx.command.Main.main(Main.java:91)
1 error; aborting


当你出现这个运行时错误的话,那就是你需要编译的文件需要和你安卓的platform-tool这个文件夹中的内容放在一起

你要做的就是把你的文件放在和dexdump.exe文件和dx.bat放在同一个目录下

这个样子就可以编译通过成功生成dex文件了

错误二:

trouble processing:
bad class file magic (cafebabe) or version (0033.0000)
...while parsing Hello.class
...while processing Hello.class
1 warning
no classfiles specified


出现这个错误的原因是因为jdk的版本不对,我之前用的是JDK1.7但是不知道为什么他编译之后生成的JDK的版本会低于jdk1.6真是让我百思不得其解?

也不知道这个代码是怎么写的

之后我上网查了一下,我把JDK1.7换成了JDK1.6,可是还是不行,出现了相同的提示,结果展示如下

这个时候解决的办法有一个:

强制转换成1.6版本的class

使用的到的命令就是javac -source 1.6 -target 1.6  ****.java(****代表了你的java文件名称)

具体步骤演示如下:

1.编写一个java文件

2.使用javac命令:javac -source 1.6 -target 1.6 ******.java  注意你编写的必须是在你的android的platform-tools文件目录下

3.使用dx命令   dx  --dex --output =*****.dex  *****.class

dexdump.exe  -d *****.dex

这个时候我们来看一下结果

D:\Android\android-sdk\platform-tools>dx --dex --output=abc.dex abc.class

D:\Android\android-sdk\platform-tools>dexdump.exe -d abc.dex
Processing 'abc.dex'...
Opened 'abc.dex', DEX version '035'
Class #0            -
  Class descriptor  : 'Labc;'
  Access flags      : 0x0001 (PUBLIC)
  Superclass        : 'Ljava/lang/Object;'
  Interfaces        -
  Static fields     -
  Instance fields   -
  Direct methods    -
    #0              : (in Labc;)
      name          : '<init>'
      type          : '()V'
      access        : 0x10001 (PUBLIC CONSTRUCTOR)
      code          -
      registers     : 1
      ins           : 1
      outs          : 1
      insns size    : 4 16-bit code units
000160:                                        |[000160] abc.<init>:()V
000170: 7010 0500 0000                         |0000: invoke-direct {v0}, Ljava/
lang/Object;.<init>:()V // method@0005
000176: 0e00                                   |0003: return-void
      catches       : (none)
      positions     :
        0x0000 line=2
      locals        :
        0x0000 - 0x0004 reg=0 this Labc;

    #1              : (in Labc;)
      name          : 'main'
      type          : '([Ljava/lang/String;)V'
      access        : 0x0009 (PUBLIC STATIC)
      code          -
      registers     : 3
      ins           : 1
      outs          : 2
      insns size    : 30 16-bit code units
000178:                                        |[000178] abc.main:([Ljava/lang/S
tring;)V
000188: 1250                                   |0000: const/4 v0, #int 5 // #5
00018a: 1271                                   |0001: const/4 v1, #int 7 // #7
00018c: 2311 0600                              |0002: new-array v1, v1, [I // ty
pe@0006
000190: 2601 0800 0000                         |0004: fill-array-data v1, 000000
0c // +00000008
000196: 7120 0200 1000                         |0007: invoke-static {v0, v1}, La
bc;.test:(I[I)V // method@0002
00019c: 0e00                                   |000a: return-void
00019e: 0000                                   |000b: nop // spacer
0001a0: 0003 0400 0700 0000 0100 0000 0100 ... |000c: array-data (18 units)
      catches       : (none)
      positions     :
        0x0000 line=18
        0x000a line=19
        0x000b line=18
      locals        :

    #2              : (in Labc;)
      name          : 'test'
      type          : '(I[I)V'
      access        : 0x0089 (PUBLIC STATIC VARARGS)
      code          -
      registers     : 6
      ins           : 2
      outs          : 2
      insns size    : 20 16-bit code units
0001c4:                                        |[0001c4] abc.test:(I[I)V
0001d4: 2151                                   |0000: array-length v1, v5
0001d6: 1200                                   |0001: const/4 v0, #int 0 // #0
0001d8: 3510 0c00                              |0002: if-ge v0, v1, 000e // +000
c
0001dc: 4402 0500                              |0004: aget v2, v5, v0
0001e0: 6203 0000                              |0006: sget-object v3, Ljava/lang
/System;.out:Ljava/io/PrintStream; // field@0000
0001e4: 6e20 0300 2300                         |0008: invoke-virtual {v3, v2}, L
java/io/PrintStream;.print:(I)V // method@0003
0001ea: d800 0001                              |000b: add-int/lit8 v0, v0, #int
1 // #01
0001ee: 28f5                                   |000d: goto 0002 // -000b
0001f0: 6200 0000                              |000e: sget-object v0, Ljava/lang
/System;.out:Ljava/io/PrintStream; // field@0000
0001f4: 6e20 0400 4000                         |0010: invoke-virtual {v0, v4}, L
java/io/PrintStream;.println:(I)V // method@0004
0001fa: 0e00                                   |0013: return-void
      catches       : (none)
      positions     :
        0x0000 line=10
        0x0006 line=12
        0x000b line=10
        0x000e line=14
        0x0013 line=15
      locals        :

  Virtual methods   -
  source_file_idx   : 12 (abc.java)

 

 

如果你有任何的问题,可以给我留言,我会及时回复!^^

之前走了好多弯路希望能帮上大家!^^
 

 





  • 5
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 25
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 25
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值