gpt4 book ai didi

android - 安装 react-native-fbsdk 后,react-native run-android 失败并显示 "Task :app:compileDebugJavaWithJavac FAILED"

转载 作者:行者123 更新时间:2023-11-29 23:14:04 26 4
gpt4 key购买 nike

按照 react-native-fbsdk 的安装说明进行操作后, 命令 react native 运行android失败并出现以下错误:

info JS server already running.
info Building and installing the app on the device (cd android && gradlew.bat app:installDebug)...

> Task :app:compileDebugJavaWithJavac FAILED
C:\projects\veida\veida_v1\Erua3\android\app\src\main\java\com\erua3\MainActivity.java:12: error: cannot find symbol
public void onActivityResult(int requestCode, int resultCode, Intent data) {
^
symbol: class Intent
location: class MainActivity
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 4s
24 actionable tasks: 1 executed, 23 up-to-date
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag for more details.

我已经尝试重新安装 android studio 并在两个新项目中按照安装步骤执行两次。

我的 App.js 是默认的 App.js。我也尝试过将示例 App.js 与 Facebook 登录一起使用。

最佳答案

您可以通过在 MainActivity.java 中添加导入来修复它:

import android.content.Intent;

此外,此错误主要发生在您的 sdk 版本与 react-native-fbsdk 版本不同时。例如:比方说,build.gradle 中的 SDK 版本是:

buildscript {
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 19
compileSdkVersion = 27
targetSdkVersion = 27
supportLibVersion = "27.0.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.0.1'
}
}

但是在你的react-native-fbsdk中是不一样的

所以需要检查是否使用了相同的sdk版本。

Go to node_modules/react-native-fbsdk/android/build.gradle and comare the version with your project build.gradle.

关于android - 安装 react-native-fbsdk 后,react-native run-android 失败并显示 "Task :app:compileDebugJavaWithJavac FAILED",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55608724/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com