[英]Why does my app's icon get replaced by the default Android icon when going above minSdkVersion 20?
[英]Why does Android Studio lint not recognize my minSdkVersion
Android Studio (version 4.1.1) is displaying warnings in my xml layout files for views that use onClick (warning id: UsingOnClickInXml, older versions of the platform do not properly support resolving Android:onClick). 當我運行代碼檢查器時,這些也會出現在 lint 警告中。 Android Studio 似乎沒有使用我在 build.gradle(應用程序)文件中設置的 minSdkVerion (16)。
<Button
android:id="@+id/btn_Splash_PrivacyPolicy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick" //This gets highlighted with the warning
android:text="@string/dialog_button_privacyPolicy"
style="?android:attr/buttonBarButtonStyle"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
/>
這是我的 build.gradle (app) 文件的摘錄:
android {
compileSdkVersion 30
buildToolsVersion '30.0.3'
defaultConfig {
...
minSdkVersion 16
targetSdkVersion 30
...
}
...
}
這似乎保留在我合並的 AndroidManifest.xml 中(我沒有直接在清單中設置 minSdkVerion,僅在 build.gradle 文件中)。 摘自合並的 AndroidManifest.xml
<manifest
...
<uses-sdk
android.minSdkVersion="16"
android.targetSdkVersion="30" />
...
我如何在相關活動中使用 onClick 的示例:
public void onClick(View view){
if (view.getId() == R.id.btn_SplashOK) {
if (mCheckBox_SplashDontShowAgain.isChecked()) {
sendIntentInfoBack(Constants.DONT_SHOW_AGAIN);
} else {
sendIntentInfoBack(Constants.DO_SHOW_AGAIN);
}
} else if (view.getId() == R.id.btn_Splash_PrivacyPolicy){
Toolset.showPrivacyPolicyDialog(getSupportFragmentManager());
}
}
該應用程序正確顯示為 function,但我擔心 AS / lint 無法識別我設置的 minSdkVersion。
Android Studio 沒有選擇 minSdkVersion - 不適用; 我已經在正確的文件中設置了值。
Android Lint 錯誤地認為 min SDK 版本為 1 - 不適用? 根據答案,我無法在 AS 中找到“Clear Lint Markers”; 過時了嗎? (2012年的回答)
從版本 androidx.appcompat:appcompat:1.3.0 出現消息“在舊版本的平台上使用 'android:onClick' 已損壞”
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.