提问人:Beibarys Sultan 提问时间:11/15/2023 最后编辑:Beibarys Sultan 更新时间:11/15/2023 访问量:79
在 Android 上运行 Expo 项目时出错:BuildConfig 和 R 的“找不到符号”;“反应原生”:“0.72.6”
Error when running Expo project on Android: "cannot find symbol" for BuildConfig and R; "react-native": "0.72.6"
问:
你好 Stack Overflow 社区!
尝试使用 expo run:android 命令在 Android 上运行我的 Expo 项目时,我遇到了一个问题。我遇到以下编译错误:
> Task :app:compileDebugJavaWithJavac FAILED
/home/(USERNAME)/Desktop/professional/projects/expo/(PROJECT_NAME)/android/app/src/main/java/com/(PACKAGE)/(PROJECT_NAME)/MainApplication.java:18: error: cannot find symbol
import com.(PACKAGE).(PROJECT_NAME).BuildConfig;
^
symbol: class BuildConfig
location: package com.(PACKAGE).(PROJECT_NAME)
/home/(USERNAME)/Desktop/professional/projects/expo/(PROJECT_NAME)/android/app/src/main/java/com/(PACKAGE)/(PROJECT_NAME)/MainApplication.java:28: error: cannot find symbol
return BuildConfig.DEBUG;
^
symbol: variable BuildConfig
/home/(USERNAME)/Desktop/professional/projects/expo/(PROJECT_NAME)/android/app/src/main/java/com/(PACKAGE)/(PROJECT_NAME)/MainApplication.java:47: error: cannot find symbol
return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
^
symbol: variable BuildConfig
/home/(USERNAME)/Desktop/professional/projects/expo/(PROJECT_NAME)/android/app/src/main/java/com/(PACKAGE)/(PROJECT_NAME)/MainApplication.java:52: error: cannot find symbol
return BuildConfig.IS_HERMES_ENABLED;
^
symbol: variable BuildConfig
/home/(USERNAME)/Desktop/professional/projects/expo/(PROJECT_NAME)/android/app/src/main/java/com/(PACKAGE)/(PROJECT_NAME)/MainApplication.java:65: error: cannot find symbol
if (!BuildConfig.REACT_NATIVE_UNSTABLE_USE_RUNTIME_SCHEDULER_ALWAYS) {
^
symbol: variable BuildConfig
location: class MainApplication
/home/(USERNAME)/Desktop/professional/projects/expo/(PROJECT_NAME)/android/app/src/main/java/com/(PACKAGE)/(PROJECT_NAME)/MainApplication.java:68: error: cannot find symbol
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
^
symbol: variable BuildConfig
location: class MainApplication
/home/(USERNAME)/Desktop/professional/projects/expo/(PROJECT_NAME)/android/app/src/main/java/com/(PACKAGE)/(PROJECT_NAME)/MainActivity.java:19: error: package R does not exist
setTheme(R.style.AppTheme);
^
/home/(USERNAME)/Desktop/professional/projects/expo/(PROJECT_NAME)/android/app/src/main/java/com/(PACKAGE)/(PROJECT_NAME)/MainActivity.java:39: error: cannot find symbol
return new ReactActivityDelegateWrapper(this, BuildConfig.IS_NEW_ARCHITECTURE_ENABLED, new DefaultReactActivityDelegate(
^
symbol: variable BuildConfig
location: class MainActivity
8 errors
FAILURE: Build failed with an exception.
我尝试更改“react-native”的库版本并清除“gradlew clean”我的 android 缓存并再次执行“expo run:android”。
编译器无法找到由 Gradle 构建过程生成的 BuildConfig 类。 编译器找不到“R”包。
我查看了其他类似的案例,他们建议我更改库的版本,但这并没有解决我的问题!
在查看错误消息时,我注意到这些问题与缺少符号 BuildConfig 和 R 有关。我相信这些资源应该可用,但编译器无法找到它们。
您能就如何解决这个问题提供建议吗?我使用 Expo 来初始化项目,直到现在一切都很好。也许有人遇到过类似的问题,可以分享他们的经验或提出解决方案?
值得一提的是,我在 Ubuntu 22 上运行它。
提前感谢您的帮助!
这是我的“package.json”文件:
"name": "(PROJECT_NAME)",
"version": "1.0.0",
"dependencies": {
"@likashefqet/react-native-image-zoom": "^2.1.1",
"@react-navigation/bottom-tabs": "^6.5.9",
"@react-navigation/native": "^6.1.8",
"@react-navigation/native-stack": "^6.9.14",
"@types/react-query": "^1.2.9",
"@ui-kitten/components": "^5.3.1",
"axios": "^1.5.1",
"expo": "^49.0.16",
"expo-splash-screen": "~0.20.5",
"expo-status-bar": "~1.6.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.72.6",
"react-native-alert-notification": "^0.3.5",
"react-native-gesture-handler": "~2.12.0",
"react-native-pinchable": "^0.2.1",
"react-native-popup-menu": "^0.16.1",
"react-native-reanimated": "^3.4.0",
"react-native-reanimated-carousel": "^3.5.1",
"react-native-safe-area-context": "4.6.3",
"react-native-screens": "~3.22.0",
"react-native-star-rating-widget": "^1.7.2",
"react-native-svg": "13.9.0",
"react-native-web": "~0.19.6",
"react-query": "^3.39.3",
"zustand": "^4.4.2"
},
}```
答: 暂无答案
评论