0

After being so close to successfully running React-Native for Android, I ran into the following error.

:app:compileDebugJavaWithJavac
/Users/Spicycurryman/Desktop/Main/Projects/Wosyl-Delivery-1.0-master/android/app/src/main/java/com/wosyldelivery/MainApplication.java:30: error: no suitable constructor found for CodePush(<null>,<anonymous ReactNativeHost>,boolean)
            new CodePush(null, this, BuildConfig.DEBUG),
            ^
    constructor CodePush.CodePush(String,Context,boolean,String) is not applicable
      (actual and formal argument lists differ in length)
    constructor CodePush.CodePush(String,Context,boolean) is not applicable
      (actual argument <anonymous ReactNativeHost> cannot be converted to Context by method invocation conversion)
    constructor CodePush.CodePush(String,Context) is not applicable
      (actual and formal argument lists differ in length)
1 error
:app:compileDebugJavaWithJavac FAILED

I've following the instructions in the repo and not sure why this is occuring even after looking at this https://github.com/Microsoft/react-native-code-push/issues/790

Here is my MainApplication.java for full context.

package com.wosyldelivery;

import android.app.Application;
import android.util.Log;

import com.facebook.react.ReactApplication;
import com.microsoft.codepush.react.CodePush;
import com.oblador.vectoricons.VectorIconsPackage;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;


import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    protected boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
            new CodePush(null, this, BuildConfig.DEBUG),
            new VectorIconsPackage()
      );
    }
    @Override
    protected String getJSBundleFile() {
      return CodePush.getJSBundleFile();
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
      return mReactNativeHost;
  }
}

What is the reason for this error occurring? How can it be resolved?

4
  • try replacing null with some string(ex "") Commented May 21, 2017 at 5:54
  • @PriyeshKumar Unfortunately same error occurred Commented May 21, 2017 at 5:59
  • Any other ideas on how to resolve? Commented May 21, 2017 at 6:09
  • Why you are sending null to codePush? Commented May 21, 2017 at 6:11

2 Answers 2

2
new CodePush("deployment-key", getApplicationContext(), BuildConfig.DEBUG)

deployment-key is a alpha-numeric string which you will get when you register your code-push account and it can't be null.

Sign up to request clarification or add additional context in comments.

Comments

0

Change instantiate of the CodePush to this:

new CodePush("deployment-key-here", MainApplication.this, BuildConfig.DEBUG)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.