2016-03-30 7 views
6

एक समय पहले मैं एप्लिकेशन मॉड्यूल में एक lint.xml फ़ाइल जोड़ने और निम्नलिखित lintOptions जोड़कर मेरी एंड्रॉयड स्टूडियो परियोजना के लिए फाहा जोड़ने की कोशिश की:फाहा नाकाम रहने नहीं बनाता

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

सब कुछ ठीक काम कर रहा था, डिबग बनाता है जब लिंट त्रुटियां थीं और अन्यथा गुजर रही थी तो असफल रहे थे। मैंने प्रोजेक्ट में बदलावों को शामिल नहीं किया है, हालांकि मैं हाल ही में उन परिवर्तनों में लौट आया हूं ताकि यह पता चल सके कि बिल्ड अब लिंट त्रुटियों में विफल नहीं हैं। मुझे उस समय के दौरान प्रोजेक्ट में किए गए बदलावों को नहीं लगता है। रिलीज बिल्ड अभी भी लिंट त्रुटियों पर असफल होने पर असफल रहे हैं।

क्या मैं फाहा कार्य इकट्ठा कर सकते हैं से

डिफ़ॉल्ट रूप से चलाने के लिए माना जाता है, लेकिन मैं कार्यों के भाग के रूप में दिखाई दे रहा है जब मैं निर्माण

अतिरिक्त जानकारी है कि मदद कर सकता है चलाएँ:

  • मैं > पुनर्निर्माण परियोजना और
    नहीं हरा प्ले बटन - //services.gradle.org/distributions/gradle-2.10-all.zip
  • मैं एंड्रॉयड स्टूडियो बिल्ड के माध्यम से निर्माण कर रहा हूँ: साथ distributionUrl = https Gradle आवरण का उपयोग कर रहा हूँ (मुझे पता है कि यह आरयू नहीं होगा n फाहा)
  • 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 को जोड़ सकते हैं -

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

}

लाइब्रेरी परियोजनाओं के लिए: मूल रूप से आप को इकट्ठा कार्य कर चलाने के लिए यह मजबूर करने के लिए फाहा कार्य पर निर्भर फाइल? हो सकता है कि आप ऐसे फैसले जोड़ रहे हैं जो सबकुछ लिंट पास कर लेते हैं .... –

उत्तर

3

मिले Run lint when building android studio projects पर एक समाधान।

libraryVariants.all { variant -> 
    variant.outputs.each { output -> 
     def lintTask = tasks["lint${variant.name.capitalize()}"] 
     tasks["bundle${variant.name.capitalize()}"].dependsOn lintTask 
    } 
} 
संबंधित मुद्दे