2016-03-30 3 views
6

Некоторое время назад я пытался добавить пух к моему андроиду студийного проекту, добавив файл lint.xml в модуле приложения и добавить следующие lintOptions:ворса не подведет строит

lintOptions { 
    abortOnError true 
    checkReleaseBuilds true 
    lintConfig file("lint.xml") 
} 

Все работало отлично, отлаживать строит были провалены, когда были ошибки ворса и передавались иначе. Я не включил изменения в проект, хотя и недавно вернулся к этим изменениям, чтобы найти, что сборки больше не терпят ошибок lint. Кажется, я не могу найти изменения, внесенные в проект за это время, вызвавшие это. Релиз сборки по-прежнему терпят неудачу по ошибкам lint, как ожидалось.

от того, что я могу собрать задачу ворса должен работать по умолчанию, но я не вижу его как часть задачи выполняется, когда я построить

дополнительной информации, которая может помочь:

  • я я с помощью Gradle обертки с distributionUrl = https: //services.gradle.org/distributions/gradle-2.10-all.zip
  • я строй через строить Android студии -> Rebuild Project и
    не зеленая кнопка воспроизведения (я знаю, что это не будет ru п ворса)
  • lint.xml:

<?xml version="1.0" encoding="UTF-8"?> 
 
<lint> 
 

 
    <!--The given layout_param is not defined for the given layout, meaning it has no 
 
    effect.--> 
 
    <issue id="ObsoleteLayoutParam" severity="error" /> 
 
    <!--A layout that has no children or no background can often be removed--> 
 
    <issue id="UselessLeaf" severity="error" /> 
 
    <issue id="HardcodedText" severity="error" /> 
 
    <issue id="UnusedResources" severity="error" /> 
 
    <!--AdapterViews such as ListViews must be configured with data from Java code, 
 
    such as a ListAdapter.--> 
 
    <issue id="AdapterViewChildren" severity="error" /> 
 
    <!--Missing commit() on SharedPreference editor--> 
 
    <issue id="CommitPrefEdits" severity="error" /> 
 
    <!--looks for cases where you have cut & pasted calls to 
 
    findViewById but have forgotten to update the R.id field--> 
 
    <issue id="CutPasteId" severity="error" /> 
 
    <!--Calling String#toLowerCase() or #toUpperCase() without specifying an explicit 
 
    locale is a common source of bugs.--> 
 
    <issue id="DefaultLocale" severity="error" /> 
 
    <!--Implied locale in date format--> 
 
    <issue id="SimpleDateFormat" severity="error" /> 
 
    <!--Incorrect order of elements in manifest--> 
 
    <issue id="ManifestOrder" severity="error" /> 
 
    <!--Using STRING instead of TEXT--> 
 
    <issue id="SQLiteString" severity="error" /> 
 
    <!--Memory allocations within drawing code--> 
 
    <issue id="DrawAllocation" severity="error" /> 
 
    <!--Handler is declared as an inner class, it may prevent the outer 
 
    class from being garbage collected.--> 
 
    <issue id="HandlerLeak" severity="error" /> 
 
    <!--Ellipsis string can be replaced with ellipsis character--> 
 
    <issue id="TypographyEllipsis" severity="error" /> 
 
    <!--ScrollViews can have only one child--> 
 
    <issue id="ScrollViewCount" severity="error" /> 
 
    <!--FragmentTransaction, you typically need to commit it as well--> 
 
    <issue id="CommitTransaction" severity="error" /> 
 
    <!--A scrolling widget such as a ScrollView should not contain any nested 
 
    scrolling widgets since this has various usability issues--> 
 
    <issue id="NestedScrolling" severity="error" /> 
 
    <!--ScrollView children must set their layout_width or layout_height attributes to 
 
    wrap_content--> 
 
    <issue id="ScrollViewSize" severity="error" /> 
 
    <!--Using Wrong AppCompat Method--> 
 
    <issue id="AppCompatMethod" severity="error" /> 
 
    <!--Some methods have no side effects, an calling them without doing something 
 
    without the result is suspicious.--> 
 
    <issue id="CheckResult" severity="error" /> 
 
    <!--Duplicate ids across layouts combined with include tags--> 
 
    <issue id="DuplicateIncludedIds" severity="error" /> 
 
    <!--This check ensures that a layout resource which is defined in multiple 
 
    resource folders, specifies the same set of widgets.--> 
 
    <issue id="InconsistentLayout" severity="error" /> 
 
    <!--Wrong locale name--> 
 
    <issue id="LocaleFolder" severity="error" /> 
 
    <!--Target SDK attribute is not targeting latest version--> 
 
    <issue id="OldTargetApi" severity="error" /> 
 
    <!--Frequent alarms are bad for battery life.--> 
 
    <issue id="ShortAlarm" severity="error" /> 
 

 

 
    <!--Using system app permission--> 
 
    <issue id="ProtectedPermissions" severity="ignore" /> 
 
    <!--Package not included in Android--> 
 
    <issue id="InvalidPackage" severity="ignore" /> 
 

 
</lint>

+0

вы можете добавить в вопросе lint.xml файл? может быть, что вы добавляете правила, которые заставляют все пропустить lint .... –

ответ

3

Найдено решение на Run lint when building android studio projects. в основном вы делаете сборку задачи зависит от поставленной задачи ворса, чтобы заставить его работать:

applicationVariants.all { variant -> 
variant.outputs.each { output -> 
    def lintTask = tasks["lint${variant.name.capitalize()}"] 
    output.assemble.dependsOn lintTask 
} 

}

Для библиотечных проектов -

libraryVariants.all { variant -> 
    variant.outputs.each { output -> 
     def lintTask = tasks["lint${variant.name.capitalize()}"] 
     tasks["bundle${variant.name.capitalize()}"].dependsOn lintTask 
    } 
} 
Смежные вопросы