Android Studio使用或覆盖了已弃用的API。

huangapple go评论107阅读模式
英文:

android studio uses or overrides a deprecated API

问题

"hi everyone i just start make an app and that error show up "" uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. "" what that mean and how can i recompile with -Xlint"

大家好,我刚刚开始制作一个应用程序,出现了错误:"使用或覆盖了已弃用的 API。注意:重新编译时使用 -Xlint:deprecation 获取详细信息。" 这是什么意思,我如何使用 -Xlint 重新编译?

my code

import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class StartActivity extends AppCompatActivity {
private static int timeOut = 1800;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start);
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
Intent i = new Intent(StartActivity.this, MainActivity.class);
startActivity(i);
finish();
}
}, timeOut);
}
}

英文:

hi everyone i just start make an app and that error show up "" uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details. "" what that mean and how can i recompile with -Xlint

my code

        import androidx.appcompat.app.AppCompatActivity;
        import android.content.Intent;
        import android.os.Bundle;
        import android.os.Handler;
        public class StartActivity extends AppCompatActivity {
        private static int timeOut = 1800;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_start);
        final Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent i = new Intent(StartActivity.this, MainActivity.class);
                startActivity(i);
                finish();

            }
        }, timeOut);
    }
}

答案1

得分: 12

  1. Deprecated 表示将来不再支持这个方法。可能会有一个新的方法你应该使用。这个方法可能不在你的代码中,而是在你使用的某个库中。

  2. Linting 是检查额外的非关键错误的过程,详见 https://en.wikipedia.org/wiki/Lint_(software)

  3. 这里有一些关于这个主题的先前问题
    https://stackoverflow.com/questions/49711773/how-to-recompile-with-xlintdeprecation
    https://stackoverflow.com/questions/18689365/how-to-add-xlintunchecked-to-my-android-gradle-based-project
    https://stackoverflow.com/questions/51109810/note-recompile-with-xlintdeprecation-for-details

还可能感兴趣的是
https://stackoverflow.com/questions/49809306/how-to-show-the-compile-errors-details-on-android-studio
https://stackoverflow.com/questions/16633956/android-studio-where-is-the-compiler-error-output-window
https://developer.android.com/studio/write/lint

Gradle 是一个构建工具,它可以为您执行构建应用所需的所有步骤。包括编译、检查、合并等。

这可能看起来很多,但不要放弃,一点一点来。如果你的应用程序正在运行,那么你可以简单地忽略这个问题。

英文:

Let's go step by step over your problem.

  1. Deprecated means that in the future this method will no longer be supported. There might be a new method that you should use instead. This method might not be in your code but in one of the libraries that you use.

  2. Linting is process of checking in this case some additional non vital errors https://en.wikipedia.org/wiki/Lint_(software).

  3. Here are some previous questions about this topic
    https://stackoverflow.com/questions/49711773/how-to-recompile-with-xlintdeprecation
    https://stackoverflow.com/questions/18689365/how-to-add-xlintunchecked-to-my-android-gradle-based-project
    https://stackoverflow.com/questions/51109810/note-recompile-with-xlintdeprecation-for-details

Also of interest might be
https://stackoverflow.com/questions/49809306/how-to-show-the-compile-errors-details-on-android-studio
https://stackoverflow.com/questions/16633956/android-studio-where-is-the-compiler-error-output-window
https://developer.android.com/studio/write/lint

Gradle is build tool which does all the steps required to build an app for you. Compiling checking lints merging etc.

This might seem like a lot but don't give up do it bit by bit. If your application is running then you can simply ignore this problem.

huangapple
  • 本文由 发表于 2020年8月11日 05:45:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/63348430.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定