問題一 : Error:All flavors must now belong to a named flavor dimension. Learn more
我是在項(xiàng)目的build.gradle中使用了productFlavors,結(jié)果編譯時(shí)報(bào)了如下錯(cuò)誤:
提示:Error:All flavors must now belong to a named flavor dimension.Learn?more?at?https://d.android.com/r/tools/flavorDimensions-missing-error-message.html?
原因
這個(gè)一個(gè)錯(cuò)誤笼痹,意思是:所有的flavors都必須屬于同一個(gè)風(fēng)格纹磺。
解決方法:
在主app的build.gradle里面,如下圖1-1所示添加代碼即可
就直接解決這個(gè)問題。然后app 就可以運(yùn)行起來(lái)了束铭。
問題二:?The SourceSet 'instrumentTest' is not recognized by the Android Gradle Plugin.
原因
是這里出問題了?instrumentTest.setRoot(‘tests’)?炭分,你可能在升級(jí) Android Studio 時(shí)更新了項(xiàng)目的 gradle 配置,這里的配置中 instrumentTest 已被棄用亏钩,不適用于現(xiàn)在的 gradle 版本莲绰。
解決辦法
用 androidTest 替換 instrumentTest,編譯運(yùn)行即可姑丑。
問題三:??DSL element 'DexOptions.incremental' is obsolete and will be removed at the end of 2018.
解決辦法
在gradle中將DexOptions如下圖1-2所示
刪除或者注釋就好蛤签!
問題四:?androidstudio3.1.2使用butterknife報(bào)錯(cuò)
報(bào)錯(cuò)提示:
Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration.- butterknife-7.0.1.jar
?Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior.? Note that this option is deprecated and will be removed in the future.
解決辦法
在app的build中android { ... defaultConfig { ... //添加如下配置就OK了javaCompileOptions { annotationProcessorOptions { includeCompileClasspath = true } } } ...}如下圖1-3所示:
問題五:? transformDexWithInstantRunDependenciesApkForDebug
好不容易build項(xiàng)目可以通過了,結(jié)果Run項(xiàng)目時(shí)報(bào)這個(gè)類型的錯(cuò)誤transformDexWithInstantRunDependenciesApkForDebug
這個(gè)問題我就查找了半天栅哀,后來(lái)發(fā)現(xiàn)原來(lái)是setting里面的設(shè)置問題:
Settings--->InstantRun ---->去掉第一個(gè)條目的對(duì)鉤就行了震肮。如下圖1-4所示: