nmhung / Selfie-Camera-With-Face-Detection

Use Machine Learning - Face Detection to take a selfie picture on Android app.
MIT License
3 stars 3 forks source link

Unable to destroy activity #1

Open tahirghani9 opened 3 years ago

tahirghani9 commented 3 years ago

Facing this crash on Oppo F9 with android 10.

java.lang.RuntimeException: Unable to destroy activity {com.my.package/net.fitken.mlselfiecamera.selfie.SelfieActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Thread$State java.lang.Thread.getState()' on a null object reference at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:5298) at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:5327) at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:44) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:181) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:102) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2239) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:237) at android.app.ActivityThread.main(ActivityThread.java:7830) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1040) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Thread$State java.lang.Thread.getState()' on a null object reference at net.fitken.mlselfiecamera.camera.CameraSource$FrameProcessingRunnable.release(CameraSource.java:637) at net.fitken.mlselfiecamera.camera.CameraSource.release(CameraSource.java:153) at net.fitken.mlselfiecamera.selfie.SelfieActivity.onDestroy(SelfieActivity.kt:137) at android.app.Activity.performDestroy(Activity.java:8254) at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1341) at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:5283) at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:5327)  at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:44)  at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:181)  at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:102)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2239)  at android.os.Handler.dispatchMessage(Handler.java:107)  at android.os.Looper.loop(Looper.java:237)  at android.app.ActivityThread.main(ActivityThread.java:7830)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1040) 

tahirghani9 commented 3 years ago

to recreate this issue, update your project level gradle to as:

classpath 'com.android.tools.build:gradle:4.1.3'

and update your app level gradle as

implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.10" implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.core:core-ktx:1.3.2' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' implementation 'de.hdodenhof:circleimageview:3.1.0' // implementation project(':mlselfiecamera') implementation 'net.fitken:mlselfiecamera:0.1.2'

nmhung commented 3 years ago

Hi @tahirghani9,

Thank you for using my small library. Currently, I'm too busy to check on this. I think you can add the library as a module like above ("mlselfiecamera") and then you can modify it to make it work.

Thank you again. I'll look into this when I have time.