I was running my existing React Native Project in my real android device. Then somehow this error pop up. The error are always about "cannot find symbol". I have JDK and SDK and add into my system variables. But I still do not know why it gives me error like this. As I remember, I just downgrade the version of react-native.
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.). D:\rnprojects\firstproject\android\app\src\main\java\com\emptyprojecttemplate\MainApplication.java:5: error: cannot find symbol import com.facebook.react.ReactApplication; ^ symbol: class ReactApplication location: package com.facebook.react D:\rnprojects\firstproject\android\app\src\main\java\com\emptyprojecttemplate\MainApplication.java:6: error: cannot find symbol import com.facebook.react.ReactNativeHost; ^ symbol: class ReactNativeHost location: package com.facebook.react D:\rnprojects\firstproject\android\app\src\main\java\com\emptyprojecttemplate\MainApplication.java:14: error: cannot find symbol public class MainApplication extends Application implements ReactApplication { ^ symbol: class ReactApplication D:\rnprojects\firstproject\android\app\src\main\java\com\emptyprojecttemplate\MainApplication.java:16: error: cannot find symbol private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { ^ symbol: class ReactNativeHost location: class MainApplication D:\rnprojects\firstproject\android\app\src\main\java\com\emptyprojecttemplate\MainApplication.java:36: error: cannot find symbol public ReactNativeHost getReactNativeHost() { ^ symbol: class ReactNativeHost location: class MainApplication D:\rnprojects\firstproject\android\app\src\main\java\com\emptyprojecttemplate\MainActivity.java:5: error: MainActivity is not abstract and does not override abstract method getPackages() in ReactActivity public class MainActivity extends ReactActivity { ^ D:\rnprojects\firstproject\android\app\src\main\java\com\emptyprojecttemplate\MainApplication.java:16: error: cannot find symbol private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { ^ symbol: class ReactNativeHost location: class MainApplication D:\rnprojects\firstproject\android\app\src\main\java\com\emptyprojecttemplate\MainApplication.java:35: error: method does not override or implement a method from a supertype @Override ^ 8 errors :app:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'. Compilation failed; see the compiler error output for details.
Build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
Build.gradle/app:
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.emptyprojecttemplate"
minSdkVersion 16
targetSdkVersion 22
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 fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}