【问题标题】:Android studio 3.1.3 not show any error when i use deprecated api当我使用已弃用的 api 时,Android Studio 3.1.3 不显示任何错误
【发布时间】:2018-07-09 11:57:15
【问题描述】:

我使用 android studio 3.1.3 。当我编写不推荐使用的方法时(例如:

  Spanned a= Html.fromHtml("<b>hello</b>");

android studio 代码编辑器不会显示任何错误或建议,也不会突出显示已弃用的方法,例如 android studio 2.3!!!当我重建(编译)项目时,这给了我以下错误。

... \MainActivity.java: 使用或覆盖已弃用的 API。 使用 -Xlint:deprecation 重新编译以了解详细信息

请帮帮我。

我的 build.gradle (Module:app):

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.my.mynewapplication"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    } }

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' }

【问题讨论】:

    标签: android android-studio-3.1.3


    【解决方案1】:

    改变这个东西.. 在应用程序级别的 gradle 构建中改变这些东西..

        compileSdkVersion 27   // hear you can define any sdk.
    

    以及根据 27 .. 删除 28 alpha 的所有依赖项

        implementation 'com.android.support:appcompat-v7:27.1.1' 
    

    我尝试了这段代码,它在 onCreate 方法中定义为活动。

            TextView textView=findViewById(R.id.textView);
        Spanned a= Html.fromHtml("<b>hello</b>");
        textView.setText(a);
    

    【讨论】:

    • 我更改它并重建项目但问题没有解决。
    • 我添加了 build.gradle 来提问请看。
    • 我更新了我的答案。还有 android studio 无效/重启。
    • 我无效/重新启动了 android studio 但不幸的是我的编辑器没有显示任何错误或建议弃用 api。
    • 一旦尝试重启工作室。
    猜你喜欢
    • 2021-08-22
    • 2021-02-27
    • 2018-12-21
    • 1970-01-01
    • 2015-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-28
    相关资源
    最近更新 更多