Sunday, February 9, 2014

Developing For Android

I have been doing a little developing for Android. I've mostly been trying to familiarize myself with Android Developer Studio (ADS). I used to use eclipse, and it worked great. ADS is based on intelliJ, and I kind of like it, I see where it is heading, and can sort of see that it has the potential of making developing something almost anyone could do.

I've also been frustrated with it. It seems every other time I use it, it says there is an upgrade ready. I've upgraded a couple times, and lost hours trying to get it working again. Sure if you are working 8 hours a day on this, you probably know right where to look, and besides what is a couple hours. If you are doing this weekends and nights, and you loose a couple hours, that can quickly translate into days.

The main failing is the build process. Yea, ADS uses Maven, and that doesn't change. What typically breaks though is the Gradle part. Plenty of note on how to fix gradle every time it breaks on StackOverflow and other places. I've just decided I don't need the updates, and I won't have to loose any time. What I got seems to work for me, and I see no reason to upgrade.

My app is using the android devices gyro's. I am not trying to build a glass panel yet, but just trying to understand the sensors and their limitations. I have the accelerometers working, and you can see graphically and textually how the sensors work. The gyros, I am trying something similar. The gyros are rate gyros, meaning they return the degrees per second the unit is changing. A turn coordinator is a rate gyro, where a standard rate turn in a Cessna 172 is 3 degrees per second.

To make something like an attitude indicator, the rate gyro must be integrated over time. Once the device starts a 3degree/second bank change, as long as the gyro is reporting 3 degrees per second, it will keep adding these values. The first second will be 3 degrees, the second 6 degrees and so on. The math can get a little complicated, but there are plenty of examples on line.

So right in the middle of that, the emulator was working great, but the phone kinda quit working. It would paint the screen once, and the crash. The dreaded "Unfortunately, ExampleMain has stopped". message. (No I haven't created a cool name for this app yet). The emulator doesn't have real sensors, so it is hard to figure out why this is crashing.

I tried to connect the phone to the computer using USB, and debugging that way. Wow, that took more than I thought it would take. Samsung's web site was no help, try searching their site for "windows 7 usb android drivers", and you'll get taken to the laptop support page where you can download USB drivers for samsung laptops.

After many hours, I finally found this site: Just by the name you can tell it is what I am looking for. This is supposed to be the drivers that will allow debugging adb and the phone! Yes, finally the phone shows up in the list, but it is listed "Off-Line".  If I click on it, the debug window just says "Waiting for device.". Finally someone said stop ADS and restart it. That was the magic.

Now I can debug on the phone. I am getting the same results, "Unfortunately, ExampleMain has stopped". message, and even the debugger isn't pointing me in a direction. Dang it, but at least I can set breakpoints in places I think there might be trouble. The two thread main loops don't seem to be the target yet. Next I'll try some of the new code I added.

No comments:

Post a Comment