简体   繁体   中英

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

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" />
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

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());

其他答案是正确的,但如果您仍然看到错误,请确保“与Gradle文件同步项目”(在Android Studio工具栏上)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM