文档章节

[react-native开发中错误]SDK location not found. Define

张小贤
 张小贤
发布于 2016/02/28 22:29
字数 572
阅读 3554
收藏 1

运行react-native run android时没有配置 ANDROID_HOME导致的错误

错误日志

java.lang.RuntimeException: SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

at com.android.build.gradle.internal.SdkHandler.getAndCheckSdkFolder(SdkHandler.java:102)

at com.android.build.gradle.internal.SdkHandler.getSdkLoader(SdkHandler.java:112)

at com.android.build.gradle.internal.SdkHandler.initTarget(SdkHandler.java:86)

at com.android.build.gradle.BasePlugin.ensureTargetSetup(BasePlugin.groovy:507)

at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.groovy:455)

at com.android.build.gradle.BasePlugin$_createTasks_closure13_closure17.doCall(BasePlugin.groovy:415)

at com.android.build.gradle.BasePlugin$_createTasks_closure13_closure17.doCall(BasePlugin.groovy)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)

at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)

at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:292)

at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1015)

at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:39)

at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)

at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:54)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)

at com.android.build.gradle.internal.profile.SpanRecorders$2.call(SpanRecorders.groovy:52)

at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:48)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSite.invoke(PojoMetaMethodSite.java:189)

at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)

at com.android.build.gradle.internal.profile.SpanRecorders.record(SpanRecorders.groovy:54)

at com.android.build.gradle.BasePlugin$_createTasks_closure13.doCall(BasePlugin.groovy:414)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)

at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)

at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:292)

at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1015)

at groovy.lang.Closure.call(Closure.java:423)

at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:40)

at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25)

at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:87)

at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:31)

at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)

at com.sun.proxy.$Proxy11.afterEvaluate(Unknown Source)

at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:67)

at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:61)

at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:487)

at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:85)

at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:47)

at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)

at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:129)

at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)

at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)

at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:90)

at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)

at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)

at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)

at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)

at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:50)

at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:27)

at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:40)

at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:169)

at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)

at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)

at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)

at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)

at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)

at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)

at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)

at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)

at org.gradle.launcher.Main.doAction(Main.java:33)

at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)

at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)

at org.gradle.launcher.GradleMain.main(GradleMain.java:23)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)

at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:127)

at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)


FAILURE: Build failed with an exception.


* Where:

Build file '/Users/qxian/Desktop/AwesomeProject/android/app/build.gradle' line: 103


* What went wrong:

A problem occurred evaluating project ':app'.

> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.


* 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: 8.827 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环境变量即可解决

具体方法参见这里

© 著作权归作者所有

共有 人打赏支持
张小贤
粉丝 9
博文 46
码字总数 11139
作品 0
福州
私信 提问
React Native SDK location not found

React Native java.lang.RuntimeException: SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable. 找了好久......

孙冠峰
2015/12/15
1K
1
react Native 运行程序报错解决笔记

命令行执行 报如下错误: Exception in thread "main" java.net.UnknownHostException: services.gradle.org 解决方案: 修改hosts文件,增加如下 127.0.0.1 主机名 ps:127.0.0.1 Administrat......

情人情人
2016/04/14
172
0
React Native开发之——Webstorm快捷开发

前言 开发RN的工具有很多,选择性也比较多,常见的有: WebStorm Sublime Text 3 VS Code Nuclide 其他 本文以Webstorm为例讲解 使用Webstorm开发React Native 注:本文默认已配置好React N...

青衫无名
07/16
0
0
RN学习第一篇:MAC配置RN环境

我们在使用之前我们最基本的就是环境的搭建,不能搭建环境,一切白搭,这篇文章我就简单的介绍一下环境搭建过程,并且运行第一个项目 React Native搭建开发环境.png 文章目录 1、React Nativ...

辉哥de简书
2017/12/24
0
0
reactive-native环境 我的是WINDOWS 32位

1:前面下载ANDRODID STUDIO 时使用JDK1.8 在安装JDK1.8 的时候会产生2个文件夹 一个是JDK的一个是JRE 环境变量设为JDK的 不然在运行 react-native run-android时会出现无法找到TOOLS.JAR 的...

李东战
2016/12/28
0
0

没有更多内容

加载失败,请刷新页面

加载更多

走上真正的教育之路——《中国最美的语文》读后感3100字

走上真正的教育之路——《中国最美的语文》读后感3100字: 文:张平。《中国最美的语文》,乍一听,你可能会觉得这个作者或者编辑有些大言不惭,竟然起这么大而狂的名字,可能名不副实。我没...

原创小博客
11分钟前
0
0
tomcat线程模型

Connector结构 BIO模式 NIO模式

grace_233
32分钟前
2
0
Javascript

变量定义 以$,_,字母开头 大小写敏感 var 关键字声明变量 声明未赋值undefined 数据类型 字符串,数字,布尔,数组,NULL,undefined 变量均为对象 函数 无默认值 var声明的是局部变量 函数外声明...

关元
33分钟前
1
0
文件系统、服务、防火墙、SELINUX——安全四大金刚

一提到安全,大家都会想到防火墙,和文件系统权限。而实际工作环境中,我们在Linux的安全配置,会涉及到四个级别。我们思考一个场景,你要在百度盘中存放一个文件,这个动作需要考虑下面四个...

Linux就该这么学
34分钟前
1
0
从源码角度理解Java设计模式——门面模式

一、门面模式介绍 门面模式定义:也叫外观模式,定义了一个访问子系统的接口,除了这个接口以外,不允许其他访问子系统的行为发生。 适用场景:子系统很复杂时,增加一个接口供外部访问。 优...

我叫刘半仙
44分钟前
2
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部