[Solved] error: external/googletest/googletest: MODULE.TARGET.STATIC_LIBRARIES.libgtest already defined

Android9.0 System compilation error
170/978] including external/google-tv-pairing-protocol/Android.mk …
[171/978] including external/googletest/Android.mk …
build/make/core/base_rules.mk:260: error: external/googletest/googletest: MODULE.TARGET.STATIC_LIBRARIES.libgtest already defined by external/googletest/googletest.
09:42:55 ckati failed with: exit status 1
0;31m#### failed to build some targets (49 seconds) ####
The reason of the error
The compiler server has defined NDK_ROOT environment variable, which conflicts with Android compiler environment variable.
Check whether NDK_ROOT environment variable or SDK_ROOT environment variable is defined.

echo $NDK_ROOT

My compilation server defines NDK_Root environment variable, so echo $NDK_Root outputs the following path:
/xxx_NDK_Root/
indicates that the change amount is defined.

Solution:

Remove the environment variable temporarily

export NDK_ROOT=""

Continue to compile the system.

Read More: