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 ↩︎

向好的方向走一步,就离坏的结果远一步
原文地址:https://www.cnblogs.com/PersistLu/p/12608599.html