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 14targetSdkVersion 21
}
改为
defaultConfig {minSdkVersion 14targetSdkVersion 21
}
第四步,进入Terminal,执行脚本。
gradlew makeJar
完整的build.gradle
apply plugin: 'com.android.library'android {compileSdkVersion 23buildToolsVersion "26.0.2"defaultConfig {applicationId "com.apicloud.amap"minSdkVersion 14targetSdkVersion 21}buildTypes {release {minifyEnabled falseproguardFiles 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)
本文转自TBHacker博客园博客,原文链接:http://www.cnblogs.com/jiqing9006/p/7762256.html如需转载请自行联系原作者