[英]Execution failed for task ':app:compileDebugJavaWithJavac'. React Native application for Android
I am trying to launch android emulator from my React Native application, But, Its throwing following error and emulator not able to launch in my MAC system. 我正在尝试从我的React Native应用程序启动android模拟器,但是,它引发以下错误并且模拟器无法在我的MAC系统中启动。
Error is
错误是
Configure project :app
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Configure project :react-native-app
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: Configuration 'testCompile' is obsolete and has been replaced with 'testImplementation' and 'testApi'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: Configuration 'testApi' is obsolete and has been replaced with 'testImplementation'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Configure project :react-native-version-number
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (23.0.1) is ignored, as it is below the minimum supported version (27.0.3) for
Android Gradle Plugin 3.1.4.
Android SDK Build Tools 27.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '23.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin
now has a default version of the build tools.
Download https://dl.google.com/dl/android/maven2/com/android/support/multidex/1.0.2/multidex-1.0.2.pom
Download https://dl.google.com/dl/android/maven2/com/android/support/multidex/1.0.2/multidex-1.0.2.aar
Task :app:compileDebugJavaWithJavac FAILED
/Users/anilkumar/Documents/projectName/android/app/src/main/java/com/projectName/MainApplication.java:19:
error: cannot find symbol
return BuildConfig.DEBUG;
^
symbol: variable BuildConfig
1 error
My build.gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules. //顶层构建文件,您可以在其中添加所有子项目/模块共有的配置选项。
buildscript {
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}
I am very new to React Native, Can anyone suggest me how to fix this? 我是React Native的新手,有人可以建议我如何解决此问题吗?
Finally I found answer by adding following code 最后我通过添加以下代码找到了答案
import statement in MainApplication.java
: MainApplication.java
import语句:
import com.facebook.react.BuildConfig;
Found answer in the following link 在以下链接中找到答案
React Native Android Build Error MainActivity.java:29: error: cannot find symbol React Native Android Build Error MainActivity.java:29:错误:找不到符号
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.