4. Gradle DSL method not found runProguard
今天下载了新版本的Android Studio,导入以前做的demo时,出现了这样的错误。<code class="hljs oxygene has-numbering">Error:(<span class="hljs-number">16</span>, <span class="hljs-number">0</span>) Gradle DSL <span class="hljs-function"><span class="hljs-keyword">method</span> <span class="hljs-title">not</span> <span class="hljs-title">found</span>:</span> <span class="hljs-string">'runProguard()'</span> Possible causes: <ul><li>The project <span class="hljs-string">'Mobile'</span> may be <span class="hljs-keyword">using</span> a version <span class="hljs-keyword">of</span> Gradle that does <span class="hljs-keyword">not</span> contain the <span class="hljs-function"><span class="hljs-keyword">method</span>. <<span class="hljs-title">a</span> <span class="hljs-title">href</span>="<span class="hljs-title">open</span>.<span class="hljs-title">wrapper</span>.<span class="hljs-title">file</span>"><span class="hljs-title">Open</span> <span class="hljs-title">Gradle</span> <span class="hljs-title">wrapper</span> <span class="hljs-title">file</span></<span class="hljs-title">a</span>> </<span class="hljs-title">li</span>><<span class="hljs-title">li</span>><span class="hljs-title">The</span> <span class="hljs-title">build</span> <span class="hljs-title">file</span> <span class="hljs-title">may</span> <span class="hljs-title">be</span> <span class="hljs-title">missing</span> <span class="hljs-title">a</span> <span class="hljs-title">Gradle</span> <span class="hljs-title">plugin</span>. <<span class="hljs-title">a</span> <span class="hljs-title">href</span>="<span class="hljs-title">apply</span>.<span class="hljs-title">gradle</span>.<span class="hljs-title">plugin</span>"><span class="hljs-title">Apply</span> <span class="hljs-title">Gradle</span> <span class="hljs-title">plugin</span></<span class="hljs-title">a</span>></<span class="hljs-title">li</span>></span></code><ul style="" class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li></ul>
解决办法:
如果你在使用高于 0.14.0版本的 Gradle插件,那你需要将“runProguard”替换成“minifyEnabled”
以前的:
<code class="hljs bash has-numbering"> buildTypes { release { runProguard <span class="hljs-literal">false</span> proguardFiles getDefaultProguardFile(<span class="hljs-string">'proguard-android.txt'</span>), <span class="hljs-string">'proguard-rules.pro'</span> } }</code><ul style="" class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li></ul>
改正后:
<code class="hljs bash has-numbering"> buildTypes { release { minifyEnabled <span class="hljs-literal">false</span> proguardFiles getDefaultProguardFile(<span class="hljs-string">'proguard-android.txt'</span>), <span class="hljs-string">'proguard-rules.pro'</span> } }</code><ul style="" class="pre-numbering"><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li></ul>