I spent about 2 weeks to find out how to get my Cocos2d-x win32 c++ running on an Android Device.
I’m totally new within this. At least I found out that VS 2015 supports building for Android.
I set up my test Device - Samsung Galaxy Note I GT N 7000, installed the SDK 4.1.2 - API16 and managed to get it running from VS2015. So far so good. But: What are the next steps to build the Android version of my app and get it running un the emulator?
I created the project with the following command line in my testgame folder:
cocos new GameNameHere -p com.MyCompany.GameNameHere -l cpp
If VS2015 is not the recommended tool to build for Android, I would be thankful for any help with which tool I should build and debug my Android app. I’ve tried Android Studio, following dozens of online tutorials but can’t get my cocos project running there.
Read this thread: http://discuss.cocos2d-x.org/t/android-developers-use-visual-studio/ and read it all. There are updated project files from our friends at Microsoft. Also, you must be on v3.13.1.
and also this: http://cocos2d-x.org/docs/installation/Android-VisualStudio/index.html
Thanks, I read a lot and at least followed the steps at
http://cocos2d-x.org/docs/installation/Android-VisualStudio/index.html
Build ends up with a lot of errors:
Severity Code Description Project File Line Suppression State
Error undefined reference to 'cocos2d::experimental::AudioPlayerProvider::AudioPlayerProvider(SLEngineItf_ const* const*, SLObjectItf_ const* const*, int, int, std::function<int (std::string const&, long*, long*)> const&, cocos2d::experimental::ICallerThreadUtils*)' Cocos2dcpp E:\Projekte\ALEX\HelloWorldTest\cocos2d\cocos\audio\android\AudioEngine-inl.cpp 176
Error undefined reference to 'cocos2d::experimental::AudioPlayerProvider::getAudioPlayer(std::string const&)' Cocos2dcpp E:\Projekte\ALEX\HelloWorldTest\cocos2d\cocos\audio\android\AudioEngine-inl.cpp 212
Error undefined reference to 'cocos2d::experimental::AudioPlayerProvider::preloadEffect(std::string const&, std::function<void (bool, cocos2d::experimental::PcmData)> const&)' Cocos2dcpp E:\Projekte\ALEX\HelloWorldTest\cocos2d\cocos\audio\android\AudioEngine-inl.cpp 377
Error undefined reference to 'cocos2d::experimental::AudioPlayerProvider::clearPcmCache(std::string const&)' Cocos2dcpp E:\Projekte\ALEX\HelloWorldTest\cocos2d\cocos\audio\android\AudioEngine-inl.cpp 398
Error undefined reference to 'cocos2d::experimental::AudioPlayerProvider::clearAllPcmCaches()' Cocos2dcpp E:\Projekte\ALEX\HelloWorldTest\cocos2d\cocos\audio\android\AudioEngine-inl.cpp 406
Error undefined reference to 'cocos2d::experimental::AudioPlayerProvider::pause()' Cocos2dcpp E:\Projekte\ALEX\HelloWorldTest\cocos2d\cocos\audio\android\AudioEngine-inl.cpp 181
Error undefined reference to 'cocos2d::experimental::AudioPlayerProvider::resume()' Cocos2dcpp E:\Projekte\ALEX\HelloWorldTest\cocos2d\cocos\audio\android\AudioEngine-inl.cpp 188
Error undefined reference to 'cocos2d::experimental::PcmData::PcmData(cocos2d::experimental::PcmData&&)' Cocos2dcpp G:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r11c\sources\cxx-stl\gnu-libstdc++\4.9\include\functional 2040
Error undefined reference to 'cocos2d::experimental::PcmData::~PcmData()' Cocos2dcpp G:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r11c\sources\cxx-stl\gnu-libstdc++\4.9\include\functional 2039
Error undefined reference to 'cocos2d::experimental::PcmData::~PcmData()' Cocos2dcpp G:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r11c\sources\cxx-stl\gnu-libstdc++\4.9\include\functional 2039
Error undefined reference to 'cocos2d::experimental::getSDKVersion()' Cocos2dcpp E:\Projekte\ALEX\HelloWorldTest\cocos2d\cocos\audio\android\jni\cddandroidAndroidJavaEngine.cpp 51
Error linker command failed with exit code 1 (use -v to see invocation) Cocos2dcpp E:\Projekte\ALEX\HelloWorldTest\proj.visualstudio\Cocos2dcpp\clang.exe 1
Error MSB3030 Could not copy the file "E:\Projekte\ALEX\HelloWorldTest\proj.visualstudio\ARM\Debug\libcocos2dcpp.so" because it was not found. Cocos2d G:\Program Files (x86)\MSBuild\Microsoft\MDD\Android\V140\Android.Common.targets 339
I didn’t change anything after VS2015 has started by opening the file:
E:\Projekte\ALEX\HelloWorldTest\proj.visualstudio\Cocos2d.sln
Just plugged in my phone at usb and clicked on the green arrow to start debug build & run.
Glad to see that my device (GT-N7000) is detected. I do also own a Sony XPERIA Z5 which is not detected
Probably an include for AudioPlayer
is missing someplace. I’ll look and hunt this down.