caffe-android-demo icon indicating copy to clipboard operation
caffe-android-demo copied to clipboard

File not found on Xiaomi6, Android7.1.1, the solution in issue41 doesn't work

Open joyzhou28 opened this issue 7 years ago • 7 comments

Crashed in Xiaomi-6. The same problem in issue41 was solved. Although I adopt the this solution, allowing the permission of caffe-android-demo, the error still exists. screenshot_2017-10-31-14-43-59-531_com miui bugreport

And the build.gradle is compileSdkVersion 25 buildToolsVersion "25.0.1" defaultConfig { applicationId "com.sh1r0.caffe_android_demo" minSdkVersion 21 targetSdkVersion 25 versionCode 1 versionName "1.0" }

joyzhou28 avatar Oct 31 '17 08:10 joyzhou28

Hello~ Do you solve this problem ? I meet the same problem.

great1319 avatar Nov 07 '17 12:11 great1319

I got root privilege, problem solved

joyzhou28 avatar Nov 07 '17 12:11 joyzhou28

Excuse me , Have another solution?

great1319 avatar Nov 08 '17 06:11 great1319

I think you should make it clear why "File not found". For my mobile phone, although I have opened the permission for the app in Setting, without root permission, file still cannot be access.

joyzhou28 avatar Nov 08 '17 11:11 joyzhou28

If running on Android >= 6.0, you should be granting permissions in the code in addition to the manifest.

Before you attempt to read the files, you need something like below. It's not perfect but it will check for the required permissions and log the result to console (0 for ok, -1 for not ok). It will also request the permissions from the user.

        int permissionCheckStorage = ContextCompat.checkSelfPermission(this.getApplicationContext(),
                Manifest.permission.WRITE_EXTERNAL_STORAGE);
        Log.d(LOG_TAG, "permissionCheck WRITE_EXTERNAL_STORAGE = " + permissionCheckStorage);
        int permissionCheckCamera = ContextCompat.checkSelfPermission(this.getApplicationContext(),
                Manifest.permission.CAMERA);
        Log.d(LOG_TAG, "permissionCheck CAMERA = " + permissionCheckCamera);

        ActivityCompat.requestPermissions(this,
                new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA},
                MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE_AND_CAMERA);

jimbochou77 avatar Nov 09 '17 05:11 jimbochou77

My cellphone is Android 7.0 and API 24. I have checked the permission .Both camera and external storage have gotten the permission. But it doesn't work . Check failed: fd != -1 (-1 vs. -1) File not found: /storage/emulated/0/caffe_mobile/bvlc_reference_caffenet/deploy.prototxt

And I find something in this project ,like below.Is it an error? image

great1319 avatar Nov 09 '17 13:11 great1319

I've successfully run this demo both on cpu-mode and gpu-mode, the error you displayed above always exists. When running, it would call JNI functions packaged in dynamic library. Check the path and acquire root permission.

joyzhou28 avatar Nov 10 '17 01:11 joyzhou28