I’m Unreal Engine programmer … And today I decide to use Cocos2Dx too…
And This is greate news i found on forum on first day…
Yeah, what about Mac users? does it work on Mac?
Visual Studio does not exist on a Mac, does it? Visual Studio Code does.
@smitpatel88 Sorry I’m back now. So it might be best if we take this off line to work on the intellisense issue to not derail the rest of the thread. You can ping me back at email@example.com if you want. But basically what we are going to do is build your project from the command line so that I can get more IntelliSense debugging information. If you go to the Cocos2dcpp directory you can run this build command from a Visual Studio 2015 developer command prompt window:
msbuild /p:Configuration=Debug;Platform=x86;BuildingInsideVisualStudio=true;DesignTimebuild=true /t:_PrintIntellisenseInfo Cocos2dcpp.vcxproj
If you send the output of that to me I can tell more about what might be going on.
Also since you mentioned that you did not have Clang installed. I’ve done all my work with Clang 3.8 which is kinda the VS default for the Android build projects. Might be a good first thing to just install that via modifying your VS install to make sure that is not the intellisense root cause issue.
@notamonopoly Regarding question 1 nothing has to be renamed to run, but to work more like the other template you might want to look at app_name in strings.xml in the java project at a minimum. That string is usually assigned to the name of your project in the other cocos templates, but since this template is not in the templating system it just has a generic name of “CocosVisualStudio” instead of the name of your app. Also the project names are generic Cocos2d for the Java project and Cocos2dcpp for the shared library and could be changed to match the project name.
Regarding question 2. It’s (sadly) intentional. The Visual Studio Android projects do allow for sharing code from alternate locations and we use that to not duplicate code files in this project. But when it comes to packaging assets and libs it goes on a strict folder location basis. To get packed in the assets need to physically be in the assets folder below the project node and the external libs need to be in a libs folder there, so we can’t reference them like with the source files. Hence the copy of asset files and extra .jar files that you see in this project.
@ishmar I’m not familiar with SDKBOX. From what I see in the docs it looks like it injects the SDK references needed with a command line tool. This might or might not be hard to reverse engineer to figure out what changes need to be made to this project itself. I’ll look into it this week, but no promises on it.
@jrosich @energy Visual Studio is only on Windows, sorry about that. As noted we do have VSCode for Linux and Mac. It’s rather slick (if you trust my biased opinion ;)) but while we are adding more debugging and language support to it it’s more like a beefed up text editor, you can’t use it with any normal Visual Studio templates and projects.
Currently SDKBOX doesn’t support Windows anything. Not deployment, not Visual Studio. Let us also add @nite and @kiyall to this discussion and perhaps they can ad this since Visual Studio now supports Android and SDKBOX supports Android.
If you so, can you post the solution back here for everyone to benefit from?
@IanHu Thanks for this.
After updating few things(CLang, android related) from VS-2015 i am able to get intellisense and also able to build apk
Now we need SDKBOX support then its perfect.
Can someone create setup project for Cocos2d-x 3.11.1 same as for 3.12?
Right now it is tied to 3.12, AFAIK. Maybe @IanHu will make more projects for other versions in the future.
Thanks for your quick answer. I’m aware that SDKBOX isn’t supported on windows platform, either desktop or mobile. I’m currently developing my game using Visual Studio 2015 Community as I’m used to it and love it, and when I need to do specific android stuff such as sdkbox develop, I use cocos console + tools (ndk, sdk, ant…) but I miss powerful/visual debugging interface that VS gives.
So, what I’m asking it’s not supporting windows stuff (that would be a request to SDKBOX team), I’m asking the possibility to compile and run/debug with the tools that @ianhu provided. I haven’t done any research, but being so close, my guess is that it may just be find the right place to append SDKBOX’s JAR files (and these files are listed in the ‘manual integration’ section of documentation for each plugin) and add search paths too or copy .H files (again, steps are documented both for xcode and console).
This is my wish list to be the perfect tool for me, but anyway, must say it’s a great wonderful job, and it’s just his first release, so i’m sure more will come and we can only THANK him for that, but being a truly noob when diving in android’s world, i just thought an expert would find it easier to solve it.
@smitpatel88 Glad to see that it’s working for you with Clang installed.
@ishmar I’m pretty sure that your guess is close (adding some new file path locations and .jar files) for SDKBOX integration as I was starting to take a peek at this. While I’m a bit familiar with Cocos SDKBOX is pretty new to me. My slight worry here is that SDKBOX expects to update all the dependences apart from Cocos. Meaning that my template would have to be customized to both a specific version of Cocos as well as each specific version of each SDKBOX component. I think that I’ll probably just start by manually integrating a single plugin bundle (IAP or something) to see what is involved here. Just to set expectations though, this work is kinda a side project to my main work. So progress from me is going to be of the slow but hopefully steady variety for a while.
Hey everyone. Hopefully not too late, but I got a chance this AM to look at the SDKBOX manual integration steps. It’s obviously not as optimal as integration with the command line tool, but with a small bit of finagling I was able to integrate the SDKBOX IAP plugin with the existing template proj.visualstudio project that I provided via manual steps.
This link here has an edited proj.visualstudio template project that can be used like the previous one to show how to manually link in an SDKBOX plugin.
The project is more of an example to look back at, as the steps would be different for each different plugin. So I’ve also provided the process of how I edited the basic proj.visualstudio project to create this so that folks could do the same steps for other plugins.
Note that these steps are all relative to the existing base proj.visualstudio project in the VC++ team blog not the edited one here.
Unzip the plugin .zip file
From pluginzipdirectory/plugin/android/libs copy PluginGooglePlay.jar PluginIAP.jar sdkbox.jar to proj.visualstudio/Cocos2d/libs
In Visual Studio right click the libs folder under the Cocos2d project. Use the “Add Existing Item” command to add in those new .jar files into the Java project. Should be in with android-async-http-1.4.8.jar
From pluginzipdirectory/plugin/android/jni copy folders pluginiap and sdkbox into proj.VisualStudio/Cocos2dcpp/jni
Add android.permission.INTERNET, android.permission.ACCESS_NETWORK_STATE, com.android.vending.BILLING into permissions in AndroidManifest.xml
In the project properties for the Cocos2dcpp project in the Configuration Properties->VC++ Directories section. Add the paths to $(ProjectDir)\jni\sdkbox and $(ProjectDir)\jni\pluginiap into the list of Include Directories
Same project properties. In Linker->General into the Additional Library Directories list add in $(ProjectDir)\jni\pluginiap\libs\armeabi-v7a and $(ProjectDir)\jni\sdkbox\libs\armeabi-v7a.
Same project properties. In Linker->Input in the Library Dependencies section add in (at the end of the list) PluginIAP and sdkbox. Note that ordering matters here, PluginIAP needs to be first in the list or you will get unresolved references.
In the Cocos2d java project in Visual Studio open Cocos2dxActivity.java and add in “import android.content.Intent” and import “com.sdkbox.plugin.SDKBox.”
This last step was a bit funky (Integration of Google Play Services) I’m a VS guy not an android expert so there might have been a better way to do this. But with my installed Android SDK there didn’t seem to be the correct extras folder to supply the Google Play Services .jar, even when I installed them from the Android SDK Manager. What I ended up doing was downloading the R28 version of Google Play Services via this thread: http://stackoverflow.com/questions/37310684/missing-sdk-extras-google-google-play-services-libproject-folder-after-updat
From the zipped R28 project I took the google-play-services.jar file, added it to the proj.visualstudio/Cocos2d/libs, then included it in VS via Add Existing Item like I did with the other libs
At this point I was able to add in some sample code from the GitHub repository for the IAP plugin. https://github.com/sdkbox/sdkbox-sample-iap
And get it all compiling, building, debugging, and running on the phone. Obviously this isn’t all as slick as the command line integrations for the existing project, but should give anyone else looking to add SDKBOX plugins to Visual Studio a bit of a head start.
Hey everyone. I’ve created a new project for this to work with Cocos2d-x version 3.13.1. Download it here.
The blogs.msdn.com post has also been updated with this info. As a note here. I’m talking with my team here about putting this project up on the Microsoft GitHub. I plan on keeping on it for some time, but I feel that putting it online would help folks to upgrade it quicker if I’m slow off the mark like this time.
Im using Windows10: How to use Cocos and Visual Studio to create game in Cocos2d-x?
Thanks for the great work!
Sorry we were unaware of VS users. Since google is pushing really hard for Android Studio, unfortunately AS’s native support is still lacking after so many versions. We’ll take a look at your project and see if we can improve the SDKBOX integration, BTW is there a good library to manipulate VS project files?
Really thanks a lot… At last I succeed to compile your pattern project for Android in VS-2015, even debug works! (but very slow…) Next I tried to migrate my project:
Q-1: Can your 3.13.1-pattern be added into your previous “vscocosandroidsamplesdkbox” pattern for 3.12+SDK - to use 3.13.1 VS project with SDK function?
Q-2: If I’m not mistaken, @nite said it is possible to create Cocos2dx based app for win32, using google-play-services; if so, then @IanHu, when could we have the same pattern sets to create google-play-services app for win32? …if that’s possible.
Q-3: Looks like I’ve missed “editor-support” folder in your
– fixed Looks like I do not need it anymore; wonder why.
Q-4: Also “size_t” and “malloc” can’t be found in my project; but
“$(VS_NdkRoot)\platforms\android-19\arch-arm\usr\include” is added ->
“C:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r11c\platforms\android-19\arch-arm\usr\include” - what am I doing wrong during the migration of my project? I used same cpp+h files to compile for win32 (in VS-2015) and for android (from command prompt).
– fixed by adding into the cpp file
#include "malloc.h" - I wonder why it was not need in win32 project version…
Q-5: In your “Cocos2dcpp.vcxproj” I see
$(VS_NdkRoot)\platforms\android-19\arch-arm\usr\include; Creating empty project that gives me double “.h” files in “Cocos2dcpp (android-19)” “External Dependencies” tree-list, for example:
c:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r11c\platforms\android-19\arch-arm\usr\include\machine\_types.h - is it ok?
Step-6: A pre-last milestone for me was to realize, what I really need to replace pattern files+folders in
Cocos2d/res tree-list to my files+folders.
Q-7: @IanHu, I have a big question for you about the apk release version build (selecting “Release” in VS): there appear
CocosVisualStudio.apk file in
ARM\Release only (or in
ARM\Debug only - if “Debug” is selected in VS). Release apk is 1.2 Mb smaller than debug. But:
7.A. I still can start “Release” apk version in VS to debug it on device (step-by-step or with breakpoints);
7.B. Google Play do not accept that 1.2 Mb smaller “Release” apk, saying it is in debug mode; Also SHA1 is different than in my previous apk, released with command-prompt.
7.C. Release apk can be build without “.keystore” file - so builder does not use it in Release mode;
7.D. apk files sizes - in megabytes:
command prompt: 6.5-release, 7.5-debug;
Visual Studio: 7.9-release, 9.1-debug;
First of all, thank you for working on this setup for our community. This could be the way to go in the future.
Two more questions about the whole Visual Studio Setup:
I’ve seen that you use Ant in the project. Many modern frameworks (like the Facebook / Firebase / etc.) require Gradle to work. Also Android Studio uses Gradle and Google greatly pushes it for Android. Is it possible to use Gradle in Visual Studio for this Setup?
Is it possible to use this together with the Visual Studio Xcode syncing feature (https://msdn.microsoft.com/en-us/library/mt748656.aspx) to have one project for Android and iOS in Visual Studio?
This would be really awesome and be a revolution for cocos2d-x developers.
Many thanks for this extension.
Had to change the default values for android sdk, ndk, java and ant in visual studio / tools / options / cross platform, but now works great!!
Using cocos13.3.1. Can deploy to android device, do remote debugging, intellisense also works well, i’m sharing the source files with the other builds and also sharing the assets, to do this deleted the assets folder and created a hard folder link (junction), from windows command type: mklink /J assets C:\wherever\you\have\cocos\project\Resources
I can deploy to my arm device with no problem but i can’t deploy to any avd x86 emulator, visual studio does not detect it, don’t really know if this is expected to work. Anyway, many thanks again.
@IanHu Thanks a lot, commander; but seems your
vscocosandroidsamplesdkbox is for sdkbox V126.96.36.199 ; and there appeared newer: V188.8.131.52 could we please have newer pack?
Hello @nite and @IanHu, I think I’m close to use SDKbox & Visual Studio, but I need help.
Windows-7, VS-2015, cpp, Android:
I successfully build & run my apk (it uses AdMob ) in both cmd and VS. In cmd it works properly, if there is a line
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> in
AndroidManifest.xml; but I can’t build it in VS - it needs
google_play_services_version value, Q: how should I properly input that value into my VS project? Thank you.
Upd: I’ve get it; anyway my “AdMob” app shows the result (test advertising), if apk created with
cocos compile ... and do not even try to download test advertising if apk created with VS
Upd: I’ve got it working (in VS-2015); going to update after max cleaning.