我正在尝试使用Robolectric(版本4.1)在Android Studio中的Android应用程序上运行测试。当我运行测试时(如下所示),我得到一个错误(恰好在测试代码下方)。请注意,该测试是用Kotlin编写的。
在我看来,在Robolectric依赖项的文件路径中,我的名字和姓氏之间的空格引起这种问题的可能性很小(请注意%20)。我在广泛的范围内寻找一种方法来将此路径更改为没有空格的内容,但是我无法弄清楚如何更改路径(即使那是问题所在)。
我正在寻找摆脱该错误的方法,以便我可以继续执行我的任务。感谢您的帮助。
测试代码(如下)
package test.kotlin
import org.junit.*
import org.junit.Assert
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
@RunWith(RobolectricTestRunner::class)
public class KotlinRobolectric {
@Before
fun beforeTest()
{
System.out.println("In the \"Before method \"")
}
@Test
fun firstTest() {
Assert.assertTrue(1 == 1)
}
@After
fun AfterTest()
{
System.out.println("In the \"After method \"")
}
}
错误输出(如下)
"C:\Program Files\Android\Android Studio\jre\bin\java.exe" -ea -Didea.test.cyclic.buffer.size=1048576 -Didea.launcher.port=55253 "-Didea.launcher.bin.path=C:\Program Files\Android\Android Studio\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Android\Android Studio\lib\idea_rt.jar;C:\Program Files\Android\Android Studio\plugins\junit\lib\junit-rt.jar;C:\Program Files\Android\Android Studio\plugins\junit\lib\junit5-rt.jar;C:\Android\Sdk\platforms\android-28\data\res;C:\Users\Anthony Andreoli\Desktop\Concordia\2019 - WINTER\SOEN 390\SOEN390_SimpleCamera\app\build\intermediates\javac\debug\compileDebugJavaWithJavac\classes;C:\Users\Anthony Andreoli\Desktop\Concordia\2019 - WINTER\SOEN 390\SOEN390_SimpleCamera\app\build\tmp\kotlin-classes\debug;C:\Users\Anthony Andreoli\Desktop\Concordia\2019 - WINTER\SOEN 390\SOEN390_SimpleCamera\app\build\generated\res\rs\debug;C:\Users\Anthony Andreoli\Desktop\Concordia\2019 - WINTER\SOEN 390\SOEN390_SimpleCamera\app\build\generated\res\resValues\debug;C:\Users\Anthony Andreoli\Desktop\Concordia\2019 - WINTER\SOEN 390\SOEN390_SimpleCamera\app\build\intermediates\unit_test_config_directory\debugUnitTest\generateDebugUnitTestConfig\out;C:\Users\Anthony Andreoli\Desktop\Concordia\2019 - WINTER\SOEN 390\SOEN390_SimpleCamera\app\build\tmp\kotlin-classes\debugUnitTest;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\backport-util-concurrent\backport-util-concurrent\3.1\682f7ac17fed79e92f8e87d8455192b63376347b\backport-util-concurrent-3.1.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-test-junit\1.3.0\535165afe68d0f38e8f8289e78caa66b6e6b4ff2\kotlin-test-junit-1.3.0.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-common\1.2.71\ba18ca1aa0e40eb6f1865b324af2f4cbb691c1ec\kotlin-stdlib-common-1.2.71.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.apache.maven\maven-project\2.2.1\8239e98c16f641d55a4ad0e0bab0aee3aff8933f\maven-project-2.2.1.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.apache.maven.wagon\wagon-file\1.0-beta-6\6c53633505460caf49d2660de1e24744d915afb9\wagon-file-1.0-beta-6.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.apache.maven.wagon\wagon-provider-api\1.0-beta-6\3f952e0282ae77ae59851d96bb18015e520b6208\wagon-provider-api-1.0-beta-6.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.ow2.asm\asm-commons\7.0\478006d07b7c561ae3a92ddc1829bca81ae0cdd1\asm-commons-7.0.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.objenesis\objenesis\2.4\2916b6c96b50c5b3ec4452ed99401db745aabb27\objenesis-2.4.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\net.bytebuddy\byte-buddy\1.5.12\b1ba1d15f102b36ed43b826488114678d6d413da\byte-buddy-1.5.12.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\com.github.bumptech.glide\annotations\4.8.0\c4c9e79eb2bfeb9059fce55020c6b237402285f6\annotations-4.8.0.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.jetbrains\annotations\13.0\919f0dfe192fb4e063e7dacadee7f8bb9a2672a9\annotations-13.0.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\net.bytebuddy\byte-buddy-agent\1.5.12\bc2c4dc0a0c7ddc12d2bb389e228cd88378a8e3a\byte-buddy-agent-1.5.12.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.ow2.asm\asm-analysis\7.0\4b310d20d6f1c6b7197a75f1b5d69f169bc8ac1f\asm-analysis-7.0.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.robolectric\resources\4.1\384de33f64db44dde6a6cce31feada722c4aee8f\resources-4.1.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.robolectric\junit\4.1\b962a4ba88371a10240148b3304ebcc651b6b0fe\junit-4.1.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\com.google.guava\guava\20.0\89507701249388e1ed5ddcf8c41f4ce1be7831ef\guava-20.0.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\log4j\log4j\1.2.17\5af35056b4d257e4b64b9e8069c0746e8b08629f\log4j-1.2.17.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\com.kohlschutter.junixsocket\junixsocket-common\2.0.4\b4d1870bf903412533e0b79c6fcd402defcfc05b\junixsocket-common-2.0.4.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\com.almworks.sqlite4java\sqlite4java\0.282\745a7e2f35fdbe6336922e0d492c979dbbfa74fb\sqlite4java-0.282.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.apache.maven\maven-settings\2.2.1\2236ffe71fa5f78ce42b0f5fc22c54ed45f14294\maven-settings-2.2.1.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.codehaus.plexus\plexus-container-default\1.0-alpha-9-stable-1\94aea3010e250a334d9dab7f591114cd6c767458\plexus-container-default-1.0-alpha-9-stable-1.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.bouncycastle\bcprov-jdk15on\1.52\88a941faf9819d371e3174b5ed56a3f3f7d73269\bcprov-jdk15on-1.52.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.apache.maven\maven-plugin-registry\2.2.1\72a24b7775649af78f3986b5aa7eb354b9674cfd\maven-plugin-registry-2.2.1.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\com.nhaarman\mockito-kotlin\1.1.0\18a1bdb7cfa6ac47bc381deda5ee58bc9d821fea\mockito-kotlin-1.1.0.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\com.ibm.icu\icu4j\53.1\786d9055d4ca8c1aab4a7d4ac8283f973fd7e41f\icu4j-53.1.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-test-common\1.3.0\b765b1fd01face2ef7f41afab96b2e09e923f053\kotlin-test-common-1.3.0.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.apache.ant\ant-launcher\1.8.0\8b53ba16fa62fb1034da8f1de200ddc407c8381\ant-launcher-1.8.0.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.apache.maven\maven-profile\2.2.1\3950071587027e5086e9c395574a60650c432738\maven-profile-2.2.1.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\nekohtml\nekohtml\1.9.6.2\2d960be7b62ae6622dbbbe49ab4ffdc609f85c80\nekohtml-1.9.6.2.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\nekohtml\xercesMinimal\1.9.6.2\d1c5e063683a0e6f77cd5f051a9d4af48346fa6\xercesMinimal-1.9.6.2.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\androidx.arch.core\core-common\2.0.0\bb21b9a11761451b51624ac428d1f1bb5deeac38\core-common-2.0.0.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.hamcrest\hamcrest-core\1.3\42a25dc3219429f0e5d060061f71acb49bf010a0\hamcrest-core-1.3.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-test-annotations-common\1.3.0\599cd980987f43e0a2252a158595a67eba8e1bf4\kotlin-test-annotations-common-1.3.0.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\com.google.android.apps.common.testing.accessibility.framework\accessibility-test-framework\2.1\c2d6267c3ad0435ddf9e27a94a0e0af4ca3fdfbb\accessibility-test-framework-2.1.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.ow2.asm\asm\7.0\d74d4ba0dee443f68fb2dcb7fcdb945a2cd89912\asm-7.0.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\com.github.bumptech.glide\disklrucache\4.8.0\a7448551cb3edd61bcf3d1b1136b670e630441cf\disklrucache-4.8.0.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.apache.maven\maven-artifact\2.2.1\23600f790d4dab2cb965419eaa982e3e84c428f8\maven-artifact-2.2.1.jar;C:\Users\Anthony Andreoli\.gradle\caches\transforms-1\files-1.1\monitor-1.1.1.aar\f08744db7221c34af67b948fc125522b\jars\classes.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.amshove.kluent\kluent\1.14\7d88188e60072e6e563d91b89ea712f0c9e0ae96\kluent-1.14.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.apache.maven\maven-error-diagnostics\2.2.1\e81bb342d7d172f23d108dc8fa979a1facdcde8e\maven-error-diagnostics-2.2.1.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.robolectric\robolectric\4.1\c323469e137aa9353b822ab2704936a6865def89\robolectric-4.1.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.scijava\native-lib-loader\2.0.2\1451fa03954c5e31a358b411147de472b4dab92c\native-lib-loader-2.0.2.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.ow2.asm\asm-tree\7.0\29bc62dcb85573af6e62e5b2d735ef65966c4180\asm-tree-7.0.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.robolectric\annotations\4.1\ecb95adf35528c498467da094d0290355516c7ec\annotations-4.1.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.apache.maven.wagon\wagon-http-lightweight\1.0-beta-6\b3815078570c3b1f0667e123d59717c6b726c6c2\wagon-http-lightweight-1.0-beta-6.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-jdk7\1.2.71\4ce93f539e2133f172f1167291a911f83400a5d0\kotlin-stdlib-jdk7-1.2.71.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib\1.2.71\d9717625bb3c731561251f8dd2c67a1011d6764c\kotlin-stdlib-1.2.71.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.mockito\mockito-core\2.4.5\7977632cfc4597ef25097b6c1ab84284d61ac70e\mockito-core-2.4.5.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.apache.ant\ant\1.8.0\7b456ca6b93900f96e58cc8371f03d90a9c1c8d1\ant-1.8.0.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-reflect\1.0.6\3d499d3b7768f88c4796e5a1e357933e11a8936d\kotlin-reflect-1.0.6.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.apache.maven\maven-artifact-manager\2.2.1\ec355b913c34d37080810f98e3f51abecbe1572b\maven-artifact-manager-2.2.1.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.apache.maven\maven-ant-tasks\2.1.3\b09be554228d66d208e5fef5266844aacf443abc\maven-ant-tasks-2.1.3.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib\1.3.0\a134b0cfe9bb44f98b0b3e889cda07923eea9428\kotlin-stdlib-1.3.0.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\com.google.protobuf\protobuf-java\2.6.1\d9521f2aecb909835746b7a5facf612af5e890e8\protobuf-java-2.6.1.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.apache.maven.wagon\wagon-http-shared\1.0-beta-6\ccd70d7e0d8c085e648a83f072da06ca9a53be94\wagon-http-shared-1.0-beta-6.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\androidx.lifecycle\lifecycle-common\2.0.0\e070ffae07452331bc5684734fce6831d531785c\lifecycle-common-2.0.0.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\com.kohlschutter.junixsocket\junixsocket-native-common\2.0.4\726bd66a934dea39c817382986496fa4eda96411\junixsocket-native-common-2.0.4.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.apache.maven\maven-model\2.2.1\c0a1c17436ec3ff5a56207c031d82277b4250a29\maven-model-2.2.1.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.apache.maven\maven-repository-metadata\2.2.1\98f0c07fcf1eeb213bef8d9316a9935184084b06\maven-repository-metadata-2.2.1.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\junit\junit\4.12\2973d150c0dc1fefe998f834810d68f278ea58ec\junit-4.12.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.robolectric\utils\4.1\b11122490f7b976c45b0253f0830e71708dfbca8\utils-4.1.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\androidx.annotation\annotation\1.0.0\45599f2cd5965ac05a1488fa2a5c0cdd7c499ead\annotation-1.0.0.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\com.google.code.gson\gson\2.8.2\3edcfe49d2c6053a70a2a47e4e1c2f94998a49cf\gson-2.8.2.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.hamcrest\hamcrest-library\1.3\4785a3c21320980282f9f33d0d1264a69040538f\hamcrest-library-1.3.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-test\1.3.0\e89924f669ba479c1a3cc8530783282e5f8c025\kotlin-test-1.3.0.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.robolectric\shadows-framework\4.1\7810032730caa96236a9ea417ea409c2cce1c4d3\shadows-framework-4.1.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.codehaus.plexus\plexus-interpolation\1.11\ad9dddff6043194904ad1d2c00ff1d003c3915f7\plexus-interpolation-1.11.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.codehaus.plexus\plexus-utils\1.5.15\c689598ce1eb94c304817877ed15911099972526\plexus-utils-1.5.15.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-common\1.3.0\84a2e0288dc17cd64d692eb1e5e0de8cd5ff0846\kotlin-stdlib-common-1.3.0.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\classworlds\classworlds\1.1-alpha-2\5adf2e681c57d7f48038b602f3ca2254ee82d47\classworlds-1.1-alpha-2.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.robolectric\shadowapi\4.1\a7b040ce9f57b8f440fed6d889e57d203a7d2731\shadowapi-4.1.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\androidx.collection\collection\1.0.0\42858b26cafdaa69b6149f45dfc2894007bc2c7a\collection-1.0.0.jar;C:\Users\Anthony Andreoli\.gradle\caches\modules-2\files-2.1\org.robolectric\sandbox\4.1\8a1f10f6a9a36cc6a0c6d1c40dd55ac5557ccf6f\sandbox-4.1.jar;C:\Users\Anthony Andreoli\Desktop\Concordia\2019 - WINTER\SOEN 390\SOEN390_SimpleCamera\app\build\intermediates\sourceFolderJavaResources\test\debug;C:\Users\Anthony Andreoli\Desktop\Concordia\2019 - WINTER\SOEN 390\SOEN390_SimpleCamera\app\build\intermediates\sourceFolderJavaResources\debug;C:\Users\Anthony Andreoli\.gradle\caches\transforms-1\files-1.1\android.jar\53d4fefab7db784a9ed12acf020a4b2c\android.jar" com.intellij.rt.execution.application.AppMainV2 com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 test.kotlin.KotlinRobolectric
[Robolectric] test.kotlin.KotlinRobolectric.firstTest: sdk=28; resources=binary
Called loadFromPath(/system/framework/framework-res.apk, true); mode=binary sdk=28
Failed to open APK 'C:/Users/Anthony%20Andreoli/.m2/repository/org/robolectric/android-all/9-robolectric-4913185-2/android-all-9-robolectric-4913185-2.jar' Error -2147483643
java.lang.RuntimeException: java.lang.RuntimeException: java.io.IOException: Failed to load asset path C:/Users/Anthony%20Andreoli/.m2/repository/org/robolectric/android-all/9-robolectric-4913185-2/android-all-9-robolectric-4913185-2.jar
at org.robolectric.shadows.ShadowPackageParser.callParsePackage(ShadowPackageParser.java:54)
at org.robolectric.android.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:151)
at org.robolectric.RobolectricTestRunner.beforeTest(RobolectricTestRunner.java:379)
at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:252)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:130)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:42)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.robolectric.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:84)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)
Caused by: java.lang.RuntimeException: java.io.IOException: Failed to load asset path C:/Users/Anthony%20Andreoli/.m2/repository/org/robolectric/android-all/9-robolectric-4913185-2/android-all-9-robolectric-4913185-2.jar
at org.robolectric.util.ReflectionHelpers.callStaticMethod(ReflectionHelpers.java:325)
at org.robolectric.internal.bytecode.ShadowImpl.directlyOn(ShadowImpl.java:62)
at org.robolectric.shadow.api.Shadow.directlyOn(Shadow.java:61)
at org.robolectric.shadows.ShadowArscApkAssets9.lambda$loadFromPath$1(ShadowArscApkAssets9.java:158)
at org.robolectric.shadows.ShadowArscApkAssets9.getFromCacheOrLoad(ShadowArscApkAssets9.java:124)
at org.robolectric.shadows.ShadowArscApkAssets9.loadFromPath(ShadowArscApkAssets9.java:156)
at android.content.res.ApkAssets.loadFromPath(ApkAssets.java)
at android.content.res.AssetManager.createSystemAssetsInZygoteLocked(AssetManager.java:199)
at org.robolectric.util.ReflectionHelpers.callStaticMethod(ReflectionHelpers.java:317)
at org.robolectric.internal.bytecode.ShadowImpl.directlyOn(ShadowImpl.java:62)
at org.robolectric.shadow.api.Shadow.directlyOn(Shadow.java:61)
at org.robolectric.shadows.ShadowArscAssetManager9.createSystemAssetsInZygoteLocked(ShadowArscAssetManager9.java:199)
at android.content.res.AssetManager.createSystemAssetsInZygoteLocked(AssetManager.java)
at android.content.res.AssetManager.__constructor__(AssetManager.java:158)
at android.content.res.AssetManager.<init>(AssetManager.java)
at android.content.pm.split.DefaultSplitAssetLoader.getBaseAssetManager(DefaultSplitAssetLoader.java:85)
at android.content.pm.PackageParser.parseMonolithicPackage(PackageParser.java:1299)
at android.content.pm.PackageParser.parsePackage(PackageParser.java:1022)
at android.content.pm.PackageParser.parsePackage(PackageParser.java:1042)
at org.robolectric.shadows.ShadowPackageParser.callParsePackage(ShadowPackageParser.java:28)
at org.robolectric.android.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:151)
at org.robolectric.RobolectricTestRunner.beforeTest(RobolectricTestRunner.java:379)
at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:252)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:130)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:42)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.robolectric.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:84)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
... 1 more
Caused by: java.io.IOException: Failed to load asset path C:/Users/Anthony%20Andreoli/.m2/repository/org/robolectric/android-all/9-robolectric-4913185-2/android-all-9-robolectric-4913185-2.jar
at org.robolectric.shadows.ShadowArscApkAssets9.nativeLoad(ShadowArscApkAssets9.java:230)
at android.content.res.ApkAssets.nativeLoad(ApkAssets.java)
at android.content.res.ApkAssets.__constructor__(ApkAssets.java:116)
at android.content.res.ApkAssets.<init>(ApkAssets.java)
at android.content.res.ApkAssets.loadFromPath(ApkAssets.java:61)
at org.robolectric.util.ReflectionHelpers.callStaticMethod(ReflectionHelpers.java:317)
... 37 more
Process finished with exit code -1
build.grandle(如下)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "com.simplemobiletools.camera"
minSdkVersion 21
targetSdkVersion 28
versionCode 64
versionName "5.0.0"
setProperty("archivesBaseName", "camera")
}
signingConfigs {
release
}
buildTypes {
debug {
applicationIdSuffix ".debug"
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
test.java.srcDirs += 'src/test/kotlin'
androidTest.java.srcDirs += 'src/androidTest/kotlin'
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
testOptions {
unitTests {
returnDefaultValues = true
includeAndroidResources = true
}
}
}
dependencies {
// Older version of kotlin = 1.0.6, then 1.2.71
implementation 'com.simplemobiletools:commons:5.1.4'
testImplementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.0'
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit:1.3.0'
testImplementation "com.nhaarman:mockito-kotlin:1.1.0"
testImplementation 'org.amshove.kluent:kluent:1.14'
testImplementation 'org.robolectric:robolectric:4.1'
}
afterEvaluate {
android.sourceSets.all { sourceSet ->
if (!sourceSet.name.startsWith('test') || !sourceSet.name.startsWith('androidTest')) {
sourceSet.kotlin.setSrcDirs([])
}
}
}
allprojects {
apply from: "$rootDir/ktlint.gradle"
}
Properties props = new Properties()
def propFile = new File('signing.properties')
if (propFile.canRead()) {
props.load(new FileInputStream(propFile))
if (props != null && props.containsKey('STORE_FILE') && props.containsKey('KEY_ALIAS') && props.containsKey('PASSWORD')) {
android.signingConfigs.release.storeFile = file(props['STORE_FILE'])
android.signingConfigs.release.storePassword = props['PASSWORD']
android.signingConfigs.release.keyAlias = props['KEY_ALIAS']
android.signingConfigs.release.keyPassword = props['PASSWORD']
} else {
println 'signing.properties found but some entries are missing'
android.buildTypes.release.signingConfig = null
}
} else {
println 'signing.properties not found'
android.buildTypes.release.signingConfig = null
}
gradle.properties
android.useAndroidX=true
android.enableJetifier=true
android.enableUnitTestBinaryResources=true