本周早些时候,每当我创建新文件时,Android Studio 就会开始从我的 build.gradle 文件中随机删除依赖项。 是否有预期的特定顺序? 我的依赖项部分如下所示:
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.+'
}
当我在项目中创建一个新 Activity 时,它最终看起来像这样(每次都会发生这种情况):
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.+'
}
花了一点时间才弄清楚发生了什么。
我使用的两种编译格式哪一个是正确的?这可能会导致问题吗?直到本周这才成为问题。
我当然可以恢复我的依赖项,但这并不能解释为什么 AS 总是删除东西。
我还担心这两个支持库都被包含在内。据我所知我只使用 v4 的东西。两者同时使用是不好的做法吗?
最佳答案
这是一个错误,将在 0.5.9 中修复。您可以在这里跟踪:
https://code.google.com/p/android/issues/detail?id=60749
同时,作为解决方法,只需手动创建新 Activity ,或者在通过向导创建它们之前保存构建文件的内容。
关于android - 为什么 Android Studio 会删除 build.gradle 中列出的依赖项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23407349/