• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

getting err when starting app

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
im getting an err ever time I try ruing the app. can some one tell what the err is...here is the err.



 
Saloon Keeper
Posts: 5776
146
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We don't know what "the app" is, but the error message is quite clear: a method is invoked on a null object reference. What object that is we can't say without seeing the code, but since the exact line number is given, it's easy for you to find out.
 
Tony fig
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the line number?
 
Tim Moores
Saloon Keeper
Posts: 5776
146
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The line numbers are listed behind the class names, separated by a colon.
 
Tony fig
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so the line is number is not list in the err i just listed?
 
Tony fig
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
isn't the line number 2940?

 
Tim Moores
Saloon Keeper
Posts: 5776
146
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
2940 is the PID (process ID).

Look for the names of your classes. As I said, the line numbers are behind the class names, separated by a colon.
 
Tony fig
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know where the classes are. were do i find them?
 
Master Rancher
Posts: 4223
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the stack trace there are these two lines, which I assume are referencing your code as they're the only classes I don't recognise:

at com.example.tony.concerts_.MainActivity$DownloadWeather.onPostExecute(MainActivity.java:161)
at com.example.tony.concerts_.MainActivity$DownloadWeather.onPostExecute(MainActivity.java:144)


So what is going on in that onPostExecute method in the MainActivity.DownloadWeather class?
 
Tony fig
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is what I have between those two lines.


 
Tim Moores
Saloon Keeper
Posts: 5776
146
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I don't know where the classes are. were do i find them?


Does "com.example.tony.concerts_.MainActivity$DownloadWeather" not look like the name of one of your classes? I advise to familiarize yourself with such stack traces - you will see (and will have to analyze) a lot of them if you're serious about Android development.

What you posted is not line 161 (or line 144) of your code. As the stack trace shows, the error occurs in the onPostExecute method when a JSONObject is initialized. So make sure that line of code works with correct data. If you're unsure, print all the relevant data to the logcat (you know how to do that, right?) - before the line that causes the problem :-)
 
Marshal
Posts: 65467
249
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please supply more details about the args array.
 
Tim Moores
Saloon Keeper
Posts: 5776
146
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One thing that looks wrong is that doInBackground looks like it receives XML, but onPostExecute apparently does something with JSON - is that the same data? If so, what kind is it?
 
Tony fig
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't get an err if I run it on android 8.0 but on android 9.0 i get the err.
 
Tim Moores
Saloon Keeper
Posts: 5776
146
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I merged your stuff with the following thread. I hope that is okay by you.
 
Tony fig
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this code for downloading the weather. it works on android 8.0 but wont work on android 9.0. can someone tell me why it wont work on android 9.0?


Here is the code.

 
Tim Moores
Saloon Keeper
Posts: 5776
146
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So which one is line 161 of this code - I'm guessing line 18? Have you verified that what the code calls "xml" is in fact valid JSON? Maybe by printing it to the logcat? If not, start with that.

Also, you should print out the full stack trace in the catch block.
 
Sheriff
Posts: 21788
104
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tony fig wrote:


Tony fig wrote:


The org.json.JSONObject.<init> means the JSONObject constructor. That makes the above line the #1 suspect. Where does xml come from, and what is its actual value? Is the null check maybe done one line too early, and should it check xml instead?
 
Tony fig
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is teh logcat err


 
Tim Moores
Saloon Keeper
Posts: 5776
146
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not output from your app, but from android. Please reread what Rob and I wrote, and answer our questions.
 
Tony fig
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get no other err it just wont work on android 9.0.
 
Tim Moores
Saloon Keeper
Posts: 5776
146
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The NullPointerException you mentioned in the first post no longer happens? And still the app crashes?
 
Tony fig
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is all the errs i get  these are the errs i get they just keep repeating down the page.


 
Tim Moores
Saloon Keeper
Posts: 5776
146
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the app no longer crashes? But it does not do what you expect it to do? If so, TellTheDetails of what it does do, and at what point it deviates from what you expected it to do.
 
Tony fig
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I run the app I get those errs and than it crashes and its says this "08/18 07:15:40: Launching 'app' on samsung SM-G975W.
$ adb shell am start -n "com.example.tony.concerts_/com.example.tony.concerts_.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Waiting for process to come online...
Connected to process 2421 on device 'samsung-sm_g975w-R58M42AW06M'.
Process 2421 terminated."
 
I am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!