If using ui:: function, android build is failed

CUiScene.h

		void sliderMove(Ref* ref, ui::Slider::EventType type);
		void sliderTouch(Ref* ref, ui::Widget::TouchEventType type);

CUiScene.cpp

			void CUiScene::sliderMove(Ref * ref, ui::Slider::EventType type)
			{
				if (type == ui::Slider::EventType::ON_PERCENTAGE_CHANGED) {		
					auto obj = this->getChildByName("dice");
					auto slider = (ui::Slider*)ref;
					float Slider_Percentage = slider->getPercent();

					//obj->setScale(Slider_Percentage / 20);
					obj->setPositionX(Slider_Percentage*10);

					if (AudioEngine::getState(sound_index) == AudioEngine::AudioState::PLAYING) {		
						experimental::AudioEngine::setVolume(sound_index, Slider_Percentage);		
					}

					auto load = (ui::LoadingBar*)this->getChildByName("BgBar")->getChildByName("LD");
					load->setPercent(Slider_Percentage);
				}
			}

			void CUiScene::sliderTouch(Ref * ref, ui::Widget::TouchEventType type)
			{
				if (type == ui::Widget::TouchEventType::ENDED) {	
					auto slider = (ui::Slider*)ref;
					float Slider_Percentage = slider->getPercent();		
					if (Slider_Percentage <= 12.5f) {	
						slider->setPercent(0);
					}
					else if (Slider_Percentage > 12.5f && Slider_Percentage<=37.5f) {
						slider->setPercent(25);
					}
					else if (Slider_Percentage > 37.5f && Slider_Percentage <= 62.5f) {
						slider->setPercent(50);
					}
					else if (Slider_Percentage > 62.5 && Slider_Percentage <= 87.5f) {
						slider->setPercent(75);
					}
					else {
						slider->setPercent(100);
					}
				}
			}

Android.mk

	LOCAL_PATH := $(call my-dir)

	include $(CLEAR_VARS)

	$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d)
	$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d/external)
	$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d/cocos)
	$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d/cocos/audio/include)

	LOCAL_MODULE := MyGame_shared

	LOCAL_MODULE_FILENAME := libMyGame

	LOCAL_SRC_FILES := $(LOCAL_PATH)/hellocpp/main.cpp \
			   $(LOCAL_PATH)/../../../Classes/AppDelegate.cpp \
			   $(LOCAL_PATH)/../../../Classes/HelloWorldScene.cpp\
			   $(LOCAL_PATH)/../../../proj.win32/CUiScene.cpp


	LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../Classes

	# _COCOS_HEADER_ANDROID_BEGIN
	# _COCOS_HEADER_ANDROID_END


	LOCAL_STATIC_LIBRARIES := cocos2dx_static

	# _COCOS_LIB_ANDROID_BEGIN
	# _COCOS_LIB_ANDROID_END

	include $(BUILD_SHARED_LIBRARY)

	$(call import-module,.)

	# _COCOS_LIB_IMPORT_ANDROID_BEGIN
	# _COCOS_LIB_IMPORT_ANDROID_END

if i using ui functions, and build for android, build is fail
because of not added front of ui, cocos2d::
if i change all ui:;~ to cocos2d::ui::~, problem is solved.
but I want only using ui::~
in VS2017, I using USING_NS_CC, so I didn’t write cocos2d:;~
but android build has problem.
how can I fix this problem?

What error when you compile for Android?

		D:/uiExp/proj.android-studio/app/jni/../../../Classes/../proj.win32/CUiScene.h:1
		7:28: error: reference to 'ui' is ambiguous
		  void sliderMove(Ref* ref, ui::Slider::EventType type);
					    ^
		In file included from D:/uiExp/cocos2d/cocos/3d/../base/CCProtocols.h:34:0,
				 from D:/uiExp/cocos2d/cocos/3d/../2d/CCNode.h:35,
				 from D:/uiExp/cocos2d/cocos/3d/../2d/CCScene.h:32,
				 from D:/uiExp/cocos2d/cocos/3d/../base/CCDirector.h:38,
				 from D:/uiExp/cocos2d/cocos/3d/../base/CCAsyncTaskPool.h:29,
				 from D:/uiExp/cocos2d/cocos/3d/../cocos2d.h:41,
				 from D:/uiExp/proj.android-studio/app/jni/../../../proj.win32/C
		UiScene.h:2,
				 from D:/uiExp/proj.android-studio/app/jni/../../../proj.win32/C
		UiScene.cpp:1:
		D:/uiExp/cocos2d/cocos/3d/../renderer/CCTexture2D.h:46:1: note:
		namespace cocos2d::ui { }
		 {
		 ^
		D:/uiExp/proj.android-studio/app/jni/../../../proj.win32/CUiScene.cpp:139:18: er
		ror: reference to 'ui' is ambiguous
		   auto slider = (ui::Slider*)ref;
				  ^
		In file included from D:/uiExp/cocos2d/cocos/3d/../ui/CocosGUI.h:50:0,
				 from D:/uiExp/proj.android-studio/app/jni/../../../proj.win32/C
		UiScene.h:5,
				 from D:/uiExp/proj.android-studio/app/jni/../../../proj.win32/C
		UiScene.cpp:1:
		D:/uiExp/cocos2d/cocos/3d/../ui/UIVideoPlayer.h:39:17: note: candidates are: nam
		espace cocos2d::experimental::ui { }
		     namespace ui{
				 ^
		In file included from D:/uiExp/cocos2d/cocos/3d/../ui/CocosGUI.h:50:0,
				 from D:/uiExp/proj.android-studio/app/jni/../../../Classes/../p
		roj.win32/CUiScene.h:5,
				 from D:/uiExp/proj.android-studio/app/jni/../../../Classes/AppD
		elegate.cpp:2:
		D:/uiExp/cocos2d/cocos/3d/../ui/UIVideoPlayer.h:39:17: note: candidates are: nam
		espace cocos2d::experimental::ui { }
		     namespace ui{

all error is making from ui::slider or ui::button.
but if i change ui::->cocos2d::ui::
No error occurs

Yes, because there are two ui namespaces:

  • cocos2d::ui
  • cocos2d::experimental::ui

And it seems you using them like this:

using namespace cocos2d::ui;
using namespace cocos2d::experimental::ui;

And as result reference to ‘ui’ is ambiguous.

So, I suggest you to remove one using namespace and in code use full name instead.