mohammad aljammali mohammad aljammali - 1 year ago 205
Android Question

cannot resolve method newinstance()

I am trying to understand how to use Api.camera2
and I am following google sample from this link

when I open the project it works but when I try it to rebuild the app to see the effect of each part of the code I got the following error
cannotresolve method newinstance()
it is the main java class

package com.example.jimy.camera_app_learn;

import android.os.Bundle;

public class CameraActivity extends Activity {

protected void onCreate(Bundle savedInstanceState) {
if (null == savedInstanceState) {
.replace(, Camera2BasicFragment.newInstance())


i tried exporting project setting from the original project but it did not work

Answer Source

Did you copy the code from the Github repo you linked to?

This line has the newInstance() method, yet your error clearly says it cannot be found, so you should either implement it or just completely copy the code from that repository.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download