android studio 错误汇总以及解决办法
android studio 错误汇总以及解决办法
问题1.
Error:Execution failed for task ':app:preDebugAndroidTestBuild'. > Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.1.0) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.
意思是“com.android.support:support-annotations”依赖冲突了,APP的 是26.1.0,而 测试APP是 27.1.1
解决措施:
1).最简单的方法,直接Rebuild Project ,此次编译可以通过,但后面还是出现,比如:Clean Project时
2).直接在build.gradle 修改SdkVersion
compileSdkVersion 26
targetSdkVersion 26
改为
compileSdkVersion 27
targetSdkVersion 27
3). 修改 dependencies

第一印象直接添加一句
com.android.support:support-annotations:26.1.0 ,就行了吧,等你同步后,发现然并卵
我这么试了发现根本就不行。查了好久才发现并不只是这一句有问题,在google之后http://stackoverflow.com/questions/28999124/resolved-versions-for-app-22-0-0-and-test-app-21-0-3-differ给出了一些解释。
简单粗暴的方法,添加force强制指定annotations,你会发现成功了
configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:26.1.0'
}
问题2
android.content.res.Resources$NotFoundException: String resource ID #0x0
在给TextView的setText(Int int)方法中的int指的是R.string.xxx,不能赋值其它int值
问题3、 apk安装出现闪退
java.lang.RuntimeException: Unable to instantiate application
在build.gradle文件中将gradle版本安装提示修改后重新编译得到解决
问题4
Error:Tag attribute name has invalid character ’ ‘.
Error:Tag attribute name has invalid character ’ ‘.
Error:org.gradle.process.internal.ExecException: Process ‘command
‘E:\Android\sdk\build-tools\26.0.2\aapt.exe” finished with non-zero
exit value 1 Error:Execution failed for task
‘:backend01:processDebugResources’.
Failed to execute aapt
这个错误是因为在AndroidManifest.xml中category的值有一个空格,将空格去除就好了
问题5
Error:Execution failed for task :app:processDebugAndroidTestResources.
No slave process to process jobs, aborting
clean和rebuild都没有成功后,直接点击 File>Invalidate Caches/Restart后编译通过
问题6
新建的工程 就出现这个错误
- 出现的异常
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.1.
Open File
Show Details
- 解决方案
看错误的信息
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.1.
我的理解 不能加载1.1.1 版本的 那么 就改成
dependencies {
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.1.1'
// implementation 'com.android.support.constraint:constraint-layout:1.1.1'
//替换陈这个版本的
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:support-v4:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
build
ok
问题7
1. Error:Execution failed for task ':app:transformNative_libsWithStripDebugSymbolForDDebug‘
java.lang.NullPointerException (no error message)
2. Error:Execution failed for task ':module:transformNative_libsWithStripDebugSymbolForDebug'.
java.lang.NullPointerException (no error message)
- 原因
Debug模式找不到NDK。 解决办法
注释掉第11行的ndk
image.png
问题8
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/graphics/drawable/DrawableWrapper;
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.graphics.drawable.DrawableWrapper" on path: DexPathList[[zip file "/data/app/com.cpsc.cpsc_pgsip-2/base.apk"],nativeLibraryDirectories=[/data/app/com.cpsc.cpsc_pgsip-2/lib/arm, /data/app/com.cpsc.cpsc_pgsip-2/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
- 根据问题得知是 android.support.v4.graphics.drawable.DrawableWrapper 找不到
- 解决办法 ,分2步
1.保持版本支持
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
compile 'com.android.support:design:27.1.1'
- 找到出问题的布局重新写一次,可能是这里的问题,我再做了1之后,发现没什么卵用(但是保持一致的还是好的)最后还是重新写一次布局ok了。
- 如果在v28.0.0上,可以尝试把android.support.v4.graphics.drawable.DrawableWrapper 改成android.support.v4.graphics.drawable.WrappedDrawable可以解决这个问题
android studio 错误汇总以及解决办法的更多相关文章
- Android Studio Gradle更新的解决办法
环境: Win7_64旗舰版.Android Studio2.1.1 问题描述: 在打开Android Studio项目的时候,会下载项目对应版本的gradle,由于是国外网站导致更新较慢,该版本是在 ...
- Android Studio --“Cannot resolve symbol” 解决办法
鼠标放上去后显示 “Cannot resolve symbol XXX”,重启 Android Studio,重新 sync gradle,Clean build 都没有用. 多半是因为 Androi ...
- Android Studio 自动更新失败解决办法
Check Update一直提示Connection failed. Please check your network connection and try again,开始以为是由于G*W在捣乱, ...
- 华为手机不能连接android studio进行调试的解决办法
出现情景:在开启了usb debugging(usb调试模式)后,AS(android studio)还是找不到真机. 解决办法:下载驱动精灵,检测是否安装了huawei的usb驱动,如果没有,安装成 ...
- 【转】 Android Studio --“Cannot resolve symbol” 解决办法
Android Studio 无法识别同一个 package 里的其他类,将其显示为红色,但是 compile 没有问题.鼠标放上去后显示 “Cannot resolve symbol XXX”,重启 ...
- Android Studio 更新失败的解决办法
编辑$ANDROID_STUDIO_HOME/bin/ 下的 studio.exe.vmoptions(如果系统用的Ubuntu,文件应该是studio.vmoptions或者如果是64位系统,应该是 ...
- Visual Studio警告IDE0006的解决办法
Visual Studio警告IDE0006的解决办法 Visual Studio警告IDE0006虽然给出明确的操作过程,但是在实施的过程中,还是有很多地方需要注意.下面以官方的信息,介绍一下注意 ...
- Android Studio Exception汇总
Android Studio 运行时出现 finished with non-zero exit value 2 错误分析 原因: 项目包含了两个相同包名的不同 project 或者 jar 举例: ...
- 错误异常 (1)Android Studio错误提示:Gradle project sync failed. Basic functionality (eg. editing, debugging) will not work properly
[已解决]Android Studio错误提示:Gradle project sync failed. Basic functionality (eg. editing, debugging) wil ...
随机推荐
- 【问题】man手册如何查看区分printf命令和printf函数
参考:UNIX / Linux Man Command Example to View Man Pages 今天再看别人博客的时候,先仔细看看printf命令是怎么玩的,于是man手册查了下.结果搜出 ...
- YUSS Round 1
YUSS Round 1 A. 国庆快乐 签到题. #include<bits/stdc++.h> using namespace std; int main() { printf(&qu ...
- 剑指Offer(三十):连续子数组的最大和
.# 剑指Offer(三十):连续子数组的最大和 搜索微信公众号:'AI-ming3526'或者'计算机视觉这件小事' 获取更多算法.机器学习干货 csdn:https://blog.csdn.net ...
- Gym - 102346D Denouncing Mafia 取k叶子节点使叶子到根覆盖节点数最大
给你一棵树 你可以取K条链 一条链为根到叶子的路径 问你K条链最多覆盖树上多少个节点 贪心的做 肯定是每次取最长链 但是取完最长链 一颗树就会变为若干个森林 我们要维护当前所有森林里的最长链 ans数 ...
- Android 测试-Robolectric,mockito,esspresso
代码参考:https://github.com/googlesamples/android-testing 解释参考: https://www.jianshu.com/p/5732b4afd12f 官 ...
- java只能的round,ceil,floor方法的使用
三者均位于java.lange包下的Math类中 round: 在原来数字的基础上加上0.5后向下取整, 例如: Math.floor(11.5)=12; Math.floor(-11.5)=-11( ...
- win10 水晶报表安装包
windows 10 64 VS2013安装 CR For VS 13_0_18 安装过程没有报错 安装成功http://downloads.businessobjects.com/akdlm/cr4 ...
- js实现发送验证码倒计时效果
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- input 限制输入数字和小数
//input 限制输入数字和小数 <input type="text" name="demo" value="" onkeyup=& ...
- [笔记] 三元环 && 四元环计数
Thanks to i207M && iki9! 三元环计数 无向图的三元环计数 我们首先需要对无向边按一定规则定向: 设 \(in[u]\) 表示 \(u\) 的度数 若 \(in[ ...