AndroidStudio 構(gòu)建出錯(cuò)“ERROR: The SourceSet 'lintOptions' is not recognized by the Android Gradle Plu...

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.

參考答案鏈接:lintOptions not being recognized by Gradle

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容