問題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了。