Toolkit error due to "Process crashed". after lengthy tests

I have about 700 tests to run. When I run them all, it crashed there

"Toolkit error due to process failure." Check logcat device for details. Health check failed: instrumentation failed due to "Process crashed".

after some runtime, about 10 minutes and the ~ 360-370th test completed.

Logcat does not contain information about this failure.

This is applicable when starting from Android Studio, from cmd (on PC and Mac). The device used is 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 thing to add: on the previous code released from my code, this failure will not happen, but I can not find what exactly has changed, caused the failure.

Please help me with this problem, I have been trying to understand it for two weeks.

+5
source share
2 answers

I don’t know if the problem is really relevant for you, but I myself encountered such a problem. An error occurred on some versions of Android on Samsung devices: they did not close the file descriptors properly, creating a leak of file descriptors. After creating 1028 descriptors, the process terminates with an error.

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

To avoid this, I had to reduce the use of HandlerThreads in my tests and, if possible, reuse them. But the best solution would probably be to change the device.

+3
source

Try not to run tests in the background, where no action is run. Therefore, avoid using ActivityUnitTestCase and SingleLaunchActivityTestCase which can cause your own C ++ crash on Android 4.1. More information here: Native crash in / dev / ashmem / dalvik-jit-code-cache

Or try running instrumental tests on newer versions of the Android OS, such as Android 5.1 (API 22) or higher. Some older versions, such as Android 4.1, will crash like this when mixing Espresso tests (JUnit4) with other tests (JUnit3), especially on the ARM emulator.

0
source

All Articles