Android studio 3.1.3 not show any error when i use deprecated api

China☆狼群 提交于 2019-12-23 06:06:32

问题


I use android studio 3.1.3 . When i write deprecated method (for example:

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

android studio code editor not show any error or suggestion and not highlighting deprecated methods like android studio 2.3!!! and when i rebuild(compile) project this give me below error.

... \MainActivity.java: uses or overrides a deprecated API. Recompile with -Xlint:deprecation for details

Please help me.

My 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' }

回答1:


Change this things.. in app level gradle build change this things..

    compileSdkVersion 27   // hear you can define any sdk.

and all dependency according to 27 .. remove 28 alpha

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

i tried this code and it working define into onCreate method into activity.

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


来源:https://stackoverflow.com/questions/51245031/android-studio-3-1-3-not-show-any-error-when-i-use-deprecated-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!