Android Build a Weather App Working with JSON Introducing JSONObject

facing a new Error with OkHttp.

Initially OkHttp used to work fine but now i am facing a new error when the minumum sdk-version is 16 for the same code the error is: Error: Invoke-customs are only supported starting with Android O (--min-api 26).So wrote the same code again but now i changed to minumum sdk-version to 26 now it was compiled but when it was running the app is closed restart or close your app i don't know how to move any further please help!!! note: i have mentioned uses-permission android:name="internet" in manifest.

2 Answers

Hi Sai. Which version of Java are you working with? Try adding the following compileOptions lines in your build.gradle (Module: app) file:

android {
...
     compileOptions {
             sourceCompatibility JavaVersion.VERSION_1_8
             targetCompatibility JavaVersion.VERSION_1_8
     }
}

Hope that helps :)

P.S. The internet permission should be:

<uses-permission android:name="android.permission.INTERNET" />

it worked thank you so much

Happy to hear that. You're welcome :)