Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android - Call requires API level 9 (current min is 8): android.os.StrictMode#setThreadPolicy

I am new to JSON. I followed this tutorial to create sample app. When i try to copy the code to my eclipse it show error.

Call requires API level 9 (current min is 8): android.os.StrictMode#setThreadPolicy

Please advice. Thanks

like image 931
chinna_82 Avatar asked Aug 03 '12 04:08

chinna_82


3 Answers

Go to the android AndroidManifest.xml

In your File it is 8

<uses-sdk android:minSdkVersion="8" />

Change The SDK version to 9 like shown below

<uses-sdk android:minSdkVersion="9" />
like image 72
Venkatesh S Avatar answered Nov 12 '22 04:11

Venkatesh S


Right Click on you Android Project>Android Tools>Clear Lint Markers

"Run Android Lint" makes some markers and the markers cause this error.

This worked for me so if you use this don't need to change the

<uses-sdk android:minSdkVersion="8" />

to 9

like image 38
surhidamatya Avatar answered Nov 12 '22 06:11

surhidamatya


In AndroidManifest.xml you have defined minSdkVersion as 8

<uses-sdk android:minSdkVersion="8" />

Though in the you code you are using StrictMode which is supported fromA API level 9.

So either you can skip using StrictMode in your app or set midSdkVersion as 9.

To skip using StrictMode just remove these lines.

import android.os.StrictMode;

StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork().penaltyLog().build());
like image 4
Sangharsh Avatar answered Nov 12 '22 04:11

Sangharsh