android {
[...]
lintOptions {
abortOnError false
checkReleaseBuilds false
}
[...]
}
以上是gradle中l(wèi)int的相關(guān)配置,點(diǎn)擊sync 進(jìn)行同步時(shí),出現(xiàn)標(biāo)題的錯(cuò)誤。在stackoverflow查找了相關(guān)問(wèn)題后,找到以下答案:
- 答案一:
將gradle配置改成以下:
model {
android {
[...]
lintOptions.abortOnError false //只需要把lint配置改成這樣即可
[...]
}
}
經(jīng)測(cè)試,這個(gè)方法是有效的。
- 答案二:
將gradle配置改成如下:
model {
android.lintOptions {
abortOnError false
}
android {
// Rest of the other declarations goes here...
}
}
此答案與一類似,gradle的配置多了一個(gè)model外層,回答者也給了一個(gè)gradle變更的鏈接。打開(kāi)鏈接可以發(fā)現(xiàn)以下變更:
NOTE: There has been significant DSL improvements starting from version 0.6.0-alpha5 compare to previous versions. The example code here will not work for previous version. If you are using an older version of the plugin. Please refer to the user guide at https://sites.google.com/a/android.com/tools/tech-docs/new-build-system/gradle-experimental/0-4-0.
DSL Changes:
- Plugin name is com.android.model.application instead of com.android.application. Or use apply plugin: "com.android.model.library" if you want to create an Android aar library.
- Configuration is wrapped with the model { } block
- Adding elements to a Collection should be done using the add method.
Gradle變更資料鏈接
從以上可以知道,gradle配置用了一個(gè)model{}進(jìn)行包裝,而lintOptions等配置引用則更改為android.lintOptions。
DSL Change
The plugin is still in experimental stage. DSL will change throughout the development of the plugin. This section documents the changes that occurs between different versions to help with migration.0.6.0-alpha1 -> 0.6.0-alpha5
- Plugin now requires Gradle 2.10, which brings significant improvements to DSL
- Configurations can now be nested. E.g. you can write
android {
buildTypes {
...
}
}
instead of:
android.buildTypes {
...
}- File type now accepts a string, but String cannot be added to List<File> at the moment.
- -Dorg.gradle.model=true is now the default. This allows references to other model, but the model being referred to must be in a separate block.
- The equal sign '=' is no longer required for most properties.