-1

I'm trying out the new CameraX, have followed the instructions mentioned here https://developer.android.com/jetpack/androidx/releases/camera#camera-camera2-1.0.0-alpha07. And I get the following error,

e: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath: class com.sample.SampleApplication, unresolved supertypes: androidx.camera.core.CameraXConfig.Provider

Can someone help?

Edit: Another thing, I extend "MultiDexApplication" class.

Sivakumar S
  • 681
  • 5
  • 19

2 Answers2

0

your Application should look similar to this:

public class AppController extends Application implements CameraXConfig.Provider {

and the implemented method like this:

@NonNull
@Override
public CameraXConfig getCameraXConfig() {
    return Camera2Config.defaultConfig(this);
}

works for me with the same setup you posted in the google group

ie

def camerax_version = "1.0.0-alpha07"
implementation "androidx.camera:camera-core:${camerax_version}"
implementation "androidx.camera:camera-camera2:${camerax_version}"

implementation "androidx.camera:camera-view:1.0.0-alpha04"

in the Activity all I do is:

bind cameraView and bind it to the activity:

@BindView(R.id.cameraView)
CameraView cameraView;
....

 if (checkCameraAndStoragePermissions()) {
        initializeView();
    } else {
        askCameraAndStoragePermissions(new SingleObserver<Boolean>() {
            @Override
            public void onSubscribe(Disposable d) {
            }

            @Override
            public void onSuccess(Boolean response) {
                if (response) {
                    initializeView();
                }
            }

            @Override
            public void onError(Throwable e) {
            }
        });
    }


@SuppressLint("MissingPermission")
private void initializeView() {
    ...
    cameraView.bindToLifecycle(this);
    ...
}
Finn Marquardt
  • 512
  • 3
  • 9
  • I have the CameraXConfig.Provider implementation too on my application class. Wondering what could be the reason :thinking: – Sivakumar S Dec 18 '19 at 13:45
  • hmm that is weird :-/ Where do you get the error? during build process or when going to the activity itself? Can you post your CameraX Activity where you use the camera view? – Finn Marquardt Dec 19 '19 at 07:43
  • I get the error during build process. And another thing is, I extend "MultiDexApplication" class. Not sure if the issue depends on it.. – Sivakumar S Dec 19 '19 at 10:13
  • works for me also with MultiDexApplication, so its not that – Finn Marquardt Dec 19 '19 at 12:07
  • maybe it is because you have the implementation "androidx.camera:camera-lifecycle:1.0.0-alpha01" part in your gradle? Its not really needed in the basic implementation of the cameraview I will update my original asnwer with some code from my activity – Finn Marquardt Dec 20 '19 at 07:41
  • api "androidx.camera:camera-core:${camerax_version}" fixes the problem though – Sivakumar S Dec 20 '19 at 15:30
0

api "androidx.camera:camera-core:${camerax_version}" fixes the problem

Sivakumar S
  • 681
  • 5
  • 19