Android studio导入模块显示(选择要导入的模块)

时间:2019-10-11 23:17:24

标签: android android-studio import module

我正在尝试将一个项目作为模块导入到我的主项目中。

该模块是从招摇代码生成器生成的代码。

但是,当我尝试导入模块时,在导入屏幕“选择要导入的模块”中出现错误!

在模块项目中是否有特定的事情要做,以使可导入?

这是我的模块项目的build.gradle文件:

apply plugin: 'idea'
apply plugin: 'eclipse'

group = 'org.openapitools'
version = '3.0.0'

buildscript {
    repositories {
        mavenCentral()
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
    }
}

repositories {
    jcenter()
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
}


if(hasProperty('target') && target == 'android') {

    apply plugin: 'com.android.library'
    apply plugin: 'com.github.dcendents.android-maven'

    android {
        compileSdkVersion 28
        buildToolsVersion '28.0.3'
        defaultConfig {
            minSdkVersion 14
            targetSdkVersion 28
        }
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }

        // Rename the aar correctly
//        libraryVariants.all { variant ->
//            variant.outputs.each { output ->
//                def outputFile = output.outputFile
//                if (outputFile != null && outputFile.name.endsWith('.aar')) {
//                    def fileName = "${project.name}-${variant.baseName}-${version}.aar"
//                    output.outputFile = new File(outputFile.parent, fileName)
//                }
//            }
//        }

        dependencies {
            provided 'javax.annotation:jsr250-api:1.0'
        }
    }

    afterEvaluate {
        android.libraryVariants.all { variant ->
            def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
            task.description = "Create jar artifact for ${variant.name}"
            task.dependsOn variant.javaCompile
            task.from variant.javaCompile.destinationDir
            task.destinationDir = project.file("${project.buildDir}/outputs/jar")
            task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
            artifacts.add('archives', task);
        }
    }

    task sourcesJar(type: Jar) {
        from android.sourceSets.main.java.srcDirs
        classifier = 'sources'
    }

    artifacts {
        archives sourcesJar
    }

} else {

    apply plugin: 'java'
    apply plugin: 'maven'

    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8

    install {
        repositories.mavenInstaller {
            pom.artifactId = 'swagger-petstore-retrofit2-rx'
        }
    }

    task execute(type:JavaExec) {
       main = System.getProperty('mainClass')
       classpath = sourceSets.main.runtimeClasspath
    }
}

ext {
    oltu_version = "1.0.1"
    retrofit_version = "2.3.0"
    swagger_annotations_version = "1.5.22"
    junit_version = "4.12"
    rx_java_version = "1.3.0"
    threetenbp_version = "1.3.5"
    json_fire_version = "1.8.0"
}

dependencies {
    compile "com.squareup.retrofit2:retrofit:$retrofit_version"
    compile "com.squareup.retrofit2:converter-scalars:$retrofit_version"
    compile "com.squareup.retrofit2:converter-gson:$retrofit_version"
    compile "com.squareup.retrofit2:adapter-rxjava:$retrofit_version"
    compile "io.reactivex:rxjava:$rx_java_version"
    compile "io.swagger:swagger-annotations:$swagger_annotations_version"
    compile "com.google.code.findbugs:jsr305:3.0.2"
    compile ("org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version"){
        exclude group:'org.apache.oltu.oauth2' , module: 'org.apache.oltu.oauth2.common'
    }
    compile "io.gsonfire:gson-fire:$json_fire_version"
    compile "org.threeten:threetenbp:$threetenbp_version"

    testCompile "junit:junit:$junit_version"
}

我的模块项目的gradle.properties文件也

# Uncomment to build for Android
target = android

0 个答案:

没有答案