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

created at 09-30-2021 views: 8

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) ####

Reason for error

The compiler server defines the NDK_ROOT environment variable, which conflicts with the Android compiler environment variable.
Check whether the NDK_ROOT environment variable or the SDK_ROOT environment variable is defined.

echo $NDK_ROOT

My build server defines the NDK_ROOT environment variable, so echo $NDK_ROOT outputs the following path:
/XXX_NDK_ROOT/
Indicates that the amount of change is defined.

solution

Temporarily remove the environment variable

export NDK_ROOT=""

Continue to compile the system and it will be normal.

created at:09-30-2021
edited at: 09-30-2021: