简体   繁体   English

为什么Android Studio删除build.gradle中列出的依赖项?

[英]Why does Android Studio delete dependencies listed in build.gradle?

Earlier this week Android Studio started randomly deleting dependencies from my build.gradle file whenever I create a new file. 本周早些时候,每当我创建新文件时,Android Studio便开始从build.gradle文件中随机删除依赖项。 Is there a particular order that's expected? 是否有预期的特定顺序? My dependencies section looks like this: 我的依赖项部分如下所示:

dependencies {
    compile project(':ParallaxScroll')
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.gms:play-services:4.+'
    compile 'com.android.support:support-v4:19.+'
    compile 'com.android.support:support-v13:19.+'
    compile 'com.android.support:appcompat-v7:19.+'
    compile group: 'com.squareup.picasso', name: 'picasso', version: '2.2.0'
    compile group: 'com.squareup.retrofit', name: 'retrofit', version: '1.4.1'
    compile 'com.github.gabrielemariotti.cards:library:1.5.0'
    compile 'com.viewpagerindicator:library:2.4.1@aar'
    compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
    compile 'com.crashlytics.android:crashlytics:1.+'    
}

When I create a new activity in the project it ends up looking like this (this happens every time): 当我在项目中创建新活动时,它最终看起来像这样(每次都会发生):

dependencies {
    compile project(':ParallaxScroll')
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile group: 'com.squareup.picasso', name: 'picasso', version: '2.2.0'
    compile group: 'com.squareup.retrofit', name: 'retrofit', version: '1.4.1'

    compile 'com.google.android.gms:play-services:4.+'
    compile 'com.android.support:support-v4:19.+'
    compile 'com.android.support:support-v13:19.+'
    compile 'com.android.support:appcompat-v7:19.+'
}

It took a little while to figure out what was happening. 花了一段时间才弄清楚发生了什么。

Which of the two compile formats I'm using is correct? 我使用的两种编译格式中的哪一种是正确的? Is this potentially causing issues? 这可能会引起问题吗? It wasn't an issue until this week. 直到本周才成为问题。

I can of course restore my dependencies but this doesn't explain why AS is deleting things all the time. 我当然可以恢复我的依赖关系,但这不能解释为什么AS一直都在删除内容。

I'm also concerned about both support libraries being included. 我还担心两个支持库都包含在内。 As far as I know I'm using only v4 stuff. 据我所知,我只使用v4的东西。 Is using both bad practice? 是否同时使用两种不良做法?

This is a bug that will be fixed in 0.5.9. 这是一个错误,将在0.5.9中修复。 You can track it here: 您可以在此处跟踪它:

https://code.google.com/p/android/issues/detail?id=60749 https://code.google.com/p/android/issues/detail?id=60749

In the meantime, as a workaround, just create new activities by hand, or save off the contents of the build file before creating them through the wizard. 同时,作为一种解决方法,只需手动创建新活动,或保存构建文件的内容,然后再通过向导创建活动即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM