React Native Android Build Error MainActivity.java:29: 错误:找不到符号 [英] React Native Android Build Error MainActivity.java:29: error: cannot find symbol

查看:23
本文介绍了React Native Android Build Error MainActivity.java:29: 错误:找不到符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试编译我的 React Native android 应用程序时遇到此错误.Android 应用无法解析 BuildConfig.DEBUG.

I'm getting this error when trying to compile my React Native android app. The Android app can't resolve BuildConfig.DEBUG.

:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac
/Users/amirsharif/mobile-rappad/android/app/src/main/java/com/rappadmobile/MainActivity.java:29: error: cannot find symbol
                .setUseDeveloperSupport(BuildConfig.DEBUG)
                                        ^
  symbol:   variable BuildConfig
  location: class MainActivity
>1 error
:app:compileDebugJavaWithJavac FAILED

我可以通过简单地将其设置为 true 来暂时解决它.这可能是在我更改应用程序名称后发生的(因为我也一直在尝试这样做).

I can temporarily resolve it by simply setting it to true. This might've happened after I changed an application name (since that's something I've also been trying to do).

我可能需要对 Gradle 进行一些更改,以便它再次生成正确类型的文件.

I probably have to change something with Gradle so it generates the right kind of files again.

/**
 * Automatically generated file. DO NOT MODIFY
 */
package com.app;

public final class BuildConfig {
  public static final boolean DEBUG = Boolean.parseBoolean("true");
  public static final String APPLICATION_ID = "com.rappadmobile";
  public static final String BUILD_TYPE = "debug";
  public static final String FLAVOR = "";
  public static final int VERSION_CODE = 1;
  public static final String VERSION_NAME = "1.0";
}

推荐答案

我使用 react-native upgrade 重建了项目.我的问题是我有引用旧包名称的旧文件(因为我在 package.json 中更改了应用程序的名称).删除这些后,我解决了这个问题.

I rebuilt the project with react-native upgrade. My issue was then that I had old files that were referencing the old package names (because I changed the name of the app in package.json). Once deleting those, I resolved the issue.

这篇关于React Native Android Build Error MainActivity.java:29: 错误:找不到符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆