【问题标题】:building AAR in Android Studio在 Android Studio 中构建 AAR
【发布时间】:2021-01-12 18:01:45
【问题描述】:

这是我第一次构建 AAR

官方网站说我讨厌做的就是构建 APK 并组装 AAR

这是报价:

但是当我选择“Build Apk(s)”时,什么也没有发生。

另一个教程说我必须选择 Gradle-> 库名称-> 任务-> 构建-> :assembleRelease

但是没有这样的事情:

如何将库组装为 AAR?

这是我的毕业论文:

plugins {
    id 'com.android.library'
    id 'kotlin-android'
    id 'kotlin-kapt'
}

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"

    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    def room_version = "2.2.3"
    implementation "androidx.room:room-runtime:$room_version"
    kapt "androidx.room:room-compiler:$room_version"
    implementation "androidx.room:room-ktx:$room_version"
    implementation "androidx.room:room-rxjava2:$room_version"
    implementation 'com.google.code.gson:gson:2.8.2'
}

【问题讨论】:

    标签: android gradle aar


    【解决方案1】:

    只需点击assemble 或添加buildTypes.debug。虽然您没有定义 buildTypes.debug,但它不会生成您正在寻找的任务(因为那里只有一个配置,所以没有什么可区分的)。

    【讨论】:

    • assemble 说“构建成功”并且构建库中没有 aar
    • 它不应该有 AAR,但应该导致 AAR。没有其他任务要构建。
    • 到什么目录? “构建”目录没有它
    猜你喜欢
    • 2014-08-10
    • 2019-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-16
    相关资源
    最近更新 更多