javaandroidcommonsware-cwaccwac-camera

Android Studio cwac-camera CameraFragment java.lang.LinkageError


I am having a head-banging issue... I started android developing again, after 2 years pause and moved to Android Studio.

I am making a simple camera app to take a single photo.. after facing enormous issues with the preview size, orientation and rotation I decided to use cwac-camera.

I have included the library like this:

compile 'com.commonsware.cwac:camera:0.6.+'

Using this repository:

maven { url "https://s3.amazonaws.com/repo.commonsware.com" }

My app sdk params are:

compileSdkVersion 23
buildToolsVersion "23.0.1"

and

minSdkVersion 15
targetSdkVersion 23

I have salvaged the demo project and now I am facing the following exception:

java.lang.LinkageError: com.test.testapp.TestCameraFragment

This happens when my activity calls:

current = TestCameraFragment.newInstance(false);

upon onCreate...

I have no idea what is causing the error. I have tried cleaning, re-including the library, renaming methods, etc.

Any fresh ideas?


Solution

  • Fragment added a getHost() method in API Level 23 (though I think it may have existed in API Levels 21-22, just marked with @hide). This conflicts with the getHost() method in CameraFragment.

    The workaround is to set your compileSdkVersion to 19 or lower, which (for some reason) does not trigger the problem.

    As this is a breaking change to the public API of a discontinued library, I will need to ponder exactly what I'm going to do about it...