Android developers: use Visual Studio!

@IanHu

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:

  1. 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?

  2. 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 V2.2.5.3 ; and there appeared newer: V2.3.2.0 could we please have newer pack? :slight_smile:

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 :frowning:
Upd: I’ve got it working (in VS-2015); going to update after max cleaning.

Please check file proj.visualstudio\Cocos2dcpp\Cocos2dcpp.vcxproj : string
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
$(VS_NdkRoot)\sources\android\cpufeatures;$(VS_NdkRoot)\platforms\android-19\arch-arm\ - I think it should be x86 instead of arm
The same for …$(Platform)'=='Release|x86'"> string.

I did it, it costed me a week: SDKbox V2.3.2.0 for Visual Studio for cocos2d-x-3.13.1 : https://drive.google.com/file/d/0BwFbYJJmjqIkR1RraWJ0djE4eUE/view?usp=sharing

How you can play with it:

  1. Create Cocos empty cpp project;
  2. With console=cmd import into project sdkbox AdMob;
  3. Merge project with “sdkbox-sample-admob” example (google for it);
  4. Make sure you can successfully build and run it on the device - (test) advertising should appear;
  5. Then you can add unzipped proj.visualstudio_sdkbox_for_cocos2d-x-3.13.1 (make its name shorter) folder into project.

https://drive.google.com/file/d/0BwFbYJJmjqIkaEZaOTNIRXZONDQ/view?usp=sharing - here is very short zip with key differences, with test AdMob id.

Upd: but my AdMob sample doesn’t work on my Android 2.3.6 devices… :frowning:

Hello, I’m tying to add fmod precompiled library. I’ve added the libfmodL.so and libfmodstudioL.so libraries to linker addtional dependencies, also updated the include paths and everithing compiles fine but hangs after deploy because libraries are not installed in the system.

Also added fmod.jar to the project and project libs folder, same place android-async and other .jar

dlopen("/data/app/com.CocosVisualStudio-2/lib/arm/libcocos2dcpp.so", RTLD_LAZY) failed dlopen failed: could not load library "libfomdstudioL.so" needed by "libcocos2dcpp.so"; caused by library "libfmodstudioL.so" not foud.
FATAL EXCEPTION: main

So my quiestion is wich Android.mk and or Application.mk or whatever have to edit to deploy the library with my project. I’m not Android expert at all and really struggling with this. Thanks a lot.

Is there some sort of android simulator like when using eclipse? I mean right now it is just making a window that has the design size…

Answered myself in a new thread think is big enough:

http://discuss.cocos2d-x.org/t/setting-up-a-precompiled-library-fmod-with-visual-studio-win32-and-visual-studio-android/

@IanHu: Could you (or someone else) please help us to add Google Play Services into VS-2015 project (to debug it on Android device from VS)? I’ve tried but no success.

Hi,

I am using windows 10, cocos 3.13.2, ndk-r11c, apache-ant-1.9.3, jdk1.7.0_55, jre1.8.0_73

  1. I cannot get visual studio to detect my 2.3.5 Samsung Gingerbread phone. Can anyone help me do this?

  2. i get these errors when i build…can i get help on how to fix this?

    1>…\cocos2d\cocos\audio\android/AudioEngine-inl.cpp(177): 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*)’
    1>…\cocos2d\cocos\audio\android/AudioEngine-inl.cpp(195): error : undefined reference to ‘cocos2d::experimental::AudioPlayerProvider::pause()’
    1>…\cocos2d\cocos\audio\android/AudioEngine-inl.cpp(209): error : undefined reference to ‘typeinfo for cocos2d::experimental::UrlAudioPlayer’
    1>…\cocos2d\cocos\audio\android/AudioEngine-inl.cpp(217): error : undefined reference to ‘cocos2d::experimental::AudioPlayerProvider::resume()’
    1>…\cocos2d\cocos\audio\android/AudioEngine-inl.cpp(242): error : undefined reference to ‘cocos2d::experimental::AudioPlayerProvider::getAudioPlayer(std::string const&)’
    1>…\cocos2d\cocos\audio\android/AudioEngine-inl.cpp(407): error : undefined reference to ‘cocos2d::experimental::AudioPlayerProvider::preloadEffect(std::string const&, std::function<void (bool, cocos2d::experimental::PcmData)> const&)’
    1>…\cocos2d\cocos\audio\android/AudioEngine-inl.cpp(428): error : undefined reference to ‘cocos2d::experimental::AudioPlayerProvider::clearPcmCache(std::string const&)’
    1>…\cocos2d\cocos\audio\android/AudioEngine-inl.cpp(436): error : undefined reference to ‘cocos2d::experimental::AudioPlayerProvider::clearAllPcmCaches()’

@IanHu In the template for v3.13.1 from your blog, we have to copy all the resources to the “assets” directory inside the “Cocos2d” directory , or else the project will throw the segmentation exception.
I made a small change, the project is now linking all resources in Resources folder when loading projects, so it would be much easier to use.
Beside that, I created a small python script to rename to dedicated project name also. You can check it here:

Is it posible to use this with cocos 3.14.1? Thanks for such a great work.

I am not sure. I haven’t tried. I can email Ian at Microsoft and ask him if he can ensure compatibility.

1 Like

Well, if not i’ll try it myself in a few weeks when i start the services side with sdkbox, hope can integrate it with relative ease using the info on this thread. I’m already using another precompiled library, fmod, and integrating it was a bit of a pain. (see my post in this same thread).

By the way, in my opinion, the andorid visual studio project is super useful and should be part of the official cocos releases.

Can I +1 the request to make this work with 3.14.

Thanks

am having setup and build issues could anyone help please.

Can anyone share a how-to of Visual Studio project VC++, Linker etc. settings ? I have never got it built using Visual Studio 2015. Not a single time.

Hi all !
A long time ago, I helped to make the VS solution, based on cocos2d-x 3.13.1, to work on VS 2015. My game project were in “StandBy” but since last week, I tried again to make it work… But I don’t succeed in making it working again :cry: !
I updated my environment : I use VS 2019 (Community), android NDK R15c, Java JDK V12.0.2 and ANT 1.9.3.
So with this configuration, if I compile the solution downloadable for version 3.13.1, I have this error :cry:
2>-compile:
2> [javac] Compiling 2 source files to C:\oponsinet\Development\MobileApps\Download\proj.visualstudio-3_13_1\proj.visualstudio\Cocos2d\ARM\Debug\Package\bin\classes
2>EXEC : [javac] error : Source option 5 is no longer supported. Use 7 or later.
2>EXEC : [javac] error : Target option 5 is no longer supported. Use 7 or later.
2>
2>BUILD FAILED
2>C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:716: The following error occurred while executing this line:
2>C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:730: Compile failed; see the compiler error output for details.

To prevent this error, I found this solution : add these 2 lines in build.xml :

But, problem, when I add these 2 lines, I no longer have this error, but I have some new errors :
2> [dx] -Djava.ext.dirs=C:\Program Files (x86)\Android\android-sdk\build-tools\23.0.3\lib is not supported. Use -classpath instead.
2>EXEC : [dx] error : Could not create the Java Virtual Machine.
2>EXEC : [dx] error : A fatal exception has occurred. Program will exit.
2>
2>BUILD FAILED
2>C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:888: The following error occurred while executing this line:
2>C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:890: The following error occurred while executing this line:
2>C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:902: The following error occurred while executing this line:
2>C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:283: null returned: 1
2>

So I don’t know if somebody has seen this error, but when I tried different solutions found on different forums, there is no solution wheich works !

Could somebody help me ? :cold_sweat:

Many thanks :stuck_out_tongue_winking_eye: