当我运行react native run android时,我得到以下错误:;我正在将其设置为在设备上运行。
:app:compileDebugJava
/Users/hello/MediaFire/apps/test2/android/app/src/main/java/com/test2/MainApplication.java:6: error: cannot find symbol
import com.facebook.react.ReactApplication;
^
symbol: class ReactApplication
location: package com.facebook.react
/Users/hello/MediaFire/apps/test2/android/app/src/main/java/com/test2/MainApplication.java:8: error: cannot find symbol
import com.facebook.react.ReactNativeHost;
^
symbol: class ReactNativeHost
location: package com.facebook.react
/Users/hello/MediaFire/apps/test2/android/app/src/main/java/com/test2/MainApplication.java:15: error: cannot find symbol
public class MainApplication extends Application implements ReactApplication {
^
symbol: class ReactApplication
/Users/hello/MediaFire/apps/test2/android/app/src/main/java/com/test2/MainApplication.java:17: error: cannot find symbol
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
^
symbol: class ReactNativeHost
location: class MainApplication
/Users/hello/MediaFire/apps/v/android/app/src/main/java/com/test2/MainApplication.java:32: error: cannot find symbol
public ReactNativeHost getReactNativeHost() {
^
symbol: class ReactNativeHost
location: class MainApplication
/Users/hello/MediaFire/apps/test2/android/app/src/main/java/com/test2/MainActivity.java:6: error: MainActivity is not abstract and does not override abstract method getPackages() in ReactActivity
public class MainActivity extends ReactActivity {
^
/Users/hello/MediaFire/apps/test2/android/app/src/main/java/com/test2/MainApplication.java:17: error: cannot find symbol
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
^
symbol: class ReactNativeHost
location: class MainApplication
/Users/hello/MediaFire/apps/test2/android/app/src/main/java/com/test2/MainApplication.java:31: error: method does not override or implement a method from a supertype
@Override
^
8 errors
:app:compileDebugJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJava'.
> 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.
BUILD FAILED
Total time: 10.738 secs
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/android-setup.html
检查构建。android中的gradle(项目)文件:
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
可能缺少这一行,请将其添加到存储库下,应如下所示:
allprojects {
repositories {
mavenLocal()
jcenter()
google()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
我使用react native upgrade解决了此问题
参考:Overload119的答案
我正在React Native 0.59.1上构建一个项目,但当我添加React Native youtube时,我在运行react-native run-android时遇到以下错误
\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\rncwebviewmanager.java:54:错误:包com.reactnativecommunity.webview.events不存在 使用: React-Native-CLI:2.0.1 React-Nati
我刚开始使用React-Native。我尝试使用在我的应用程序中添加google map 我参考了https://github.com/react-community/react-native-maps/blob/master/docs/installation.md并按照所有步骤操作。我获得Google API并将其放入AndroidManifest。我的Google Play服务版本是14.5
单击此处查看错误图像 我有这个错误,当我运行反应本机run-android在我的设备上,我怎么能修复它? 我运行这个: react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --
我正在研究MacOS,刚从开始。 开始的第一步之一是运行:或。但我得到了这个错误: 结果: 这是运行时得到的结果: 有什么办法解决这个问题吗?