Visual studio 2015 android project setup and build problems

does anyone know how to run the proj.visualstudio for cocos2d-x 3.12 in visual studio 2015 … i the downloaded project from Here.

am using visual studio 2015 update 3 with:
NDK: android-ndk-r13b-windows-x86_64
ANT: apache-ant-1.9.7
Java: jdk-7u80-windows-x64

i don’t know if i’m right or wrong but this is what i did:

first i knew that my current visual studio installation isn’t setup to run android projects

so i modified my current visual studio installation and insalled these new packages

under visual c++ mobile devlopement tab i installed the folwing packages :

visual c++ android devlopement (update 3)
clang with microsoft codegen (july 2016)
microsoft visual studio emulater for android (july 2016) ... hyper v has to be enabled or else the option wont show up in the installation menu

and under common tools and software devlopement kits i installed the following packages:

android sdk [3rd Party]
android sdk setup (api 19 and 21) [3rd Party]

as for ANT, NDK, JDK i have them downloaded manualy along time ago

after that i opened Tools->Options->Cross Platform->Android to specify the ANT, NDK, JDK paths:

the problem now is that the run button is showing “No devices available” once i open the project

but if you look at my avd manager you can see that there is a device that i created … so for some reason it doesn’t recognize it?

i decided to ignore it and hit run anyways but sadly i get this compiler error after build:

Error MSB3030 Could not copy the file "E:\Cocos2d-dev-tools\cocos2d-c++\android-ndk-r13b-windows-x86_64\android-ndk-r13b\sources\cxx-stl\gnu-libstdc++\4.9\libs\armeabi-v7a\thumb\libgnustl_static.a" because it was not found.

but i didn’t stop there … i tried again and after a bit of googling i got around the problem of "No devices available" by changing the solution active config from Debug|ARM to Debug|x86

and then i choose an api-19 complaint device witch i downloded before and hit run then i get this compiler errors … wired chipmunk errors

Error		Unable to open file C:\Users\Joseph\Documents\TestGame\proj.visualstudio\x86\Debug\libcocos2dcpp.so.recipe because 2	Cocos2d	C:\Program Files (x86)\MSBuild\Microsoft\MDD\Android\V140\Android.Common.targets	231	
Error		'chipmunk/chipmunk_private.h' file not found	Cocos2dcpp	C:\Users\Joseph\Documents\TestGame\cocos2d\cocos\physics\CCPhysicsBody.cpp	31	
Error		'chipmunk/chipmunk_private.h' file not found	Cocos2dcpp	C:\Users\Joseph\Documents\TestGame\cocos2d\cocos\physics\CCPhysicsWorld.cpp	30	
Error		'chipmunk/chipmunk.h' file not found	Cocos2dcpp	C:\Users\Joseph\Documents\TestGame\cocos2d\cocos\physics\CCPhysicsJoint.cpp	27	
Error		'chipmunk/chipmunk.h' file not found	Cocos2dcpp	C:\Users\Joseph\Documents\TestGame\cocos2d\cocos\physics\CCPhysicsShape.cpp	31	
Error		'chipmunk/chipmunk.h' file not found	Cocos2dcpp	C:\Users\Joseph\Documents\TestGame\cocos2d\cocos\physics\CCPhysicsContact.cpp	26	
Error		%lu", __func__, result);	Cocos2dcpp	C:\Users\Joseph\Documents\TestGame\proj.visualstudio\Cocos2dcpp\CLANGCOMPILE	1	
Error		%lu", __func__, result);	Cocos2dcpp	C:\Users\Joseph\Documents\TestGame\proj.visualstudio\Cocos2dcpp\CLANGCOMPILE	1	
Error		%lu", __func__, result);	Cocos2dcpp	C:\Users\Joseph\Documents\TestGame\proj.visualstudio\Cocos2dcpp\CLANGCOMPILE	1	
Error		%lu", __func__, result);	Cocos2dcpp	C:\Users\Joseph\Documents\TestGame\proj.visualstudio\Cocos2dcpp\CLANGCOMPILE	1	

please if anyone has any ideas Help.

Update 1:

i managed to get a successful ARM build after downgrading the ndk to r11c and keeping debug|arm as the active config but even after the build succeeds there is no devices to deploy to so now am back to the problem of no devices.

Update 2:

i’m getting closer to success … now am able to get a successful X86 build but only after updating cocos2d-x version to 3.13.1 and downloading its corresponding visual studio android project from the post mentioned before … but now even after the build succeeds there is a new problem when the build finishes and the x86 emulator starts up then an error message pops up:

unable to start debugging the package 'com.CocosVisualStudio' did not start on emulator or device.

and if i go to the app tray in the emulator i can see the cocos2d app installed in there but if i run it the device stops responding and the screen goes black for a couple of seconds and then a message:
unfortunately CocosVisualStudio has stopped.

P.S 1:
to be honest it didn’t compile successfully right from the start … i had to first get rid of some chipmunk2d errors that i got after compiling the project by manually removing the “chipmunk/” part from all the chipmunk2d errors and am sure there is better way of doing this but for now it worked fine and the build succeed.

P.S 2:
i too got chipmunk2d errors when i compile cocos2d-x 3.12 proj.visualstudio and with x86 as the active platform but when fixed them manually like in 3.13.1 it didn’t work because there were other errors that i couldn’t fix so i guess every one should stay of cocos2d-x 3.12 proj.visualstudio as obviously there is something wrong with it.

Update 3:

after looking at the emulator logcat when the app is launched i see this:

cocos2d-x debug info: OpenGL error 0x0502 in ..\..\cocos2d\cocos\renderer\CCTexture2D.cpp initWithMipmaps 663
cocos2d-x debug info: OpenGL error 0x0501 in ..\..\cocos2d\cocos\renderer\CCTexture2D.cpp initWithMipmaps 663
cocos2d-x debug info: OpenGL error 0x0501 in ..\..\cocos2d\cocos\renderer\CCTexture2D.cpp initWithMipmaps 663
EGL_emulation: eglSurfaceAttrib not implemented

i don’t know why am getting these rendring related errors?

so now as it seems … the build succeeds but when it runs it can’t render?

by the way in Troubleshooting the Visual Studio Emulator for Android there is something mentioned about Emulator fails to render OpenGL content but nothing on how to fix it?

I don’t use VS to develop Android before. I suggest to use Android Studio. Since cocos2d-x v3.15+, can use Android Studio to build/debug cpp files.

already done it but thanks anyway.

i wanted to use visual studio for android just because of its fast emulator … it’s a lot faster then android studio even with x86 system images.

Great to hear that it is resolved. Will you please share the experience?

1 Like

What is your solution please?

I’ve run into same problem. Here is my VS2015 build error ss: http://imgur.com/4Lbr7yW
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 := hellocpp/main.cpp
…/…/Classes/AppDelegate.cpp
…/…/Classes/HelloWorldScene.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

Application.mk

APP_PLATFORM := android-19
APP_STL := gnustl_static

APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char
APP_LDFLAGS := -latomic

APP_ABI := x86
#APP_ABI := armeabi armeabi-v7a x86
#APP_ABI := armeabi-v7a
APP_SHORT_COMMANDS := true

ifeq ($(NDK_DEBUG),1)
APP_CPPFLAGS += -DCOCOS2D_DEBUG=1
APP_OPTIM := debug
else
APP_CPPFLAGS += -DNDEBUG
APP_OPTIM := release
endif

i never said it’s resolved … i just switched to android studio and am not happy with it either especially when i am used to visual studio build speed and ide responsiveness

however if you still want to use visual studio for android you can still use a real device and the arm build will work totally fine for you

as for the emulator the last thing i remember trying out is BlueStacks 3 as a desperate attempt along with the arm as the active platform and surprisingly visual studio recognize it … and it even showed up in devices tab … !!

but then again don’t get excited because after the build succeeds and the app finishes installing on the emulator i get an error message 'unable to start debugging android command run-as' so i immediately googled it and it turned out to be issues in some file permissions /system/bin/run-as and in order to fix it you have to root the device and execute some commands as a super user …but even after doing that new error message just popped up but this time it’s about another command 'pwd'? … so with a lot of problems and no where to go i had to leave it there.

tried other emulators MEmu, KOPLAYER, Nox but visual studio doesn’t recognize theme.
also tried genymotion and the device gets recognized but the same as bluestacks i get an error message.


since i started using cocos2d-x with android wherever i go i get nothing but hiccups and problems no matter the IDE or tool that i use … i doubt that any of this would’ve happened if i used Unity.

am not denying that android studio works yeah it works but without issues that let you waste precious time issues like slow gradle build even with an i7 desktop processor and if you try to make prebuilt libs to speed it up then you instead just get a bunch of other problems

and if you try to profile some code you end up with another set of problems and don’t forget that without good profiling your not gonna go far in android development

the bottom line is there is nothing smooth or good when it comes to android and cocos2d-x
IT’S SIMPLY DOOR SHUT … PERIOD