Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Instrumentation run failed due to 'Process crashed.' after long tests execution

I have about 700 tests to execute. When I run them all, there raised a crash

"Instrumentation run failed due to 'Process crashed.'" Check device logcat for details. Test running failed: Instrumentation run failed due to 'Process crashed.'

after some time of execution, about 10 minutes and ~360-370th executed test.

Logcat doesn't contain any information about this crash

It is applicable by running from Android Studio, from cmd (on PC and Mac). Device used - Samsung S3 on Android 4.1.1

build.gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 18
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.xxx.yyy"
        minSdkVersion 9
        targetSdkVersion 18

        testApplicationId "com.xxx.zzz"
        testInstrumentationRunner "android.test.InstrumentationTestRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }

    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }

    project.gradle.taskGraph.whenReady {
        connectedAndroidTestDebug  {
            ignoreFailures = true
        }
    }
}


repositories {
    // The local cache should be used first
    mavenLocal()

    jcenter()
    mavenCentral()
}

dependencies {
    compile 'junit:junit:4.12'

    compile fileTree(include: '*.jar', dir: 'libs')
}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.xxx.yyy"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.CAMERA.autoFocus" />
    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />
    <application
        android:allowBackup="true"
        android:largeHeap="true"
        android:icon="@drawable/ic_launcher"

        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <activity
            android:name="com.xxx.yyy.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <meta-data
            android:name="roboguice.annotations.packages"
            android:value="com.xxx"/>
        <meta-data
            android:name="roboguice.modules"
            android:value="com.xxx.yyy.MainModule"/>
    </application>

</manifest>

One more to add: on previous released of my code this crash is not happen, but I can't find what exactly change gave a crash.

Please help me with this issue, I'm trying to understand it over two weeks.

like image 333
pbelov Avatar asked Aug 10 '15 10:08

pbelov


1 Answers

I don't know if the problem is still actual for you, but I have encountered such problem myself. There was a bug in certain Android versions on Samsung devices: they didn't close file descriptors properly thus creating file descriptors leak. After 1028 descriptors are created - the process crashes.

http://code.google.com/p/android/issues/detail?id=32470

To avoid this I had to cut on the usage of HandlerThreads in my tests, and re-use them where possible. But the better solution would be to change the device, probably.

like image 93
abaranov Avatar answered Oct 19 '22 17:10

abaranov