Android Studio 2.3中的Gradle缩进问题 [英] Gradle indentation issue in Android Studio 2.3

查看:292
本文介绍了Android Studio 2.3中的Gradle缩进问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次我在AS 2.3中创建一个新的Activity时,都会混淆build.gradle缩进,导致类似这样的错误。

错误:无法为类型为org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler的对象获取未知属性'compile'。



我必须重做每次缩进。任何想法如何永久解决这个问题?

解决方案

这个问题似乎是由包含花括号的行引起的:

  compile('com.github.tony19:logback-android-core:1.1.1-4'){
exclude group:'ch.qos.logback .core.net'
}

为了避免这个错误,只需将所有行在常规(即 compile'something')行上面加上花括号:

  compile fileTree(dir:'libs',include:['* .jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2' ,{
exclude group:'com.android.support',module:'support-annotations'
})

compile('com.github.tony19:logback-android -core:1.1.1-4'){
exclude group:'ch.qos.logback.core.net'
}
compile('com.github.tony19:logback-android -classic:1.1.1-4'){
exclude group:'ch.qos.logback.core.net'
}

compile'c​​om.bolyartech.forge.android:forge-android:6.1.0'
compile'c​​om.bolyartech.scram_sasl:scram_sasl:2.0.0'
compile'c​​om.android。 support:multidex:1.0.1'
compile'c​​om.squareup:otto:1.3.6'
compile'c​​om.google.code.gson:gson:2.7'
compile'c​​om。 github.franmontiel:PersistentCookieJar:v0.9.3'
compile'c​​om.google.dagger:dagger:2.9'
...


Every time I create a new Activity in AS 2.3 it messes up the build.gradle indentation that results in errors like this.

Error:Could not get unknown property 'compile' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

I have to redo the indentations every time. Any idea how to fix this permanently?

解决方案

The problem seems to be caused by the lines which contain curly braces like:

compile('com.github.tony19:logback-android-core:1.1.1-4') {
    exclude group: 'ch.qos.logback.core.net'
}

In order to avoid the bug just put all the lines with curly braces above the "usual" (i.e. compile 'something') lines like this:

compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})

compile('com.github.tony19:logback-android-core:1.1.1-4') {
    exclude group: 'ch.qos.logback.core.net'
}
compile('com.github.tony19:logback-android-classic:1.1.1-4') {
    exclude group: 'ch.qos.logback.core.net'
}

compile 'com.bolyartech.forge.android:forge-android:6.1.0'
compile 'com.bolyartech.scram_sasl:scram_sasl:2.0.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup:otto:1.3.6'
compile 'com.google.code.gson:gson:2.7'
compile 'com.github.franmontiel:PersistentCookieJar:v0.9.3'
compile 'com.google.dagger:dagger:2.9'
...

这篇关于Android Studio 2.3中的Gradle缩进问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆