問題描述
我有大約 700 個測試要執行.當我全部運行它們時,引發了崩潰
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.'
經過一段時間的執行,大約 10 分鐘和約 360-370 次執行測試.
after some time of execution, about 10 minutes and ~360-370th executed test.
Logcat 不包含有關此崩潰的任何信息
Logcat doesn't contain any information about this crash
它適用于從 Android Studio 運行,從 cmd(在 PC 和 Mac 上).使用的設備 - Android 4.1.1 上的三星 S3
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 文件:
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
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.
推薦答案
我不知道你的問題是否仍然存在,但我自己也遇到過這樣的問題.三星設備上的某些 Android 版本存在一個錯誤:它們沒有正確關閉文件描述符,從而導致文件描述符泄漏.創建 1028 個描述符后 - 進程崩潰.
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/問題/詳細信息?id=32470
為了避免這種情況,我不得不在我的測試中減少 HandlerThreads 的使用,并在可能的情況下重新使用它們.但更好的解決方案可能是更換設備.
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.
這篇關于由于“進程崩潰",檢測運行失敗.經過長時間的測試執行的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!