2017-05-21 51 views
0

在成功運行React-Native for Android之後,我遇到了以下錯誤。在React-Native中運行Android CodePush

: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 

我按照回購的指示,不知道這是爲什麼連看這個https://github.com/Microsoft/react-native-code-push/issues/790

後,這裏是我的完整的上下文MainApplication.java存在的。

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; 
    } 
} 

發生此錯誤的原因是什麼?如何解決?在CodePush的

+0

嘗試用一些字符串替換null(例如「」) –

+0

@PriyeshKumar與此同時發生的錯誤 –

+0

有關如何解決的其他想法? –

回答

0

更改實例化這樣的:

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

deployment-key是字母數字字符串,當你註冊你的代碼推帳戶,它不能爲空,你會得到。