Change NDK PATH after setup.py

I am struggling to change my NDK Path, in the setup.py file. This results in that I can’t use cmd with cocos command to run projects since it keeps reffering to ndk-r10e to do the build, and I’ve now changed to ndk-9c.
How can I change this?
I’ve already changed the environment variable to the proper ndk-9c one, but I cant fingure out how to change the path set in setup.py.

hi @froggan

I believe you are in a PC when you said cmd.
If that’s the case then it’s very easy to change.

Just follow these steps -

  1. Press windows button and go to run.
  2. In there, type environment variables.
  3. Inside there in the first part, there should be user environment variables.
  4. check for NDK_ROOT, it should be there.
  5. click on edit, and change the path to the new one. (in your case r9c).

This will change your NDK_ROOT environment variable.
Now, run setup.py again, it will show you the updated NDK_ROOT.

NOTE:
Also, I would like to recommend you to use recommended NDK and SDK for versions of Cocos2d-x.

Hope this helps.
Happy Coding :smile:

Hi @pabitrapadhy
thanks for the reply.

I am indeed on PC, and I thought that would be enough to change the environment variable.
My case is that I’ve changed the environment variable to the following:
C:\Users\Julian\Private\AndroidDev\android-ndk-r9d

Yet if I run setup.py it shows me the following:

->Check environment variable NDK_ROOT
->Search for environment variable NDK_ROOT…
->NDK_ROOT is found : C:\Users\Julian\Private\AndroidDev\android-ndk-r10e

I’ve removed ndk-r10e, and therefore if i try to run a project it will give me an error saying the following:

NDK build mode: debug
Parse NDK version from file C:\Users\Julian\Private\AndroidDev\android-ndk-r10e
RELEASE.TXT failed.
NDK_TOOLCHAIN_VERSION: 4.8
running: ‘C:\Users\Julian\Private\AndroidDev\android-ndk-r10e\ndk-build -C C:\An
droidTest\AndroidTest\proj.android -j4 NDK_MODULE_PATH=C:\AndroidTest\AndroidTes
t\proj.android…/cocos2d;C:\AndroidTest\AndroidTest\proj.android…/cocos2d/coc
os;C:\AndroidTest\AndroidTest\proj.android…/cocos2d/external NDK_TOOLCHAIN_VER
SION=4.8 NDK_DEBUG=1’

The system cannot find the path specified.
Ndk build failed!

I was under the impression that r9c is the recommended NDK, as r10e gave me a lot of compilations error with different std:: functions etc.

AFAIK, R9D was the most stable one.

Also, please check if there are more than one variables named NDK_ROOT
both in user and in system environment variables.

If all are changed to your latest ndk, please restart your system again.

1 Like

Ahh, yes.
I forogot to restart my system.
I apologize for my stupidity, thank you for your help!

If anyone else have the same problem on Windows, simply change the environment variables and then restart the system.

yes, because environment variables are variables defined in OS.
So, it will take effect in next instance of OS.

Glad that helped… :smile: