Android : A/libc: fdsan: attempted to close file descriptor 86, expected to be unowned
หลังจากกำหนด targetSdkVersion 30 ปรากฎว่าแอปปลิเคชันเปิดแล้วปิดตัวทันที ลองไปตรวจสอบใน Logcat พบว่ามีเพียงข้อความ error
A/libc: fdsan: attempted to close file descriptor 86, expected to be unowned
แต่พอเปลี่ยน targetSdkVersion 29 กลับสามารถทำงานได้ปกติ เลยสืบค้นจนพบว่า Error ที่เกิดขึ้น นั่นเกี่ยวกับการใช้
<pl.droidsonroids.gif.GifTextView android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/image" />
พบว่าถ้ารูปภาพที่โหลดไม่ใช่ Gif images จะทำให้โหลดไม่ขึ้นพร้อมกับขึ้น Error ข้างต้น ซึ่งในตัวอย่างพบว่า @drawable/image เป็นรูปภาพ “.jpg” ดังนั้นวิธีแก้คือเปลี่ยนมาใช้ <ImageView> แทน ดังนี้
<ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="centerCrop" android:src="@drawable/image" />
เพียงเท่านี้ก็สามารถทำให้แอปฯกลับมาทำงานได้อีกครั้งครับ