我正在使用React Native开发一个应用程序,其中我试图在本地存储中创建一个文件并在该文件上编写。
但是由于以下错误,我无法构建项目
任务:app:compileDebugJavaWithJavac FAILED失败 F:\ ReactNativeWorkspace \ MyFirstProject \ android \ app \ src \ main \ java \ com \ myfirstproject \ MainApplication.java:5:错误:找不到符号 导入com.facebook.react.ReactApplication; ^ 符号:类ReactApplication 位置:包com.facebook.react F:\ ReactNativeWorkspace \ MyFirstProject \ android \ app \ src \ main \ java \ com \ myfirstproject \ MainApplication.java:8:错误:找不到符号 导入com.facebook.react.ReactNativeHost; ^ 符号:类ReactNativeHost 位置:包com.facebook.react F:\ ReactNativeWorkspace \ MyFirstProject \ android \ app \ src \ main \ java \ com \ myfirstproject \ MainApplication.java:16:错误:找不到符号 公共类MainApplication扩展应用程序实现ReactApplication { ^ 符号:类ReactApplication F:\ ReactNativeWorkspace \ MyFirstProject \ android \ app \ src \ main \ java \ com \ myfirstproject \ MainApplication.java:18:错误:找不到符号 私有最终ReactNativeHost mReactNativeHost =新的ReactNativeHost(this){ ^ 符号:类ReactNativeHost 位置:类MainApplication F:\ ReactNativeWorkspace \ MyFirstProject \ android \ app \ src \ main \ java \ com \ myfirstproject \ MainApplication.java:42:错误:找不到符号 公共ReactNativeHost getReactNativeHost(){ ^ 符号:类ReactNativeHost 位置:类MainApplication F:\ ReactNativeWorkspace \ MyFirstProject \ android \ app \ src \ main \ java \ com \ myfirstproject \ MainActivity.java:5:错误:MainActivity不是抽象的,并且不会覆盖ReactActivity中的抽象方法getPackages() 公共类MainActivity扩展了ReactActivity { ^ F:\ ReactNativeWorkspace \ MyFirstProject \ android \ app \ src \ main \ java \ com \ myfirstproject \ MainApplication.java:18:错误:找不到符号 私有最终ReactNativeHost mReactNativeHost =新的ReactNativeHost(this){ ^ 符号:类ReactNativeHost 位置:类MainApplication F:\ ReactNativeWorkspace \ MyFirstProject \ android \ app \ src \ main \ java \ com \ myfirstproject \ MainApplication.java:41:错误:方法未覆盖或从超类型实现方法 @Override ^ 8个错误
我的build.gradle文件..
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.myfirstproject"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
compile project(':react-native-fs')
// compile project(':react-native-filesystem')
compile project(':react-native-check-app-install')
// compile project(':react-native-cardview')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompatv7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
}