Debugging Android Cocos2dx-3.0(rc2) with Visual Studio and Tegra Nsight 1.5

Debugging Android Cocos2dx-3.0(rc2) with Visual Studio and Tegra Nsight 1.5
0.0 0

#11

ok, it looks like it’s not automatically prefixing these build arguments with “ndk-build” then… So you should just put it there yourself-- put "ndk-build " before the -C …


#12

Thank @Ajas now i can build the new project but i get the following error when i click Debug->Start new instance where Tegra is Android project Name :


#13

@Ajas , Error 14 error MSB6006: “ndk-build.cmd” exited with code 2. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\Tegra-Android\Nvidia.Cpp.Tegra-Android.Make.targets .

can you help me ?


#14

@bangthaisu – is there any more info besides that?

@hossainiir – it’s looking for your android apk in the proj.win32 directory. You should figure out where that apk got built to and fix your paths.

I also found a weird issue in the newer 3.2 Application.mk.

The lines:

APP_DEBUG := $(strip $(NDK_DEBUG))
ifeq ($(APP_DEBUG),1)

cause the gdbserver not to be included in the apk, causing an error in the “Starting GDB server” part. Change those 2 lines simply to:

ifeq ($(NDK_DEBUG),1)

and you can debug again!


#15

@Ajas , I did as your guide, i debug and then " Error 14 error MSB6006 "
. i’m using cocos2d-x 2.2.1 , tegra 3.0r1, vs 2012.
Thank you for your quick reply .


#16

I gave this a try with cocos2d-x 3.2, tegra 3.0r2, vs 2013 with bad results. To anyone who’s thinking about installing TADP, it’s 6 gb large or so!!

I choose Import and ndk-build Android Project:

Was that the correct choice?

I get the error when building:

1> [armeabi] Compile++ thumb: cocos2dx_static <= CCPhysicsBodyInfo_chipmunk.cpp
1> error: error opening ‘…/…/…/…/…/cocosIDEprojects/vsprojects/VSTest/VSTest/VSTest/Tegra-Android/Debug//local/armeabi/objs-debug/cocos2dx_static/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.o.d’: Error opening output file ‘…/…/…/…/…/cocosIDEprojects/vsprojects/VSTest/VSTest/VSTest/Tegra-Android/Debug//local/armeabi/objs-debug/cocos2dx_static/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.o.d’: Can’t find the search path

1> 1 error generated.
1> make.exe: * […/…/…/…/…/cocosIDEprojects/vsprojects/VSTest/VSTest/VSTest/Tegra-Android/Debug//local/armeabi/objs-debug/cocos2dx_static/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.o] Error 1
1> make.exe: * Waiting for unfinished jobs…
1> [armeabi] Compile++ thumb: cocos2dx_static <= CCPhysicsContactInfo_chipmunk.cpp
1> error: error opening ‘…/…/…/…/…/cocosIDEprojects/vsprojects/VSTest/VSTest/VSTest/Tegra-Android/Debug//local/armeabi/objs-debug/cocos2dx_static/physics/chipmunk/CCPhysicsContactInfo_chipmunk.o.d’: Error opening output file ‘…/…/…/…/…/cocosIDEprojects/vsprojects/VSTest/VSTest/VSTest/Tegra-Android/Debug//local/armeabi/objs-debug/cocos2dx_static/physics/chipmunk/CCPhysicsContactInfo_chipmunk.o.d’: Can’t find search path

1> 1 error generated.
1> make.exe: * […/…/…/…/…/cocosIDEprojects/vsprojects/VSTest/VSTest/VSTest/Tegra-Android/Debug//local/armeabi/objs-debug/cocos2dx_static/physics/chipmunk/CCPhysicsContactInfo_chipmunk.o] Error 1
1> make.exe: Leaving directory `D:/Programming/cocos2d-x-3.2rc0/projects/VSGameCenterTest/VS_GameCenterTest/proj.android’
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Platforms\Tegra-Android\Nvidia.Cpp.Tegra-Android.Make.targets(56,5): error MSB6006: “ndk-build.cmd” exited with code 2.

I open the really short folder path:

“D:\Programming\cocosIDEprojects\vsprojects\VSTest\VSTest\VSTest\Tegra-Android\Debug\local\armeabi\objs-debug\cocos2dx_static\physics\chipmunk”
and there is indeed not a single .o file inside that directory (it has files outside the dir tho).

Any kind of help is appreciated.


Visual Studio and tegra
#17

Thanks for posting this, I was going insane finding a stable (and free) solution for debugging Java/C++ code in Cocos2d-x 3.5 apps for Android on Windows.

Good news:
I had success in getting this to work with Tegra 2.1, Visual Studio 2013 & Android 4.2! Debugging Java & C++ code in the Cocos2dx proj.android solution worked perfectly in Visual Studio.

Bad news:
On Android 4.3+, I get an error when the NSight debugger tries to launch the application on the device: Failed to pull device files: Index was outside the bounds of the array.

I’ve posted about this on the NVidia forums so I’m hoping there’s some easy workaround or patch for it. Any ideas anyone ? Thanks in advance.


#18

Update:
Discovered later that the Tegra Android Development Pack has a nag screen when debugging devices that don’t have NVidia chips. See here: https://developer.nvidia.com/nvidia-nsight-tegra-licensing

To get around the error I mentioned on Samsung 4.3+ devices, the Android device needs to be rooted - I think. But anyway, I ended up picking up a cheap Nexus 7 for debugging C++ on Android and got it all humming along with Android 5.1 - no interrupted debugging now. Good-bye to Eclipse.


#19

I have used the Eclipse plugin from NVIDIA called Debug Manager for Android NDK and it worked great for breakpoint debugging on Android.

Has anyone else tried using the NVIDIA Debug Manager and the NVIDIA Tegra Nsight for Visual Studio?
I am curious if someone has used both, which one they liked better and the reasons why one might be better than the other.

Primary Requirements

  1. Breakpoint C++ debugging on Android
  2. Does not break the cocos console build and game publishing processes.
  3. Minimal hacking required to get it to work reliably.

This post talks about using the NVIDIA Nsight for Visual Studio Android debugging.
vs.
In the post in the following link I added some info about getting and setting up the NVIDIA Tegra Eclipse C++ NDK IDE with breakpoint debugging: How do you debug in Cocos2d-x?


How do you debug in Cocos2d-x?
Environment setup - general question about targets
Best Android Cocos2d-x C++ IDE Environment with Debugger?
#20

With regards to your comment about needing Visual Studio Pro in the other post, you should be able to use Visual Studio Community Edition which is free and has the same functionality as VS Pro, however there are licensing restrictions. https://www.visualstudio.com/en-gb/products/visual-studio-community-vs

Visual Studio 2015 has built-in android/NDK debugging but I haven’t played with the preview version as yet.
http://blogs.msdn.com/b/visualstudioalm/archive/2014/11/12/introducing-visual-studio-s-emulator-for-android.aspx


#21

@brightlightapps For Visual Studio Android NDK Debugging could you please answer these three questions:
Thanks!

  1. Does visual studio work ok with adding and editing Java code and JAR files (Admob, Flurry, Google Analytics, etc) for Android, or does it only deal with C/C++?

  2. Does the VS solution build Java and C++ then package for device testing, or just C++ and require the JAR’s to already be present?

  3. How does the debugger respond to Java code build issues? Any similar runtime log messages to Logcat in Eclipse or other info about issues in the Java areas of the project?

I definitely want to try the VS solution, but I might wait until VS2015 is officially supported by cocos2d-x.
Although, I might not survive that long since Eclipse might give me a heart attack due to frustration before then.


#22
  1. Yes to adding and editing Java code. JAR files - I haven’t added any APIs to my project as yet but will soon be integrating AppLovin.

  2. Java is built.

  3. Error is picked up by the javac compiler and reported in the VS IDE in the same way as a C++ error is typically displayed

Output window shows all the ANT build log:
1> -compile:
1> [javac] Compiling 2 source files to D:\DEV\GuessTheAnimal\proj.tegra\Tegra-Android\Debug\bin\classes
1> [javac] D:\DEV\GuessTheAnimal\proj.android\src\org\cocos2dx\cpp\AppActivity.java:33: error: cannot find symbol
1> [javac] private bool test;
1> [javac] ^
1> [javac] symbol: class bool
1> [javac] location: class AppActivity
1> [javac] 1 error

  1. Supports GDB Console & Android Logcat window

#23

I gave this a try, the solution built and deployed to my Nexus 7 ok. But the Classes, cocos2d, Resources directories & contents are not showing in my project. How do I import those into my new project?

Cheers.


#24

They don’t show up cause those folders are not underneath proj.android when you import the project. I just added the new tegra project to the existing win32 solution like the original poster suggested and I have access to all the files in the one solution, works for me - see below:

But if there are extra files you want to appear in the tegra project after you import, just right-click on the project, Add->New Filter, call the filter whatever you want, for eg.“Classes”, then right-click on the filter, go “Add Existing Files” and select all the C++ files. Although this isn’t practical for adding cocos2d cause you would need to create all the filters for the subdirectories - which is why adding the project to the existing win32 solution is the easier way and nothing in the solution view is duplicated.


#25

Thanks! I will try that win32 way.


#26

Does autocomplete work for you?
I added the Classes filter & the debugging is excellent.


#28

Intellisense for C++ files imported directly into the tegra project doesn’t seem to work for “Make Application” tegra project types so best to just work with the C++ files in the win32 project.


#29

Could you please make a video, I can’t make it work.


#30

Where can i put breakpoint? because i put it in project win32 (HelloWold.cpp) nothing happen!


#31

You should run visual studio as Administrator! It will work, but i don’t know where to put Breakpoint, in project android don’t have files cpp.