Google Maps in Android app crashes - android

In attempting to add a map to an Android app I encountered an error to the extent of:
04-15 17:36:42.036: E/AndroidRuntime(28534):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{xxx}: android.view.InflateException: Binary XML file
line #7: Error inflating class fragment
I have read over numerous posts, and articles on what the problem might be and have tried any number of suggestions from:
verifying uses-library in Manifest
Adding the Google SDK (as opposed to the Android SDK).
Extending FragmentActivity (as opposed to Activity).
Setting up API Keys and adding them to the Manifest.
However, nothing changes the results. The app still crashes when trying to launch that activity, with the same error message.
In an attempt to narrow things down I downloaded the sample application from here, but it crashes with the exact same error message.
Being relatively new to Android, the above sample looked fine, but with it crashing it's hard to tell where the error is. The complete stack trace is can be found here.
I am developing this on a Nexus 4, running Android 4.2.
I would have assumed that the referenced sample app would have at least worked. Am I wrong? Is there something wrong with the sample I've been referencing?

Have a look to my detailed step by step tutorial for using google android Map v2 on Android Virtual Device(Emulator) Android 4.2 http://umut.tekguc.info/en/content/google-android-map-v2-step-step
Specifically, make sure that the reference to google-play-services_lib can be resolved. If it cannot be resolved, the application will compile and launch successfully up to the point where it actually needs to display the map. Then it will crash.
Right click on the project in Eclipse, and select Properties.
On the left select "Android"
Ensure that google-play-services_lib has a green check mark next to it on the right under Library.
If it has a red "X" or is missing entirely, the reference will need to be re-added.

Related

MyEclipse: Changing Android codes takes no effect

I know this is a rare question. Even if there are people using MyEclipse for Android development is doubted :(
The annoying thing is that after I modified my Android project (like an Activity class of a xml file), the project remained the same as it was when I imported it.
I thought there is an important feature that demonstrates this error: When I run my Android project and the console reported that "Activity not started, its current task has been brought to the front". This line occurs because the project didnt changed while as a matter of fact I did change the project and saved it.
Is there anyone has the same problem like me?
-------------add in Oct. 28-------------------
This was what I did: first, I modified one of my activities by commenting out the Toast functions; and then, I ran it however the Toast line still showed on my Genymotion emulator

Integrating Swarm with Libgdx

Im looking to integrate Swarm high scores with my game that is built on a modified version of the game framework outlined in the Beginning Android Games book by Mario zechner.
The problem is that my game consists of two halves. One is the gameframework which contains the activity and all the background open gl code. That framework is added as a jar to my game. So i cant reference Swarm in the manifest of the framework, because it doesnt exist. The manifest of the game is the one that is used. Ive tried following the steps for getting Swarm working with libgdx but that doesnt work. I get a classnot found error on runtime.
anyone got any ideas?
thanks
Edit: Unable to post screenshot of the error as my rep is too low.But the error said:
java.lang.RuntimeException: Unable to instatiate activity ComponentInfo{com.MYSTUFF/com.MYSTUFF.FartJumper
Class not found exceptions are thrown when a class loader is unable to find a class. Check to make sure your classes are all named properly and referenced in the manifest xml file.

Google Maps app loads to emulator but will not open on emulator

I followed the google maps tutorial to create a new google maps project, obtained an api key, included the , and the INTERNET permissions in the manifest file. Included
in the main.xml file, and followed the steps to modify the main.java file. The app will install to the emulator, but as soon as I click on the app, a notifications shows:
The application has stopped unexpectedly.
I have exhausted all resources, so hopefully someone can help. Thanks in advance for all of the help. Also, in the logcat, I am getting a number of errors after I "click" on the app in the emulator. One error in particular that I have read about, but not found a fix for is:
Caused by: java.lang.ClassNotFoundException: com.hutzley.TestMap.MyApplication in loader dalvik.system.PathClassLoader
Something in your app is trying to refer to com.hutzley.TestMap.MyApplication, and this class does not exist in your project. Since a reference from Java would typically generate a compile error, I recommend that you check your manifest, find where this is referenced, and change it to whatever it is supposed to be.
Make sure you are using one of the special emulator images which supports the Google APIs, without this you would be trying to run your app on an environment that lacks required libraries for maps to work.

How do you debug successfully in Android?

I understand there is the LogCat view to check the messages logged but I can't make sense of it.
When debugging (I use Java primarily) I've been accustomed to stepping over each line of code and finding out the exact point where the program crashes and then doing something about it.
How can I do this with Android development? Is there a way to precisely locate the line which is causing the application to crash?
I can't understand what to make of/how to read the LogCat messages and when I try to step over (using the F9 key or the 'Debug' option in Eclipse) it keeps opening new tabs for inbuilt classfiles (like Instrumentation.class etc) and after pressing F6 a few times over again the app crashes showing 'The application has stopped unexpectedly. Please try again'
Can someone tell me if there's something to be done in a way that I'm not doing here?
Thanks!
Btw if it helps, here's the generated log:
http://pastebin.com/EaqaWUdS
You are using a resource id that doesn't exist at line : 93 of com.site.custom.ModAdapter.getView(CustomListProjectActivity.java
--EDIT : add explanations
You will read a logcat stack trace in the same way as you did in Java : read bottom up and the culprit is the last line of your classes (before the code gets into the android sdk code).
You can do it the other way around, and start from top, stopping at the first class of yours and discarding android classes.
The same reasoning applies when debugging : step into your methods if needed and step over all methods of the SDK unless you want to debug them (and usually you don't, if you really suspect a bug inside the SDK, check the source at grepcode to see the inner mechanics of the android sdk class you are interested in).
Sometimes it gets difficult to track bugs on android, especially for widget layout related bugs because you can only see the code that is executed by the android platform, no code of your is executed, only your data are read from an xml file for instance. If something breaks here, it can be harder to debug. In that case, apply the dichotomy method : remove half line, if the bug doesn't show up, then readd your lines, remove half of them, etc...
It is the same like in java. Basically you need the sources to open the java files instead the class files. Google shows you how to add the sources.
Basically you debug android while staying in your own classes. I barely look into the android classes as the most issues are, of course, located in my own classes.
So just debug like you already do but don't step into methods/classes you don't own unless you have the sources added to your sdk. Even if you have, there might be some classes that aren't open source, so you can't step into the sources there. (Basically all Google API classes)

Locating Errors When Developing Android Apps

I'm working on my first Android app and to be honest I'm not sure about most of what I'm doing. Right now I'm stuck on a NullPointerException that is created by a line that refers to another class that, in turn, refers to another class.
How can I locate the error?
The word you are looking for is debug. If you are using eclipse, it's very easy to debug your program in most cases. Two main options in eclipse are to use the logger for debug prints to logcat, or debug the program step by step to detect relevant errors. Here is a tutorial for both options and here is a nice video tutorial in YouTube regarding debug in eclipse.
You can use the Eclipse debugger to help with that. Set a break point above the line that errors out and deploy your app using the Eclipse debugger (with the little bug icon) rather than the standard deployer (the play button). You'll be able to see what is going on right before the line with the error occurs and hopefully fix things up.
If that doesn't work, you can post the stack trace and your method that has the error and we can take a look at it.

Categories

Resources