Best way to test your project when you're developing it for Android?

I’ll admit I’ve never used the emulator, so there may be a way to improve the loading time and speed of development with it. You may want to look into cocos2d-x w/javscript or lua. Then you can develop in a similar manner as you do with Corona simulator using Cocos Code IDE w/Cocos Simulator or even just using a web Browser.

For Android dev I’d highly recommend getting a cheap device (amazon, ebay, etc) that runs 4.x Android. Also, while you should test android as you go along development you can test on win32/mac daily and say android once a week just to make sure there aren’t any android specific bugs. You can then do cocos compile -p android and then afterward reinstall with adb install -r bin/project_name_prefix-debug.apk, or you can do cocos deploy -p android and have it fully uninstall the app first.

use cococs command for deployment in device. Thats the easy way to go. Eclipse crashes often.

Don’t use the emulator, just grab a cheap or 2nd hand android device (preferably 4.x, as +/- 90% of your players will be on that). And then use USB debugging on the device.

I run everything from Eclipse and never really had any crashes?
Not that it doesn’t give you trouble now and then of course :smile:

Kind regards,
Mich

Thank you guys for replying!

Yeah. I have two android devices, one is my main phone, a Sony Xperia, the other I only bought for testing and this is a very cheap one because I want to test the app and game performance on low devices.

I’m new on mobile developing and still doing everything on my own. So I never used USB debugging before, I guess it suppose to work directly on device instead of emulator, sounds pretty good for me, and I’ll check it out for this work out.

@stevetranby
@MFHSchoonbrood

I know the ability of Cocos2D to handle JS and Lua languages as a wrapper framework, but I really don’t want it. I’d like to stand on C++ for some reasons (performance, “universal language”, native, some other enginers also use it, and so on).

My only complain was about the time to deploying to android emulator. I’ll try what was suggested, to spend almost all the time developing under win32 or mac and just make few tests on android device when I figure it is applied for.

@sillyatom

I don’t like Eclipse, never liked it, even I was using it for Java. I love IntelliJ IDEs, they are for me the best IDEs.

Sounds like you got pretty much the same setup as me.
I develop with visual studio under windows. I only use C++, so no lua… for android you also need java and for ios obviously some objective c/c++.

I only use windows testing for when I develop… all real testing is done on actual android devices. Myself through USB debugging (when developing mobile specific stuff) and the testers through beta releases from the android store. It’s way easier and faster to get new test/beta releases to your testers on Android then it is on iOS (testflight helps, but Android is still way faster… upload beta package, and an hour later your testers can update).

Works great!

oh really, you never encountered some weird update errors as soon as you open cocos2dx projects in eclipse? it happens like, i recreate project each time i open eclipse due to some constant errors. So i stopped using eclipse. i do all my dev in Xcode and running the app in device thru cocos command.

I’ve just started testing on Android (was only testing on iOS before) and found the free Genymotion Android emulator to be quite serviceable on a half decent machine.

It’s no comparison for a real device, but it’s free.

There’s even an answer to a post on the forums by @Shurul explaining how to correctly compile your app and configure a Genymotion device to run a cocos2d-x game. I will state here that I got it working with his Step 1, but your milage may vary.

Oh, I encountered some weird shit, but only a few times, plus it was easily fixable by googling the problem.
Use what works for you, cocos studio sounds great, I might at some point switch to it myself. But right now everything is working smooth as hell, so why touch it :slight_smile:

stainsby: You might run into issues when you wanna test integration with other apps (like facebook), unless they resolved that now.Plus nothing beats testing on a real device, because that is what it eventually will run on.

@MFHSchoonbrood: Absolutely, but if you don’t have a device it’s a better option than Google’s emulator.

You can’t beat final testing on a device, but depending on the game, I just develop initially as a Mac app (windows would be equally useful)

this way you can just change the window size to test for different resolutions, build, run and debug nearly instantly (especially if you have an SSD)

When I need to test specific functionality, or performance, I test again on real devices.

Same here, I have a list of resolutions I can loop through with CTRL+F11, so I can check what the game looks like on all different aspect ratios, and CTRL+O toggles the orientation between portrait and landscape.

I store the active resolution and orientation in the config, so I can read+use it on startup as well.

I also store the x,y position of the game window in the config, so it’s always in the same position on screen when I run it.

Stuff like this makes debugging smooth as hell on your PC.

You’ve inspired me, now!
I’ve been meaning to improve my debuggng and testing set up - but have never even tried keyboard input (although I did look at it when I was developing solely for iPad, and couldn’t get it to work)

My current method has a “PauseDebug” layer which overlays my actual pause layer (when running in debug mode). On this layer I have buttons to:
Show/Hide sprites
Show/Hide terrain surface
Show/Hide ‘sub-terrain’
Show Box2d Debug
Edit level
Save and Load level
and I also stick stuff on there to make the player invulnerable, add health etc.

Doing some of this via the keyboard would be so much faster, I think

When you say you look through the resolutions, is that during a game? So you cope with resolution changing mid-game?
If so, I’d be interested in how you do it - I can only set resolution before starting the game, as so much (loading sprites, etc.) depends on the resolution…

yups, mid game… I kinda cheat by calling onOrientationChanged after resizing the window, but it’s ok to cheat, because it can never happen on a real device like that.

So basically, you change the window size, call onScreenSizeChanged of the gamelayer, and then I send an onOrientationChanged event to my game. They already handle the event because items need to reposition when flipping from landscape to portrait mode. The repositioning part looks at the active resolution, so by sending the event again, the game repositions itself to the new resolution.

Hopefully that gives you some pointers on how to do it yourself…

Kind regards,
Michaël

Nice.

My game is landscape only, so I’m not handling orientation at all - but I suppose I could follow your process easily enough

Hmmm… might give it a go!

Hi guys,

Yesterday I got mac to run Cocos2D-X as well, it was easier than Windows because I just did it afterwards it, however I guess I’ll stick on Windows for developing because it is a desktop machine.

I’ve not tried the USB Debugging yet, so when I reach that I’ll post down here.

Hi Everyone,

Sorry If I have missed something.
I’ve only been through a couple of posts from the start.
I was a part of android development team, where we were using very naive methods.

I used to develop in a windows device for android, so I used to edit on sublime on one side and command prompt on the other side. I found that pretty good.

However, if you are new may be eclipse will help you in getting autocomplete feature, in return for a lot of crash. So, I recommend not to use eclipse, if you are even little experieced.
Other thatn that -

When it comes to testing, android says that installing some intel HAXM will increase the speed of the emulator but that’s just a myth. Personally I found IOS simulators great, but they are not available when it comes to android development.
So, like most of the post suggest to get a cheap android device to test, I would go with it.

Get a nice chinese tablet online.
but do check that they don’t need to install any drivers or if needed, they have their adb drivers available.
I found an android tablet but then it was a pain in the butt to find it’s adb driver, ofcourse you can use universal adb drivers, if they are supported.

So summary is :-

  1. Use eclipse only if you are very naive (still I wouldn’t recommend) else use sublime text.

  2. try to compile in the command prompt only.
    build_native.py -p 20
    where the number 20 is the android version number of your SDK

  3. Get an android device for test, GenyMotion is a bit faster but when it comes to android a real device is better to test.
    You dont always need to connect the device with the cable, instead you can enable wireless adb with some good apks from the app store, that would also work wonder (only if both the devices are connected wirelesly to the same router).

Happy Codind :smile:

Hey could you tell me how exactly you did that?
And more important how can I set the window position on win32?

You save/load the position in/from your user defaults.
All you gotta do is retrieve the window handle from cocos, and use that to move the window (or access the position to store it).

Here is my SetWindowPosition() for example…

// Set the window position to the provided coordinates
void Graphics::SetWindowPosition( int x, int y )
{
#if defined(__COCOS2DX__) && defined(_WIN32)
	// Restore window position (Do this first, as it create black borders in the OpenGL window)
	cocos2d::Director*	pDirector	= cocos2d::Director::getInstance();
	cocos2d::GLView*	pGLView		= pDirector ? pDirector->getOpenGLView() : NULL;
	HWND				hwnd		= pGLView ? pGLView->getWin32Window() : NULL;
	if (hwnd)
	{
		// Get the current window rect
		RECT	rectCurrentWindow	= {0, 0, 0, 0};
		GetWindowRect( hwnd, &rectCurrentWindow );
		// Move the window
		MoveWindow( hwnd, x, y, x + rectCurrentWindow.right - rectCurrentWindow.left, y + rectCurrentWindow.bottom - rectCurrentWindow.top, TRUE );
	}
#endif // __COCOS2DX__ && _WIN32
}

I can get you more code if you need it, but this should show you everything you need…

Thanks!

This should be enough. :smile: