1

当我尝试实现 codepush 时,我收到此错误:

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
70 actionable tasks: 7 executed, 63 up-to-date
/Users/lukeschoenberger/Documents/Programming/news-arg/test7/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:59: error: cannot find symbol
      new CodePush(getResources().getString(R.string.reactNativeCodePush_androidDeploymentKey), getApplicationContext(), BuildConfig.DEBUG),
                                                    ^
  symbol:   variable reactNativeCodePush_androidDeploymentKey
  location: class string
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 9s

这就是我配置 MainApplication.java 文件的方式:

package com.test7;


import com.microsoft.codepush.react.CodePush;

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

import com.facebook.react.PackageList;
import com.facebook.hermes.reactexecutor.HermesExecutorFactory;
import com.facebook.react.bridge.JavaScriptExecutorFactory;
import com.facebook.react.ReactApplication;
import com.oblador.vectoricons.VectorIconsPackage;
import com.amazonaws.RNAWSCognitoPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
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
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected String getJSBundleFile() {
        return CodePush.getJSBundleFile();
    }

    @Override
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            new CodePush("mykey", MainApplication.this, BuildConfig.DEBUG)
        );
    }

    @Override
    protected String getJSMainModuleName() {
      return "index";
    }
  };

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

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
  }
}

这是 Codepush 的首选实现:https ://github.com/Microsoft/react-native-code-push/blob/master/docs/setup-android.md

这是我从他们的实施中收到的第三个错误;我收到一个 MainReactPackage 错误和一个 Array 错误,但都通过各自的导入解决了。

4

1 回答 1

4

看起来您android\app\src\main\res\values\strings.xml没有reactNativeCodePush_androidDeploymentKey部署密钥的字段。reactNativeCodePush_androidDeploymentKey使用您的部署密钥添加文件。以下是该字段的示例:

<string name="reactNativeCodePush_androidDeploymentKey">deploymentKey</string>
于 2019-09-22T20:22:41.177 回答