-1

I just want use react-native-camera in my react-native project but has an error, I need help, I don't know what happened about this error. Looking forward to your answer, Thanks.

error info

android/app/build.gradle

Nirmalsinh Rathod
  • 5,079
  • 4
  • 26
  • 56
  • You'll get a better response if you copy the error code and output into the stack question instead of posting a picture of the output – Matt Coady Apr 18 '18 at 17:24

1 Answers1

0

There are two main possibilities:

  • Add below line in build.gradle under compile project(':react-native-camera')

    compile (project(':react-native-camera')) { exclude group: "com.android.support" }

  • As Camera module is used same TAG name as default native camera will use it: --> put code into react-native-camera --> src --> main --> java --> com.lwansbrough.RCTCamera --> RCTCameraModule

1) You need to add RCTCameraModule as a tag:

 public class RCTCameraModule extends ReactContextBaseJavaModule
    implements MediaRecorder.OnInfoListener, MediaRecorder.OnErrorListener, LifecycleEventListener {
    private static final String TAG = "RCTCameraModule";
...
}

2) Add this method

 @Override
    public String getName() {
        return "RCTCameraModule";
    }

Hope this will help you :)

Nirmalsinh Rathod
  • 5,079
  • 4
  • 26
  • 56
  • i do that, but still the error, * What went wrong: A problem occurred evaluating project ':react-native-camera'. > Could not find method compileOnly() for arguments [com.facebook.react:react-native:+] on o bject of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. – Chris Downey Apr 19 '18 at 01:48
  • This issues is solved now, i just update buildToolsVersion to "26.0.2" and gradle to "gradle-4.4-all" then it's ok, thanks always. – Chris Downey Apr 19 '18 at 03:31
  • Atleast we all come to know solution. – Nirmalsinh Rathod Apr 19 '18 at 03:32