简体   繁体   English

无法将外部项目作为Android Studio 3中的模块导入

[英]Can't import external project as module in Android Studio 3

I have an app already published on the store, after upgrading to Android Studio 3 (now 3.1) and the forced update of gradle I am unable to import my external projects as modules. 升级到Android Studio 3(现在为3.1)并强制更新gradle之后,我已经在商店中发布了一个应用程序,我无法将外部项目导入为模块。

I have tried removing all my modules and adding them one by one, deleting the cache, changing gradle version, and compileSdkVersion but it doesn't work. 我尝试删除所有模块并一个接一个地添加它们,删除缓存,更改gradle版本和compileSdkVersion,但是它不起作用。

When I try to sync gradle I receive some messages like this: 当我尝试同步gradle时,会收到如下消息:

Unable to resolve dependency for ':app@produzioneDebug/compileClasspath': Failed to transform file 'ShareLib-release.aar' to match attributes {artifactType=android-exploded-aar} using transform ExtractAarTransform 无法解析':app @ produzioneDebug / compileClasspath'的依赖关系:无法使用转换ExtractAarTransform来转换文件'ShareLib-release.aar'以匹配属性{artifactType = android-exploded-aar}

This is in my settings.gradle to make external project available: 这在我的settings.gradle中,以使外部项目可用:

include ':app'

include ':ShareLib'
project(':ShareLib').projectDir = new File('..//ShareLib//')

This is my build.gradle 这是我的build.gradle

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'

}

I have solved opening modules project one by one and doing this for each one: 我已经解决了打开模块项目的一个接一个的问题,并为每个项目做一个:

  • Project Structure -> Project -> Gradle Version = 4.7 项目结构->项目-> Gradle版本= 4.7
  • Settings -> Build, Execution, Deployment -> Compiler -> Uncheck "Configure on demand" 设置->构建,执行,部署->编译器->取消选中“按需配置”
  • Rebuild project once you can see your .aar file into build/outputs/aar 一旦您可以看到您的.aar文件到build / outputs / aar,请重新构建项目

Then repeat these steps for main project module 然后对主项目模块重复这些步骤

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

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