本文旨在记录开发过程中遇到的错误异常信息,并记录解决的办法以及自己对出现此种错误异常的原因的一些推测 若有纰漏还请各路大神不吝指正
1.java.lang.IllegalArgumentException: No config chosen
原因:SDK找不到支持OPENGL的硬件
用户钩选了Use Host Gup 选项,此选项是说模拟器使用用户物理机上的GPU。如果用户物理机没有独立显卡,就会报错,此种情况下不钩这个选项就可以了。模拟器设置问题,与sdk没关系.
解决:真机测试
2.Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
原因:貌似是工程中的方法数量超过安卓规定65536个方法数了
解决:在工程的混淆配置文件 proguard-rules.pro 中加入下面这句代码即可:
-keepattributes EnclosingMethod
原因:加载不到so库
解决:删除arm64-v8a 文件夹即可。
4. UnsupportedMethodException
Unsupported method: AndroidProject.getPluginGeneration().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.
原因 : Android Studio升级到最新版本后,没有升级build-tools,无法使用instant run功能,导致运行项目时,报这个错
解决:
1. 关掉 instant run功能
File - Settings - Build, Execution, Deployment - Instant Run
去掉打勾:Enable Instant Run to hot swap code/resource changes on deploy(default enabled)
2. 升级build-tools
打开SDK Manager进行更新
5. Gradle 'SimpleLineView-master' project refresh failed
Error:This Gradle plugin requires a newer IDE able to request IDE model level 3. For Android Studio this means version 3.0+
原因: Gradle插件需要一个更新的IDE来请求IDE模型级别3。对于Android Studio来说,这意味着版本3.0 +
解决: 更新AndroidStudio到响应的版本就行了
6.使用DataBinding编译报错
错误信息 : Error:Execution failed for task ':app:mergeDebugResources'.
> Error: ****/ data binding error ****msg:Only one layout element and one data element are allowed. C:\Users\Administrator\Desktop\testMVVM\app\src\main\res\layout\activity_main.xml has 2
file:C:\Users\Administrator\Desktop\testMVVM\app\src\main\res\layout\activity_main.xml
原因 : xml文件中
解决: 将
7.java.lang.RuntimeException:
Unable to start activity ComponentInfo{包名}: android.view.InflateException: Binary XML file line #0: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
原因: xml文件中 的某个标签的大小写错误
8. android java.lang.SecurityException: Package 包名 is currently frozen!
打开新页面直接黑屏 并提示该错误
原因: 页面中的SharedPreferences配置错误 导致无法访问
9.Error:Execution failed for task ':app:preDebugAndroidTestBuild'
原因: 依赖包冲突
解决:
在app下的build.gradle文件中的dependences {}中添加如下代码:
dependencies {
androidTestCompile('com.android.support:support-annotations:26.1.0') {
force = true
}
...
}
10.Error:(30, 31) 错误: 找不到符号
符号: 类 KeyEventCompat
位置: 程序包 android.support.v4.view
原因:KeyEventCompat类被取消了 hasNoModifiers方法已经被KeyEvent实现
解决:
if (KeyEventCompat.hasNoModifiers(event)) {
handled = arrowScroll(FOCUS_FORWARD);
} else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) {
handled = arrowScroll(FOCUS_BACKWARD);
}
//改为
if (event.hasNoModifiers()) {
handled = arrowScroll(FOCUS_FORWARD);
} else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) {
handled = arrowScroll(FOCUS_BACKWARD);
}
//即可
11.Error:All flavors must now belong to a named flavor dimension.
原因:AndroidStudio升级到3.0之后,配置多版本打包运行的时候会提示这个错误
解决:在app的gradle中的defaultConfig{}中添加
flavorDimensions "default"
12.No toolchains found in the NDK toolchains folder for ABI with prefix
原因:NDK的包在3.0以后进行了修改,出现了版本不兼容
解决:将gradle版本升级到3.0以上,同时将AS升级到3.1以上
13.Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'
原因:依赖的第三方开源项目包有些是重复的
解决:在APP的gradle的defaultConfig{}中配置
multiDexEnabled true