# 为什么打包工具会清除环境变量? 这导致NDKROOT is not specified的错误

**URL:** <https://forums.unrealengine.com/t/ndkroot-is-not-specified/785001>\
**Category:** Mobile\
**Tags:** unreal-engine, Android, bug-report, question\
**Created:** [March 6, 2023, 4:29pm UTC](https://forums.unrealengine.com/t/ndkroot-is-not-specified/785001 "2023-03-06T16:29:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sincky8](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sincky8](https://forums.unrealengine.com/u/Sincky8)\
**Post date:** [March 6, 2023, 4:29pm UTC](https://forums.unrealengine.com/t/ndkroot-is-not-specified/785001/1 "2023-03-06T16:29:52Z")

</div>

# 前提

NDK、Android SDK都已经正确配置在环境变量里。

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/3/9/03994377cce5874b9c0da8d1174fa674d5d6d8cd.png)

# 问题

当我尝试Android打包时，出现：  
NDKROOT is not specified  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/a/c/eac21c6ee631d7434afb81ce7f059dfa24b398a2.png)

# 疑问

后面我通过改动源码发现，一开始是能打印ndk path的，最后却找不到，我怀疑中间清楚过环境变量。

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/b/5/9b593da87cc4dff90b965aeaa54a087b8cffa438.png)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/8/f/98f69106c06ac690ab707e4c0f96c4b5ae98772a.png)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/8/1/c81fd405624452a0a8ec9cc21ff33b2dcfa35e0f.png)

这个应该是个bug，请修复它

---

<div class="post-metadata">

**Author:** ![hyperdr1ve](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@hyperdr1ve](https://forums.unrealengine.com/u/hyperdr1ve)\
**Post date:** [March 6, 2023, 10:40pm UTC](https://forums.unrealengine.com/t/ndkroot-is-not-specified/785001/2 "2023-03-06T22:40:55Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/2/9/7296c4ab9fffcd9ad682d85913d31744377b9d67.png)  
Do you have a space or empty character in the circled box? This would override the variable. Make sure the box is empty if you want to use the `NDKROOT` environment variable.

---

<div class="post-metadata">

**Author:** ![Sincky8](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sincky8](https://forums.unrealengine.com/u/Sincky8)\
**Post date:** [March 12, 2023, 8:45am UTC](https://forums.unrealengine.com/t/ndkroot-is-not-specified/785001/3 "2023-03-12T08:45:43Z")

</div>

when the error came, it is empty and no characters in the sdk config.

btw, the sdk config has been changed and saved before, but it is empty now, the problem is also exists.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/0/d/a0d6e7e5a5c52ae7f259b9d068aea8b07958f356.png)
