Android程序報錯以及解決辦法


INSTALL_FAILED_OLDER_SDK

Launching ‘app’ on Genymotion Google Nexus 5.
Installation did not succeed.
The application could not be installed: INSTALL_FAILED_OLDER_SDK
The application’s minSdkVersion is newer than the device API level.
Retry
在這里插入圖片描述

原因:

The application’s minSdkVersion is newer than the device API level.
application’s minSdkVersion:Android Studio 的項目的SDK版本
the device API level:虛擬機運行的API版本

辦法:

安裝相匹配的模擬機

Genymotion模擬機Android API 信息:
在這里插入圖片描述
項目版本信息:
在這里插入圖片描述
兩者的版本,應該相匹配

This view is not constrained. It only has designtime positions, so it will jump to (0,0) at runtime unless you add the constrain1

情況:
在視圖中操作控件時報錯

解決辦法:
在視圖中選中報錯控件,點擊魔術棒形狀的按鈕,添加約束
在這里插入圖片描述

The activity must be exported or contain an intent-filter2

解決辦法:
在 AndroidManifest.xml 對應的activity中添加一條屬性
android:exported=“true”

 <activity android:name=".ClickEvent" android:exported="true"></activity>

AGPBI: {“kind”:“error”,“text”:"‘M’ is not a valid file-based resource name character: File-based resource names must contain only lowercase a-z, 0-9, or underscore",“sources”: …}

原因:
命名不符合要求。only lowercase a-z, 0-9, or underscore(小寫的a到z,0到9,或者下划線)

解決辦法:
修改"sources"后面指向的文件名稱

Can’t resolve symbol ‘…’

原因:
在.java文件中提示,缺少相應的import語句
變量未聲明

解決辦法:
1.將該部分,回退,鍵盤輸入,由AS自動補全代碼
2.快捷鍵Alter+Enter
在這里插入圖片描述

新建項目的語言與使用語言不符合

新建項目時,選擇使用的編程語言在這里插入圖片描述
android視圖下java/…/MainActivity.java
在這里插入圖片描述
下面的文件的后綴名是.java就是java語言,.kt就是kotlin語言


  1. Android 學習之那些年我們遇到的BUG1:This view is not constrained, it only has designtime positions ↩︎

  2. Error running second Activity: The activity must be exported or contain an intent-filter ↩︎


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM