微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何从react-native-code-push解决android编译错误'无法找到符号'

如何解决如何从react-native-code-push解决android编译错误'无法找到符号'

不确定这里的问题是什么。在Microsoft appcenter上构建/分发时,该构建没有问题。我记得代码构建成功后唯一要做的事情是向build.gradle添加了不同的部署密钥:

buildTypes {
        debug {
            signingConfig signingConfigs.debug
            // Note: CodePush updates should not be tested in Debug mode as they are overriden by the RN packager. However,because CodePush checks for updates in all modes,we must supply a key.
            // specifically left blank in appcenter docs
            resValue "string","CodePushDeploymentKey",'""'
        }
        releaseStaging {
            resValue "string",'"<key>"'

            // Note: It is a good idea to provide matchingFallbacks for the new buildType you create to prevent build issues
            // Add the following line if not already there
            matchingFallbacks = ['release']
        }
        release {
            // Caution! In production,you need to generate your own keystore file.
            // see https://facebook.github.io/react-native/docs/signed-apk-android.
            // signingConfig signingConfigs.release
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"),"proguard-rules.pro"
            resValue "string",'"<key>"'
        }
    }

现在,当我尝试从android studio中进行构建时,出现此错误

> Task :react-native-code-push:javaprecompiledebug UP-TO-DATE

> Task :react-native-code-push:compileDebugJavaWithJavac Failed
/Users/vorousjames/Desktop/Development/Slide/Slide/node_modules/react-native-code-push/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java:157: error: cannot find symbol
                isLiveReloadEnabled = devInternalSettings.isReloadOnjsChangeEnabled();
                                                         ^
  symbol:   method isReloadOnjsChangeEnabled()
  location: variable devInternalSettings of type DevInternalSettings
/Users/vorousjames/Desktop/Development/Slide/Slide/node_modules/react-native-code-push/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java:175: warning: [unchecked] unchecked cast
        List<ReactRootView> mAttachedRootViews = (List<ReactRootView>)mAttachedRootViewsField.get(instanceManager);
                                                                                                 ^
  required: List<ReactRootView>
  found:    Object
1 error
1 warning

FAILURE: Build Failed with an exception.

* What went wrong:
Execution Failed for task ':react-native-code-push:compileDebugJavaWithJavac'.
> Compilation Failed; see the compiler error output for details.

这是什么原因以及如何解决此问题?

解决方法

  1. 将导入保留在 MainApplication.java

    导入com.microsoft.codepush.react.CodePush;

  2. 保留覆盖getJSBundleFile 方法。

  3. 删除buildConfigFields并更新为这种格式

    resValue "string",

reactNativeCodePush_androidDeploymentKey”,'"<INSERT_PRODUCTION_KEY>"'

  1. 如果已将密钥从strings.xml中删除,则将其删除。

按照提交的所有详细信息here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。