关于安卓一些报错的解决方法(随时更新)

本文主要介绍了Android开发过程中常见的四种错误及其解决方案,包括依赖包冲突、TextView绑定错误、List未初始化及无法启动守护进程的问题。文章详细解释了每种错误的原因,并提供了具体的解决步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.Program type already present

依赖包冲突

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.1.1, 25.3.0. Examples include com.android.support:animated-vector-drawable:27.1.1 and com.android.support:design:25.3.0 less... (Ctrl+F1) 
There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion.)

若按提示加入

//noinspection GradleCompatible

  编译不会出现问题但在调试的时候就会报错

看提示应该是com.android.support:design版本和com.android.support:appcompat中显示的版本冲突,这时候把design版本置换即可,在dependencies中加入:

implementation 'com.android.support:design:27.1.1'

 

2.Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference

textview绑定错误,检查xml文件下id或xml文件是否绑定正确

 

3.Attempt to invoke interface method 'boolean java.util.List.add(java.lang.Object)' on a null object reference

原因:定义了 List<E> lists;   但并没有初始化

解决方法:

在使用前加入:

List<E> lists = new ArrayList<>();

 

4.Error:Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.

解决方法:

找到gradle.properties文件,将为注释掉的内容更换为:

org.gradle.jvmargs=-Xmx512m

 然后重启项目

转载于:https://www.cnblogs.com/yang12318/p/9027999.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值