具有以下单元测试的 Android Things 项目失败:
import com.google.android.things.iotcore.IotCoreClient;
import org.junit.Test;
public class ExampleUnitTest {
@Test
public void clientTest() {
new IotCoreClient.Builder();
}
}
build.gradle 依赖:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
compileOnly 'com.google.android.things:androidthings:1.0'
implementation 'com.google.android.things:cloud-iot-core:1.0.0'
testImplementation 'com.google.android.things:cloud-iot-core:1.0.0'
}
错误输出:
java.lang.VerifyError: Expecting a stackmap frame at branch target 36
Exception Details:
Location:
com/google/android/things/iotcore/IotCoreClient$Builder.build()Lcom/google/android/things/iotcore/IotCoreClient; @22: ifnonnull
Reason:
Expected stackmap frame at this location.
Bytecode:
0000000: 2ab4 0013 1203 b800 1e2a b400 1412 06b8
0000010: 001e 2ab4 0015 c700 0e2a bb00 0959 b700
0000020: 1ab5 0015 2ab4 0017 c600 112a b400 16c7
0000030: 000a 2ab8 001f b500 162a b400 19c6 0011
0000040: 2ab4 0018 c700 0a2a b800 1fb5 0018 bb00
0000050: 1059 2ab4 0013 b600 1b2a b400 13b6 001c
0000060: bb00 1259 b700 23b7 0022 4ca7 000d 4cbb
0000070: 000e 592b b700 20bf bb00 0b59 2ab4 0013
0000080: 2ab4 0014 2b2a b400 152a b400 182a b400
0000090: 192a b400 162a b400 1703 b700 1db0
Exception Handler Table:
bci [78, 107] => handler: 110
我可以在 Activity 中很好地实例化 Builder,但也想为它编写测试。有没有办法测试我的 IoT Core 连接?
这可能只是一个依赖问题,但我没有想法。