This week's book giveaway is in the Java in General forum. We're giving away four copies of Helidon Revealed: A Practical Guide to Oracle’s Microservices Framework and have Michael Redlich on-line! See this thread for details.
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.
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?
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 :-)
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?
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?
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.
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?
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.
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."