Can';t在Android Studio 3中导入外部项目作为模块
我已经在商店里发布了一个应用程序,升级到Android Studio 3(现在是3.1)和gradle的强制更新后,我无法将我的外部项目作为模块导入 我尝试过删除所有模块并逐个添加,删除缓存,更改gradle版本和CompileSDK版本,但都不起作用 当我尝试同步gradle时,会收到如下消息: 无法解析“”的依赖项:app@produzioneDebug/compileClasspath':无法使用transform-ExtractAarTransform将文件“ShareLib release.aar”转换为匹配属性{artifactType=android exploded aar} 这在my settings.gradle中,用于使外部项目可用:Can';t在Android Studio 3中导入外部项目作为模块,android,gradle,android-gradle-plugin,android-studio-3.1,Android,Gradle,Android Gradle Plugin,Android Studio 3.1,我已经在商店里发布了一个应用程序,升级到Android Studio 3(现在是3.1)和gradle的强制更新后,我无法将我的外部项目作为模块导入 我尝试过删除所有模块并逐个添加,删除缓存,更改gradle版本和CompileSDK版本,但都不起作用 当我尝试同步gradle时,会收到如下消息: 无法解析“”的依赖项:app@produzioneDebug/compileClasspath':无法使用transform-ExtractAarTransform将文件“ShareLib relea
include ':app'
include ':ShareLib'
project(':ShareLib').projectDir = new File('..//ShareLib//')
这是我的身材,格雷德尔
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'io.fabric.tools:gradle:1.+'
}
}
repositories {
jcenter()
mavenCentral()
mavenLocal()
maven {
url 'https://repo.spring.io/libs-milestone'
}
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
def AAVersion = '4.4.0'
android {
compileSdkVersion 26
buildToolsVersion "27.0.3"
defaultConfig {
minSdkVersion 15
targetSdkVersion 26
versionCode 3
versionName "1.0.0.0"
applicationId "com.xxx.app"
// Enabling multidex support.
multiDexEnabled true
javaCompileOptions {
annotationProcessorOptions {
arguments = ["resourcePackageName": android.defaultConfig.applicationId]
}
}
}
signingConfigs {
releaseSigning {
///
}
}
buildTypes {
debug {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
zipAlignEnabled true
}
release {
// proguard
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
shrinkResources false
zipAlignEnabled true
signingConfig signingConfigs.releaseSigning
}
}
flavorDimensions "tier"
productFlavors {
dev {
buildConfigField "String", "SERVICE_URL_BASE", "\"dev.xxx.com/xxx-rest\""
applicationId "development.xxx.app"
}
coll {
buildConfigField "String", "SERVICE_URL_BASE", "\"dev.xxx.com/xxx-rest\""
applicationId "test.xxx.app"
}
prod {
buildConfigField "String", "SERVICE_URL_BASE", "\"www.xxx.com/xxx-rest\""
applicationId "com.xxx.app"
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
dexOptions {
javaMaxHeapSize "4g"
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation project(path: ':shareLib', configuration: 'default')
// implementation project(path: ':shareLib', configuration: 'default') {
// exclude module: 'jsr305'
// }
// compile fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'com.squareup:otto:1.3.8'
implementation 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
implementation "org.androidannotations:androidannotations-api:$AAVersion"
annotationProcessor "org.androidannotations:rest-spring:$AAVersion"
implementation "org.androidannotations:rest-spring-api:$AAVersion"
annotationProcessor "org.androidannotations:otto:$AAVersion"
implementation "org.androidannotations:otto:$AAVersion"
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
// support AA on Android < 5
// compile 'com.android.support:multidex:1.0.1'
implementation 'com.github.markomilos:paginate:0.5.1'
// mpandroid
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.0-beta1'
// crashlytics fabric
implementation('com.crashlytics.sdk.android:crashlytics:2.6.1@aar') {
transitive = true
}
// recaptcha
implementation ('android.lib.recaptcha:reCAPTCHA:2.0.0') {
exclude group: 'com.android.support'
}
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.9.0'
}
buildscript{
存储库{
jcenter()
mavenCentral()
maven{url'https://maven.fabric.io/public' }
谷歌()
}
依赖关系{
classpath'com.android.tools.build:gradle:3.1.2'
类路径'io.fabric.tools:gradle:1.+'
}
}
存储库{
jcenter()
mavenCentral()
mavenLocal()
马文{
url'https://repo.spring.io/libs-milestone'
}
maven{url'https://maven.fabric.io/public' }
}
应用插件:“com.android.application”
应用插件:“io.fabric”
def AAVersion='4.4.0'
安卓{
编译DK26版
buildToolsVersion“27.0.3”
默认配置{
第15版
targetSdkVersion 26
版本代码3
versionName“1.0.0.0”
applicationId“com.xxx.app”
//启用多索引支持。
多索引启用真
javaCompileOptions{
注释处理器选项{
arguments=[“resourcePackageName”:android.defaultConfig.applicationId]
}
}
}
签名配置{
释放签名{
///
}
}
建筑类型{
调试{
minifyEnabled false
收缩资源是错误的
proguard文件GetDefaultProGuard文件('proguard-android-optimize.txt'),'proguard rules.pro'
Zipalignedtrue
}
释放{
//前卫
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard rules.pro'
收缩资源是错误的
Zipalignedtrue
signingConfig signingConfigs.releaseSigning
}
}
“层次”
产品风味{
发展{
buildConfigField“String”、“SERVICE\u URL\u BASE”、“dev.xxx.com/xxx rest”
applicationId“development.xxx.app”
}
科尔{
buildConfigField“String”、“SERVICE\u URL\u BASE”、“dev.xxx.com/xxx rest”
applicationId“test.xxx.app”
}
刺激{
buildConfigField“String”、“SERVICE\u URL\u BASE”、“www.xxx.com/xxx rest”
applicationId“com.xxx.app”
}
}
包装选项{
排除“META-INF/DEPENDENCIES.txt”
排除“META-INF/LICENSE.txt”
排除“META-INF/NOTICE.txt”
排除“META-INF/通知”
排除“META-INF/许可证”
排除“META-INF/依赖项”
排除“META-INF/notice.txt”
排除“META-INF/license.txt”
排除“META-INF/dependencies.txt”
排除“META-INF/LGPL2.1”
}
德克斯选项{
javaMaxHeapSize“4g”
}
林特选项{
checkReleaseBuilds为false
异常错误
}
编译选项{
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
依赖关系{
实现项目(路径:':shareLib',配置:'default')
//实现项目(路径:':shareLib',配置:'default'){
//排除模块:“jsr305”
// }
//编译文件树(目录:“libs”,包括:['*.jar'])
测试实现'junit:junit:4.12'
实现'com.squareup:otto:1.3.8'
实现“org.springframework.android:springandroid rest模板:2.0.0.M3”
annotationProcessor“org.androidannotations:androidannotations:$AAVersion”
实现“org.androidannotations:AndroidAnnotationsAPI:$AAVersion”
annotationProcessor“org.android注释:rest spring:$AAVersion”
实现“org.androidannotations:RESTSpringAPI:$AAVersion”
注释处理器“org.android注释:otto:$AAVersion”
实现“org.android注释:otto:$AAVersion”
实现'com.github.bumptech.glide:glide:3.7.0'
实现'com.android.support:support-v4:26.1.0'
实现'com.android.support:appcompat-v7:26.1.0'
实现'com.android.support:recyclerview-v7:26.1.0'
//Android上支持AA<5
//编译'com.android.support:multidex:1.0.1'
实现'com.github.markomilos:paginate:0.5.1'
//多潘德里克
实现'com.github.PhilJay:MPAndroidChart:v3.0.0-beta1'
//碎裂织物
实现('com.crashlytics.sdk.android:crashlytics:2.6。1@aar') {
可传递=真
}
//雷帕查
实现('android.lib.recaptcha:recaptcha:2.0.0'){
排除组:“com.android.support”
}
实现'com.fasterxml.jackson.core:jackson注释:2.9.0'
}
我已经解决了一个接一个地打开模块项目的问题,并对每个模块都这样做:
- 项目结构->项目->渐变版本=4.7
- 设置->构建、执行、部署->编译器->取消选中“按需配置”
- 在build/outputs/aar中看到.aar文件后重新生成项目
然后对主项目模块重复这些步骤您的依赖项中的ShareLib中有一个小写字母。如果这不能解决您的问题:您是否尝试过使用除实现之外的其他方法,如:api project(“:ShareLib:default”)?这是一个编辑错误,但我没有尝试过。