java - 由于 'java.io.FileNotFoundException',检测运行失败

标签 java android

我正在尝试在 Travis CI 上运行我的仪器测试。在 Travis 上运行构建时出现此错误。但是,我在本地运行测试没有任何问题。我是 Android/Java 开发的新手,所以我什至不知道从哪里开始。

...

:MyappAndroid:packageMyappDebugAndroidTest
:MyappAndroid:assembleMyappDebugAndroidTest
:MyappAndroid:connectedMyappDebugAndroidTest
Tests on test(AVD) - 6.0 failed: Instrumentation run failed due to 'java.io.FileNotFoundException'

com.android.builder.testing.ConnectedDevice > No tests found.[test(AVD) - 6.0] FAILED 
No tests found. This usually means that your test classes are not in the form that your test runner expects (e.g. don't inherit from TestCase or lack @Test annotations).
:MyappAndroid:connectedMyappDebugAndroidTest FAILED

...

这是我希望运行的测试之一:

package core.ui.dialogs;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

@RunWith(AndroidJUnit4.class)
@LargeTest
public class DialogActivityTest {
    @Rule
    public ActivityTestRule<DialogActivity> mActivityRule = new ActivityTestRule<>(DialogActivity.class);

    @Test
    public void testSomething() {
        // etc...
    }
}

我的.travis.yml:

language: android
jdk: oraclejdk7
sudo: false
env:
  global:
    - ANDROID_API_LEVEL=23
    - BUILD_TOOLS_VERSION=23.0.3
    - ANDROID_ABI=armeabi-v7a
    - ADB_INSTALL_TIMEOUT=8
android:
  components:
    - tools
    - build-tools-$BUILD_TOOLS_VERSION
    - android-$ANDROID_API_LEVEL
    - add-on
    - extra
before_script:
  - echo no | android create avd --force -n test -t android-$ANDROID_API_LEVEL --abi $ANDROID_ABI
  - emulator -avd test -no-skin -no-audio -no-window &
  - android-wait-for-emulator
  - adb shell input keyevent 82 &
script: ./gradlew assembleMyappDebug connectedMyappDebugAndroidTest -PdisablePreDex

更新:以下是我的 build.gradle 中可能相关的一些内容:

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 23

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
}
// ...
dependencies {
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:support-v4:23.1.0'
    compile 'com.google.android.gms:play-services-gcm:8.4.0'
    compile 'com.google.code.gson:gson:2.3'
    compile 'com.squareup.dagger:dagger:1.2.2'
    provided 'com.squareup.dagger:dagger-compiler:1.2.2'
    // ...
    androidTestCompile 'com.squareup:javawriter:2.5.0'
    androidTestCompile ('com.android.support.test.espresso:espresso-core:2.0') {
        exclude group: 'javax.inject'
    }
    androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
 }

最佳答案

我也是android新手,但我会尽力帮助你。

你可以按照这个答案:

https://groups.google.com/d/msg/adt-dev/QW5SuzQizNk/mWdaEuuCCQAJ

which links to:

https://github.com/google/dagger/issues/271

基本上这可能是问题:

您可能使用了 compile 'com.google.dagger:dagger-compiler:2.0.2' 错误。

正确的apt 'com.google.dagger:dagger-compiler:2.0.2'

并检查此链接与您的问题相同

https://googleweblight.com/?lite_url=https://github.com/Shippable/support/issues/1453&ei=a6rzQlWF&lc=en-IN&s=1&m=140&host=www.google.co.in&ts=1471246688&sig=AKOVD67-05kCThujPFkmuySpywKlKpVG-g

关于java - 由于 'java.io.FileNotFoundException',检测运行失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38926487/

相关文章:

java - 值(value)和元素值(value)之间的差异

android - 在 multidex 应用程序中加速 gradle 构建

android - ADB 在 Linux Ubuntu 10.04 中无法识别三星 S5830(Ace)

android - 指定的 child 在膨胀 View 上已经有父错误

java - Spring Cloud Stream 消息 JSON 转换不起作用

java - 具有 3 个条件的 do-while 循环

java - UTC 的 Joda DateTime getMillis() 不正确,而是返回本地毫秒

android - AVD 在 Android 4.0 上非常慢

android - 以纵向模式拍摄视频,但使用媒体播放器播放时方向错误

java - 使用 JAXB 解析具有更多子元素的 XML