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 273). 修改 dependencies
image.png第一印象直接添加一句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' }android.content.res.Resources$NotFoundException: String resource ID #0x0在给TextView的setText(Int int)方法中的int指的是R.string.xxx,不能赋值其它int值
java.lang.RuntimeException: Unable to instantiate application
在build.gradle文件中将gradle版本安装提示修改后重新编译得到解决
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-zeroexit value 1 Error:Execution failed for task‘:backend01:processDebugResources’.Failed to execute aapt
这个错误是因为在AndroidManifest.xml中category的值有一个空格,将空格去除就好了
clean和rebuild都没有成功后,直接点击 File>Invalidate Caches/Restart后编译通过
新建的工程 就出现这个错误
出现的异常 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
解决办法注释掉第11行的ndk
image.png转载于:https://www.cnblogs.com/it-tsz/p/11512373.html
相关资源:JAVA上百实例源码以及开源项目