【问题标题】:android studio uses or overrides a deprecated API [duplicate]android studio 使用或覆盖已弃用的 API [重复]
【发布时间】:2020-11-30 13:03:21
【问题描述】:

大家好,我刚开始制作一个应用程序,但显示的错误“”使用或覆盖了已弃用的 API。 注意:使用 -Xlint:deprecation 重新编译以获取详细信息。 "" 那是什么意思以及如何使用 -Xlint 重新编译

我的代码

        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);
    }
}

【问题讨论】:

标签: java android android-studio


【解决方案1】:

欢迎瑞兹。有许多经验丰富的开发人员,因此他们的简短而准确的答案可能看起来很粗鲁。不要让这阻止你学习。让我们一步一步解决您的问题。

  1. 已弃用意味着将来不再支持此方法。您可能应该使用一种新方法。此方法可能不在您的代码中,而是在您使用的某个库中。

  2. Linting 是在这种情况下检查一些额外的非重要错误https://en.wikipedia.org/wiki/Lint_(software) 的过程。

  3. 以下是有关此主题的一些先前问题 How to recompile with -Xlint:deprecation How to add -Xlint:unchecked to my Android Gradle based project? Note: Recompile with -Xlint:deprecation for details

也可能感兴趣 How to show the compile error's details on Android Studio? Android Studio: Where is the Compiler Error Output Window? https://developer.android.com/studio/write/lint

Gradle 是一款构建工具,它可以完成为您构建应用所需的所有步骤。编译检查 lints 合并等。

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

【讨论】:

  • 非常感谢它的帮助
猜你喜欢
  • 2021-08-22
  • 1970-01-01
  • 2021-12-11
  • 2020-04-19
  • 2021-04-27
  • 2021-08-26
  • 2021-12-20
  • 1970-01-01
相关资源
最近更新 更多