• Android Studio导出jar包


    Eclipse直接有个Export,可以直接导出jar包。AS相对Eclipse变化很大,编译脚本变成了Gradle,各种导包操作都有差异。

    下面是AS导出jar的过程:

    第一步,修改app下的build.grade。

    apply plugin: 'com.android.application'
    

    修改为

    apply plugin: 'com.android.library'
    

    第二步,增加一些配置。

    task makeJar(type: Copy) {    
        delete 'build/libs/uzAMap.jar'  
        from('build/intermediates/bundles/release/')    
        into('build/libs/')    
        include('classes.jar')    
        rename ('classes.jar', 'uzAMap.jar')
    }
    makeJar.dependsOn(build)
    
    

    第三步,去除applicationId

    defaultConfig {
            applicationId "com.apicloud.amap"
            minSdkVersion 14
            targetSdkVersion 21
    }
    

    改为

    defaultConfig {
            minSdkVersion 14
            targetSdkVersion 21
    }
    

    第四步,进入Terminal,执行脚本。

    gradlew makeJar
    

    完整的build.gradle

    apply plugin: 'com.android.library'
    
    android {
        compileSdkVersion 23
        buildToolsVersion "26.0.2"
    
        defaultConfig {
            applicationId "com.apicloud.amap"
            minSdkVersion 14
            targetSdkVersion 21
        }
    
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            }
        }
    }
    
    dependencies {
        compile 'com.android.support:support-v4:23.4.0'
        compile files('libs/AMap_3DMap_V3.3.2_20160525.jar')
        compile files('libs/AMap_Location_V2.4.1_H5.jar')
        compile files('libs/AMap_Search_V3.2.1_20160308.jar')
        compile files('libs/apiEngine v1.1.0.jar')
        compile files('libs/xUtils-2.6.1.jar')
    }
    
    task makeJar(type: Copy) {
        delete 'build/libs/uzAMap.jar'
        from('build/intermediates/bundles/release/')
        into('build/libs/')
        include('classes.jar')
        rename ('classes.jar', 'uzAMap.jar')
    }
    makeJar.dependsOn(build)
    
    
    

  • 相关阅读:
    解决Struts中文乱码问题总结
    多校第十场1009 CRB and String题解
    DirectX--Filter属性页的调用
    理解ThreadLocal类
    unity3d
    使用Java8提供的Duration类制作字幕时间轴调整工具
    算法练习--卡片游戏
    在eclipse中创建web项目
    testNg官方文档
    TestNG基本注解(注释)
  • 原文地址:https://www.cnblogs.com/jiqing9006/p/7762256.html
Copyright © 2020-2023  润新知