pix*_*xel 94 android android-appcompat android-lint
升级到appcompat后,25.1.0我开始收到有线错误.
在我的代码中:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Run Code Online (Sandbox Code Playgroud)
我得到lint错误:
AppCompatActivity.onCreate can only be called from within the same library group (groupId=com.android.support)
如何防止这种行为?
Dim*_*CBR 126
正如先前的回复所强调的,这是错误的.我建议不要在项目范围内禁用特定的lint警告,但仅限于该方法.注释您的方法如下:
@SuppressLint("RestrictedApi")
@Override
public void setupDialog(Dialog dialog, int style) {
super.setupDialog(dialog, style);
//your code here
}
Run Code Online (Sandbox Code Playgroud)
Mar*_*tin 84
正如Felipe在他的评论中已经指出的那样,这是工具预发布版本中的一个错误.
您可以暂时解决此问题,直到Google发布修复程序,方法是将以下内容添加到项目模块的build.gradle文件中:
android {
lintOptions {
disable 'RestrictedApi'
}
}
Run Code Online (Sandbox Code Playgroud)
值得注意的是,这可能会隐藏项目中的真正错误,因为它会抑制该类型的所有错误,因此更好的选择是降级Android Studio版本和项目中使用的工具.
Kil*_*ler 64
在lintOptions中禁用警告看起来不是一个好的选择,最好在语句级别禁止检查.
在提供警告的代码行上方添加此注释:
//noinspection RestrictedApi
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
38864 次 |
| 最近记录: |