1.Target platform Lolipop 5.0
2.SDK API level 26
3.capturePicture()
Take a picture
Crashed
04-01 07:36:23.805 7945-7989/com.example.cqedu.lpr E/AndroidRuntime: FATAL EXCEPTION: FallbackCameraThread
Process: com.example.cqedu.lpr, PID: 7945
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/media/ExifInterface;
at com.otaliastudios.cameraview.CameraUtils.decodeBitmap(CameraUtils.java:114)
at com.otaliastudios.cameraview.CameraUtils$1.run(CameraUtils.java:91)
at android.os.Handler.handleCallback(Handler.java:819)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.os.HandlerThread.run(HandlerThread.java:65)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.media.ExifInterface" on path: DexPathList[[zip file "/data/app/com.example.cqedu.lpr-dewriNcKuVVlUrYGUKsoGg==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.cqedu.lpr-dewriNcKuVVlUrYGUKsoGg==/lib/x86, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.otaliastudios.cameraview.CameraUtils.decodeBitmap(CameraUtils.java:114)聽
at com.otaliastudios.cameraview.CameraUtils$1.run(CameraUtils.java:91)聽
at android.os.Handler.handleCallback(Handler.java:819)聽
at android.os.Handler.dispatchMessage(Handler.java:99)聽
at android.os.Looper.loop(Looper.java:164)聽
at android.os.HandlerThread.run(HandlerThread.java:65)聽
import android.support.media.ExifInterface;
This line in CameraUtils.java:11 seems to be wrong.It cannot find the "media" class.
import android.media.ExifInterface;
This statement seems to be right.
So, is it a SDK version problem?And which version should i use?
You can useCameraLogger.setLogLevel(LEVEL_VERBOSE)
to add logs to logcat, andCameraLogger.registerLogger()
to handle logs yourself (e.g. export to file or a crash reporting service)
so you can collect data from your users.
+1
There might be something weird in your build file, because we are using the support ExifInterface library and the class path is correct: https://developer.android.com/reference/android/support/media/ExifInterface.html
You need to add
implementation "com.android.support:exifinterface:$supportLibraryVersion"
into dependencies in your build.gradle file. Note: The $supportLibraryVersion variable is defined outside dependencies like this
ext.supportLibraryVersion = '27.1.1'
implementation 'androidx.exifinterface:exifinterface:1.0.0' if use android x
Most helpful comment
implementation 'androidx.exifinterface:exifinterface:1.0.0'if use android x