我有一个名为Common的库项目,我用它来实现我的其他项目Consumer和Management共享的功能。消费者本身也是其他应用程序使用的库项目。
Common中的build.gradle文件包含其他项目使用的所有外部依赖项,如下所示:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.code.gson:gson:2.2.2'
compile 'com.android.support:support-v4:22.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
}
下载以下库:
当我将Common添加到Consumer,Management或两者时,此列表保持不变。当我像这样添加Consumer到MyApp时:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':consumer')
}
发生这种情况:
支持库刚刚消失,在我的项目中造成了彻底的破坏。这在更新到Android Studio 1.3.1之前没有发生,因此我真的想知道问题可能是什么。
作为参考,这些是完整的gradle.build文件:
公用
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 11
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.code.gson:gson:2.2.2'
compile 'com.android.support:support-v4:22.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
}
管理
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "eu.test.mgmt"
minSdkVersion 11
targetSdkVersion 22
multiDexEnabled = true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/ASL2.0'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':common')
}
消费
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
lintOptions {
checkReleaseBuilds false
abortOnError false
}
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
versionCode 18
versionName "1.3"
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { res.srcDirs = ['src/main/res', 'src/main/xml', 'src/main/res/xml'] } }
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':common')
}
MyApp的:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "eu.test.myapp"
minSdkVersion 15
targetSdkVersion 22
versionCode 19
versionName "1.4"
multiDexEnabled = true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/ASL2.0'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':consumer')
}
答案 0 :(得分:0)
尝试单击项目结构的图标并检查有关结构的详细信息。有时它可能是您导入库缺少一些重要步骤
答案 1 :(得分:0)
导入或删除任何库后最好清理和重建项目,这样就不会出现任何GC 在 Android Studio 中。