0

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?

iganev
  • 124
  • 1
  • 5

1 Answers1

1

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...

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • That fixed everything. I have replaced the compileSdkVersion, targetSdkVersion and the appcompat library to revision of com.android.support:appcompat-v7:19.1.0. Wonderful work btw. – iganev Oct 14 '15 at 08:51
  • 2
    @iganev: BTW, 0.7.0 of CWAC-Camera fixes this by renaming `getHost()` to `getCameraHost()` and `setHost()` to `setCameraHost()`. That will require some refactoring in projects using this library, but it's less risky than relying upon v19 stuff. See https://github.com/commonsguy/cwac-camera/blob/master/README-original.markdown#from-anything-to-070. – CommonsWare Oct 16 '15 at 13:10
  • Thank you very much for the provided information. I will keep that in mind. I already refactored my test app to accommodate v19, so this would be useful in any future projects. – iganev Oct 19 '15 at 12:29