简体   繁体   English

使用Android Studio 3.0 Canary 7无法生成AAR / JAR

[英]AAR / JAR not get generated with Android Studio 3.0 Canary 7

So, the title pretty much sums up my problem. 所以,标题几乎总结了我的问题。 Anyone know how to fix it? 谁知道怎么修它? Last time I build apk, it work fine on AS 2.X, but, I'm now developing with Kotlin so, I have to use AS 3.0. 上次我构建apk,它在AS 2.X上工作正常,但是,我现在正在使用Kotlin进行开发,所以我必须使用AS 3.0。

I use AS 3.0 Canary 7 (This project is a fresh project) 我使用AS 3.0 Canary 7(这个项目是一个新项目)

This is my dummy class in my library (Stored in "domain".library.mylibrary) 这是我的库中的虚拟课程(存储在“domain”.library.mylibrary中)

class Test {
    fun hello(): String {
        return "hello"
    }
}

And this is my (mylibrary) gradle: 这是我的(mylibrary)gradle:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"


    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    implementation 'com.android.support:appcompat-v7:26.0.0-beta2'
    testImplementation 'junit:junit:4.12'

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" //Declared in project level gradle: ext.kotlin_version = '1.1.3-2'
}

My gradlew.bat clean build --info log: https://pastebin.com/bfTZ5s4e 我的gradlew.bat clean build --info log: https ://pastebin.com/bfTZ5s4e

Android Studio does not generate a jar by default, but rather an AAR file. 默认情况下,Android Studio不会生成jar,而是生成AAR文件。 If you want to get a jar output , you need to implement apply plugin: 'maven-publish' on top of your mylibrary/gradle.build file and read the following document: Chapter 36. Maven Publishing (new) 如果你想获得一个jar输出 ,你需要在mylibrary/gradle.build文件的顶部实现apply plugin: 'maven-publish'并阅读以下文档: 第36章Maven Publishing(新)

Another note, is that I would suggest you not to use ProGuard directly on your release artifact, but rather provide a consumer ProGuard file and let the users of your library to handle that task, otherwise they will have a hard time referencing obfuscated code. 另一个注意事项是,我建议你不要直接在你的发布工件上使用ProGuard ,而是提供一个消费者ProGuard文件,让你的库用户来处理这个任务,否则他们将很难引用混淆代码。 Read my answer on this here 这里阅读我的答案

While the build task may generate an output, it is known that the assemble task (or assembleRelease ) is the one that will generate your aar output. 虽然构建任务可能会生成输出,但已知assemble任务(或assembleRelease )将生成您的aar输出。

Try running the following command: 尝试运行以下命令:

./gradlew clean assembleRelease

and check the output in /mylibrary/build/outputs/apk/release/ if I am not mistaken. 并检查/mylibrary/build/outputs/apk/release/如果我没有记错的话。

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

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