android – Instrumentation run failed due to ''-ThrowExceptions

Exception or error:

I’m trying to get my instrumentation tests running on Travis CI. I’m getting this error when the build runs on Travis. However, I don’t have any problems running the tests locally. I’m new to Android/Java development so I’m not even sure where to start looking.


Tests on test(AVD) - 6.0 failed: Instrumentation run failed due to '' > 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


Here is one of my tests that I expect to run:

package core.ui.dialogs;

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


public class DialogActivityTest {
    public ActivityTestRule<DialogActivity> mActivityRule = new ActivityTestRule<>(DialogActivity.class);

    public void testSomething() {
        // etc...

My .travis.yml:

language: android
jdk: oraclejdk7
sudo: false
    - ANDROID_ABI=armeabi-v7a
    - tools
    - build-tools-$BUILD_TOOLS_VERSION
    - android-$ANDROID_API_LEVEL
    - add-on
    - extra
  - 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

Update: Here are a few things that may be relevant in my build.gradle:

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 23

        testInstrumentationRunner ""
// ...
dependencies {
    compile ''
    compile ''
    compile ''
    compile ''
    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 ('') {
        exclude group: 'javax.inject'
    androidTestCompile ''
How to solve:

I’m also new to android, but I`ll try to help you.

You can follow this answer:

which links to:

Basically this maybe the problem:

You might of used compile '' incorrectly.

The correct apt ''

and also check this link same as your issue


There are 2 issues:

Issue#1: > No tests
found.[test(AVD) – 6.0] FAILED

This is already described here in your case. 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).

For this you can run

gradlew :MyappAndroid:connectedMyappDebugAndroidTest

(where MyappAndroid is the directory name of the MyappAndroid module), which will only run your MyappAndroid‘s tests.

Resource Link:


This problem occurs for some dependency missing like dagger.

As artem-zinnatullin stated in the post

The problem is that you compile dagger-compiler to the project. I don’t want to investigate why it creates problems with instrumentation tests on Android 5+ but anyway, just do not compile it to the apk.

// probably test runner uses Dagger 2 internally and you break it via compiling own version, probably they even use Dagger 1, package names are same.

You can use APT Gradle Plugin to run dagger-compiler during the compilation but do not compile it to the app.

Here is the #qualitymatters app with instrumentation tests and Dagger 2, everything works without problems, so you can take a look and see how to bake something similar.

For Gradle users, use

For Maven users, use <optional>true</optional>.

Dagger documentation details are here: installation, gradle details

Resource Link:


I had the same error but different testOptions and my project uses Dagger:

testOptions {
        execution 'ANDROIDX_TEST_ORCHESTRATOR' <---- remove this!

When I removed the execution line I stopped getting the error. Different bug but thought I’d share in case it can help anyone else!

Leave a Reply

Your email address will not be published. Required fields are marked *