How to create a release android library package (aar) in Android Studio (not debug)

后端 未结 9 805
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-02 07:50

I have built my android library package (aar) and the result of build is created in \"..\\app\\build\\outputs\\aar\" folder. The file within this folder is called \"app-deb

相关标签:
9条回答
  • 2020-12-02 08:37

    Yet another 2 part question where nobody answers the second part...

    For the future generations, here are simple answers:

    Part 1 How to create release only *release.aar ?

    Run in android studio terminal (or any terminal in your project folder).:

    ./gradlew assembleRelease
    

    You don`t need signing config for such task.

    Part 2 How to rename the output library to AnotherLibraryName-release.aar ?

    Add to your module gradle.build :

    android{
        project.archivesBaseName = "AnotherLibraryName"
    }
    
    0 讨论(0)
  • 2020-12-02 08:40

    1.add following script to your android{} tag in build.gradle to generate a release build:

    signingConfigs {
        testConfig{
            storeFile file("X:/XXXX/yourkeystore")
            storePassword "yourKeyPassword"
            keyAlias "yourAlias"
            keyPassword "yourAliasPassword"
        }
    }
    
    buildTypes{
        release {
            signingConfig  signingConfigs.testConfig
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    

    2.run command "gradle clean build" in you command line.

    0 讨论(0)
  • 2020-12-02 08:42

    This issue of can already be handled with the answers like execute

    ./gradlew assembleRelease
    

    or choose assembleRelease from Android Studio's Gradle menu. However, for completeness, with Android Studio 1.5.1 (and probably also older versions) building release version of a .aar can be accomplished by selecting Build->"Build APK" in Android Studio. It seems to execute assembleRelease. If your project only contains the library project, it does not ask for any signing information.

    0 讨论(0)
提交回复
热议问题