crash before OS 7
Opened this issue · 2 comments
java.lang.RuntimeException: Unable to create application : java.io.IOException: fcntl failed: EAGAIN (Try again)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4710)
at android.app.ActivityThread.access$1600(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.io.IOException: fcntl failed: EAGAIN (Try again)
at java.nio.FileChannelImpl.basicLock(FileChannelImpl.java:123)
at java.nio.FileChannelImpl.tryLock(FileChannelImpl.java:181)
at java.nio.channels.FileChannel.tryLock(FileChannel.java:584)
at java.util.logging.FileHandler.initOutputFiles(FileHandler.java:197)
at java.util.logging.FileHandler.init(FileHandler.java:159)
at java.util.logging.FileHandler.(FileHandler.java:482)
at fr.bipi.tressence.file.FileLoggerTree$Builder.build(FileLoggerTree.java:242)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1014)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707)
at android.app.ActivityThread.access$1600(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.system.ErrnoException: fcntl failed: EAGAIN (Try again)
at libcore.io.Posix.fcntlFlock(Native Method)
at libcore.io.ForwardingOs.fcntlFlock(ForwardingOs.java:70)
at java.nio.FileChannelImpl.basicLock(FileChannelImpl.java:121)
at java.nio.FileChannelImpl.tryLock(FileChannelImpl.java:181)
at java.nio.channels.FileChannel.tryLock(FileChannel.java:584)
at java.util.logging.FileHandler.initOutputFiles(FileHandler.java:197)
at java.util.logging.FileHandler.init(FileHandler.java:159)
at java.util.logging.FileHandler.(FileHandler.java:482)
at fr.bipi.tressence.file.FileLoggerTree$Builder.build(FileLoggerTree.java:242)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1014)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707)
at android.app.ActivityThread.access$1600(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
I met this problem on Android OS < 7
Platform, Five, One
I've had the same problem on Android 5. Our root cause was the fact that our app had another process besides the default one (this came from 3rd party SDK).
You have to initialize your FileLoggerTree
only in your app's main process, or it will crash.
Here is the sample code:
private fun initDebugFileLogging() {
if (packageName == findProcessName()) {
val logDir = File(getExternalFilesDir(null), "logs")
if (!logDir.exists()) {
logDir.mkdir()
}
val t = FileLoggerTree.Builder()
.withDir(logDir)
.withFileName(TimberConfig.LOG_FILE_NAME)
.withSizeLimit(TimberConfig.LOG_FILE_SIZE)
.withFileLimit(1)
.withMinPriority(Log.DEBUG)
.appendToFile(true)
.build()
Timber.plant(t, Timber.DebugTree())
}
}
fun Application.findProcessName(): String? {
val pid = Process.myPid()
val manager: ActivityManager = this.getSystemService(ACTIVITY_SERVICE) as ActivityManager
val processes = manager.runningAppProcesses
return processes?.find { it.pid == pid }?.processName
}
I think this can be stated in Readme to prevent confusion.