how to create a jar file from android studio

前端 未结 5 1082

I have a fairly latest version of android studio, I have created a module under a project which is basically supposed to be a library, when I build it, it creates an \".aar\

5条回答
  •  -上瘾入骨i
    2021-01-04 20:47

    Add this in your library's gradle file:

    task deleteJar(type: Delete) {
        delete 'libs/traylib.jar'
    }
    
    task createJar(type: Copy) {
        from('build/intermediates/packaged-classes/release/')
        into('libs/')
        include('classes.jar')
        rename('classes.jar', 'traylib.jar')
    }
    
    createJar.dependsOn(deleteJar, build)
    

    You need to check path of your generated classes.jar: build/intermediates/packaged-classes/release/

    Create lib folder in your lib's root folder if it is not there

    Go to gradle build: Android Studio --> View --> Toll Windows --> Gradle

    Select your module(:library) --> Tasks --> other --> Double click on createJar task

提交回复
热议问题