Skip to content Skip to sidebar Skip to footer

Android Error While Using Exifinterface

I am trying to check the orientation of bitmap and flip it if there is a need, but I have error while applying the code. Here is my code while i am trying to flipp the image using

Solution 1:

for AndroidX use

androidx.exifinterface.media.ExifInterface

Import this dependency in build.gradle:

implementation 'androidx.exifinterface:exifinterface:1.3.2'

Solution 2:

You are attempting to use android.media.ExifInterface. On Android 7.0+ (API Level 24), that class is safe to use and has a constructor that takes an InputStream. Apparently, you are running your app on an older device. That results in two problems:

  1. The older device will not have that constructor

  2. ExifInterface has security flaws on older devices, opening your app up to malware attacks

Use android.support.media.ExifInterface instead. It is from the support libraries (com.android.support:exifinterface, specifically). It offers a constructor taking an InputStream that works on all supported versions of Android. And, it bypasses the security bug on older devices.

Solution 3:

Add this to your build.gradle file

compile"com.android.support:exifinterface:25.1.0"

for me it worked.

Solution 4:

The ExifInterface constructor being used in your code sample:

ByteArrayInputStreambs=newByteArrayInputStream(bitmapdata);

was added in SDK level 24.

But it looks like the code is being run on a device with an earlier version of Android than 24.

See https://developer.android.com/reference/android/media/ExifInterface.html#ExifInterface(java.io.InputStream)

Post a Comment for "Android Error While Using Exifinterface"