android - 调用需要 API 级别 9(当前最小值为 8):android.os.StrictMode#setThreadPolicy
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11789275/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
android - Call requires API level 9 (current min is 8): android.os.StrictMode#setThreadPolicy
提问by chinna_82
I am new to JSON. I followed this tutorialto create sample app. When i try to copy the code to my eclipse it show error.
我是 JSON 的新手。我按照本教程创建示例应用程序。当我尝试将代码复制到我的 Eclipse 时,它显示错误。
Call requires API level 9 (current min is 8): android.os.StrictMode#setThreadPolicy
Please advice. Thanks
请指教。谢谢
回答by Venkatesh S
Go to the android AndroidManifest.xml
转到android AndroidManifest.xml
In your File it is 8
在您的文件中,它是 8
<uses-sdk android:minSdkVersion="8" />
Change The SDK version to 9 like shown below
将 SDK 版本更改为 9,如下所示
<uses-sdk android:minSdkVersion="9" />
回答by surhidamatya
Right Click on you Android Project>Android Tools>Clear Lint Markers
"Run Android Lint" makes some markers and the markers cause this error.
“运行 Android Lint”会生成一些标记,这些标记会导致此错误。
This worked for me so if you use this don't need to change the
这对我有用,所以如果你使用它不需要改变
<uses-sdk android:minSdkVersion="8" />
to 9
到 9
回答by Sangharsh
In AndroidManifest.xml you have defined minSdkVersion as 8
在 AndroidManifest.xml 中,您已将 minSdkVersion 定义为 8
<uses-sdk android:minSdkVersion="8" />
Though in the you code you are using StrictMode which is supported fromA API level 9.
尽管在您的代码中您使用的是 API 级别 9 支持的 StrictMode。
So either you can skip using StrictMode in your app or set midSdkVersion as 9.
因此,您可以跳过在应用程序中使用 StrictMode 或将 midSdkVersion 设置为 9。
To skip using StrictMode just remove these lines.
要跳过使用 StrictMode 只需删除这些行。
import android.os.StrictMode;
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork().penaltyLog().build());
回答by TheUnwokenFool
Other answers are correct, but if you still see the error be sure to "Sync Project with Gradle Files" (on Android Studio toolbar).
其他答案是正确的,但如果您仍然看到错误,请确保“将项目与 Gradle 文件同步”(在 Android Studio 工具栏上)。