首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何解决android编译错误“找不到符号”的反应-本机代码推送

如何解决android编译错误“找不到符号”的反应-本机代码推送
EN

Stack Overflow用户
提问于 2020-11-10 16:30:38
回答 1查看 1.5K关注 0票数 0

不知道这是什么问题。在Microsoft上构建/分发时,构建没有问题。我记得在成功构建代码推送之后,我所做的唯一一件事就是向build.gradle添加不同的部署键:

代码语言:javascript
复制
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", "CodePushDeploymentKey",  '"<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", "CodePushDeploymentKey", '"<key>"'
        }
    }

现在,当我尝试在android中构建时,我得到了以下错误:

代码语言:javascript
复制
> 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.

是什么导致了这一问题&如何解决这一问题?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-11-11 02:30:39

  1. 将导入保存在MainApplication.java中 进口com.microsoft.codepush.react.CodePush;
  2. 保留重写getJSBundleFile方法。
  3. 删除buildConfigFields并更新为此格式 resValue "string",

"reactNativeCodePush_androidDeploymentKey",'"<INSERT_PRODUCTION_KEY>"'

  1. 如果在strings.xml中添加了密钥,则将其移除。

按照提交的所有细节这里

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64772844

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档