I managed to build the sub project BasicLocationSample from https://github.com/googlesamples/android-play-location. But as soon as I try to run either in Emulator or in Samsung Galaxy S 2. It immediately crash. I tried to check any reasonable clue in logcat but nothing significant to mention. I tried to set breakpoint at Main Activity's onCreate very first line. It doesn't even call it :( .
I can run ActivityRecognition and LocationAddress sample from the same sample list. So I must be missing something from BasicLocationSample. Please inform me how to run BasicLocationSample? Thanks in advance!
Related
I would really appreciate if someone can help me with my problem:
I am using Android Studio. I want to create the simplest of apps: Just a "Hello World" would be ok.
So I start by creating a new app with an Empty Activity (so far I was using a "Blank Activity" but as you know, they are different.
So I create the basic code (and I find several problems -for example "cant resolve symbol AppCompatActivity- but I dont know how, it got solved...and then I have other problems..etc but...)
So, I finally get a "hello world" app, with everything ready to run. All errors corrected "by magic"- I mean really... anyway I push the Run button.(i am using genimotion by the way cause the native emulator is another problem!) and it starts to run
and I wait.... and wait.... and wait....
it never runs. I can see "gradle processes running"
So I *stop * (by clicking Run-> Stop)
the gradle processes seem to stop
and then the app finally runs succesfully and load into the genimotion emulator and I can run without problems...
So my question is: What is happening here? Why do I have to stop in order to run??
Thanks a lot for any useful help you can give me
I have found my app returned error after a for loop.
Are there any tricks for me to just run through the for-loop and then debug?
I have studied some posts saying that using Ctrl+R could help.
However my latest version eclipse cannot found such a function.
You can do Step debugging in Eclipse
mark a break point in the code where you want ( mark at the blue line as shown with a small blue circle)
then run->Debug Configuration and start the app
and when the program starts it will stop at that line where you put break point.
just dont forget to change from JAva or DDMS to Debug
also you can see various stepping code things in run menu while debugging
I hope it helps you
1.use Log.i() or System.out.println() to print something.
2.just see debug information in logcat
3.reduce loop times or replace loop with other simple code, then run the app again
So I downloaded the Sample App for 'Recognizing the User's Current Activity' on the android website http://developer.android.com/training/location/activity-recognition.html
The problem I'm having is that when I press the 'Start Updates' button, then the 'Stop Updates' button, and then the 'Start Updates' button again, the updates don't start again the second time.
I've searched online but couldn't find much material on the topic so yeah, I've also tried debugging and found that the onDisconnected() method call (via the ConnectionCallbacks interface) isn't being called in either of the DetectionRemover.java or DetectionRequester.java files.
If anyone knows why this is happening I'd really like to know why. From what I've gathered it doesn't seem to be anything in the sample code, and I think it might be a problem on the Google Services side.
P.S. I'm using Google Play services rev 16. along with a Samsung galaxy s2 android version 4.1.2
I noticed this same problem running the sample code on my Nexus 4 (Android 4.4.4). I found that if I commented out the following line of code in the ActivityDetectionRemover continueRemoveUpdates() method, it fixed the problem:
mCurrentIntent.cancel();
Sorry, I don't yet have a good explanation as to why canceling the PendingIntent causes this issue.
UPDATE: I also commented out the cancel in the MainActivity onStopUpdates() method:
mDetectionRequester.getRequestPendingIntent().cancel();
Which is effectively doing the same thing as the first line above.
I don't know if this question is suitable for this site or not, but I think this place is better for this kind of question than stackoverflow.
I'm developing an Android application using Eclipse. I always debug and log when I encounter a complex problem/bug when developing apps.
However, this is the first time I encountered a situation where debug and log seem not working correctly. This is what happened:
When I run my apps (using log) : The getView method in my adapter is not called, i know this by using log.
When I debug it step by step : The getView method in my adapter is called, however it gives me the NPE (Null Pointer Exception).
When I debug it, but not step by step : Same like when i run my apps, the program never entered the getView method.
Note : The 3rd means that I set some breakpoints, then I debug what I need to debug (not step by step), then I skip to the next breakpoint, while the 2nd means I debug the apps step by step, not skipping anything.
I have tried to solve this bug for more than 20 hours, but I still can't get things working correctly.
Have you encountered the same problem like mine, while running and debugging a program, or even different method of debugging give you a different result?
What should I do now?
are you working with threads ? if yes please check code your for synchronization blocks. These kind of problems happens when you miss some code blocks for synchronization. Always behavior will be strange.
I'm having a troubling problem testing some code for and Android app. My app has two parts, and activity where the user changes some settings, and a broadcast receiver that responds to SMS messages, both in the same package.
Here's the problem, I first implemented some simple code to test out the broadcast receiver and the activity, and both worked fine. But then as I tried to refine the code, I noticed the emulator wasn't picking up any of my changes. Event went so far as to uninstall the app from the emulator and try again, no luck. Then I added some extra Toast popups to my receiver, nothing, still running the old code. I know its running the old code because its sending out an SMS using a string constant that is no longer in the current code, so it should be impossible that it respond with that value.
Here's the kicker that has me confused. For fun I made a change to my activity. Ran the project from Eclipse and that change showed up! Tried to test the receiver code again, runs the old code that doesn't even exist anymore!!
How in the world can half the package update, and the other half not?
Can anyone help me out 'cause I'm about ready to lose my mind.
I had a similar problem. Changes made to classes imported from another project didn't get picked up by eclipse, but those made to classes in the current android project were.
Making a change to the current android project (inserting a blank line and deleting it) seemed to make eclipse pick up all the changes made and upload the app to the emulator.
I had this problem too, Now I found a working solution. Just follow these steps:
Run your project normally.
When emulator started, run your project again (DO NOT close the first emulator)
Then the updated application will be uploaded into emulator
I can't really be sure what happened but creating an new emulator image appeared to solve the issue.
I don't know why it happens but it's a problem I have all the time.
What I typically do is
Close the emulator
Close Eclipse
Reopen Eclipse
Clean the projects (in Eclipse, select Project -> Clean... -> Clean all projects)
Rerun the emulator
Annoying as hell but seems to work for me.
I'm having this problem too. It mostly happens when errors are entered into the code. The strange thing is if I go back to the original code, Eclipse doesn't revert to the original code. One thing that seems to help is to temporary delete the contents of a file, save, and rebuild, and then enter the contents back into the file, save, and rebuild.
How is one supposed to debug in such an environment?