Android studio broke up my build.gradle file after

2019-01-23 03:22发布

Using Android Studio 2.0 over El Capitan like the next screenshot said:
Android Studio 2.0 on El Capitan

I found a bug that I can't report: After add a Fragment to my project, AS screw up my module build.gradle file. I mean, before add the fragment they file looks like this screenshot:
build.gradle dependence screenshot

but after add the Fragment AS screw it in this way:
build.gradle dependence screenshot 2

The way to reproduce it is like I'm showing in next screenshot:
enter image description here

I can fix it manually, but its so annoying doing it every single time that I add a Fragment. Is there anyway to fix it?

I'm on Mac OX with El Capitan.

4条回答
劫难
2楼-- · 2019-01-23 03:33

put your constraint-layout on the bottom, it will not scramble again (i don't know why, but it works)

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    // support lib
    compile "com.android.support:appcompat-v7:$supportlib_version"

    // kotlin
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

    // ...

    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
}
查看更多
forever°为你锁心
3楼-- · 2019-01-23 03:38

It is a still open bug, you can monitor it's state here

The bug is due to the comments in the dependencies section, a temporal fix could be to remove them from there. I placed the comments there for a reason too :)

查看更多
太酷不给撩
4楼-- · 2019-01-23 03:44

just reformat your project level gradle . It will work fine. These compile statement got dis-formatted. Just hit Enter before every "compile" it should be like:

compile 'com.android.support:support-v13:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:design:23.4.0'

img

查看更多
贼婆χ
5楼-- · 2019-01-23 04:00

Delete all comments in your gradle file

查看更多
登录 后发表回答