android - 将 'emma' 添加到 Android ant build 触发 "local variable type mismatch"异常

标签 android ant emma

我正在尝试在 Android 项目的测试中运行 Emma,该项目是 Java 和 C/JNI 代码的组合。构建和测试工作正常,但每当我添加 emma 时,我都会遇到一个神秘的异常。我使用的是 Android SDK v20.1 和 NDK r8b。

项目在这里,它是一个Android库项目: https://github.com/guardianproject/IOCipher 测试在这里: https://github.com/guardianproject/IOCipherTests

build.xml 文件是使用android update test-project 生成的。运行 ant clean debug install test 每次都有效,而 ant clean emma debug install test 触发异常:

异常(exception)情况:

-dex:
      [dex] Converting compiled files and external libraries into /var/lib/jenkins/workspace/IOCipherTests/IOCipherTests/bin/classes.dex...
       [dx] 
       [dx] EXCEPTION FROM SIMULATION:
       [dx] local variable type mismatch: attempt to set or access a value of type int using a local variable of type info.guardianproject.libcore.io.ErrnoException. This is symptomatic of .class transformation tools that ignore local variable information.
       [dx] 
       [dx] ...at bytecode offset 0000002e
       [dx] locals[0000]: Linfo/guardianproject/iocipher/File;
       [dx] locals[0001]: Linfo/guardianproject/iocipher/FileDescriptor;
       [dx] locals[0002]: <invalid>
       [dx] locals[0003]: <invalid>
       [dx] locals[0004]: <invalid>
       [dx] locals[0005]: [Z
       [dx] stack[top0]: int{0x00000001 / 1}
       [dx] ...while working on block 002c
       [dx] ...while working on method createNewFile:()Z
       [dx] ...while processing createNewFile ()Z
       [dx] ...while processing info/guardianproject/iocipher/File.class
       [dx] 
       [dx] 1 error; aborting
BUILD FAILED
/opt/android-sdk/tools/ant/build.xml:850: The following error occurred while executing this line:
/opt/android-sdk/tools/ant/build.xml:852: The following error occurred while executing this line:
/opt/android-sdk/tools/ant/build.xml:864: The following error occurred while executing this line:
/opt/android-sdk/tools/ant/build.xml:266: null returned: 1

最佳答案

我遇到了同样的错误。在我的项目中,我们在一个项目中有一个单元测试应用程序,它包装了另一个包含单元测试本身的项目。这两个项目都引用了我的 SDK,正如 chaitanya 所建议的那样,这导致 emma 两次检测 SDK 代码。通过删除单元测试项目中对 SDK 的引用,我能够解决错误。

关于android - 将 'emma' 添加到 Android ant build 触发 "local variable type mismatch"异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12203826/

相关文章:

java - 如何找出正在运行的 AsyncTask?

android - 如何使用 MOTODEV 从 Android 中的 MapActivity 扩展 Activity ?

android - setPivotX 不适用于 android 4.1.1 NineOldAndroids

java - 如何在不再次运行整个构建的情况下验证在 ant 构建文件中所做的更改?

java - 是否可以在 Eclipse 中使用 Emma 覆盖工具来忽略某些行?

android - 有没有办法在 APK 安装失败时收到通知?

java - Ant 编译但不运行或创建 jar

ant - 将可选路径参数传递给 ant

java - 代码覆盖最终阻塞

scala - IntelliJ IDEA 10.5 的 Scala 案例类中的部分 EMMA 代码覆盖率