仪表运行由于“进程崩溃"而失败. [英] Instrumentation run failed due to 'Process crashed.'

查看:189
本文介绍了仪表运行由于“进程崩溃"而失败.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想运行以下测试:

package com.xxx.yyy;

import android.content.Context;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;

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

import static org.junit.Assert.*;

/**
 * Instrumented test, which will execute on an Android device.
 *
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 */
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
    @Test
    public void useAppContext() {
        // Context of the app under test.
        Context appContext = InstrumentationRegistry.getTargetContext();

        assertEquals("com.xxx.yyy", appContext.getPackageName());
    }
}

但是我在控制台中得到了错误:

But I get the error in the console:

$ adb shell am instrument -w -r   -e debug false -e class 'com.xxx.yyy.ExampleInstrumentedTest' com.xxx.yyy.test/android.support.test.runner.AndroidJUnitRunner
Client not ready yet..
Started running tests
Test running failed: Instrumentation run failed due to 'Process crashed.'
Empty test suite.

我无法弄清为什么它不起作用.

I can not figgure out why its not working.

这是我的gradle文件:

Here is my gradle file:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

apply plugin: 'org.greenrobot.greendao' // das kann dann später weg
//apply plugin: 'kotlin-kapt' // if using Kotlin
//apply plugin: 'io.objectbox'


android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.xxx.yyy"
        minSdkVersion 21
        targetSdkVersion 28    
        versionCode 130
        versionName "1.3.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

greendao {
    schemaVersion 4
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.vectordrawable:vectordrawable:1.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
    implementation 'org.greenrobot:greendao:3.2.2'
    implementation 'com.google.firebase:firebase-core:16.0.3'
    implementation 'com.google.firebase:firebase-ads:15.0.1'
    testImplementation 'junit:junit:4.12'
    implementation 'com.github.PhilJay:MPAndroidChart:v3.0.2'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test:rules:1.0.2'
}

apply plugin: 'com.google.gms.google-services'

有什么建议吗?

推荐答案

我自己找到了解决方案. 我已更新为AndroidX,因此还需要从以下位置更新build.gradle文件:

Found the solution by myself. I updated to AndroidX, therefor I needed also to update my build.gradle file from:

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

这篇关于仪表运行由于“进程崩溃"而失败.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆