前言
我使用的Android stuido开发android项目,现在有A项目和B项目,B项目中需要用到A项目的apk包(A项目的apk放到B项目的assets目录下)
代码
apply plugin: ‘com.android.application‘
//这里是要输入的路径
def outputPathName = "/Users/zsl/Downloads/Bproject/assets/some.apk"
android {
signingConfigs {
demo {
keyAlias ‘Demo‘
keyPassword ‘.......‘
storeFile file(‘/Users/zsl/Downloads/android/appkey/keydemo.jks‘)
storePassword ‘.......‘
}
Full {
keyAlias ‘Full‘
keyPassword ‘.......‘
storeFile file(‘/Users/zsl/Downloads/android/appkey/key.jks‘)
storePassword ‘.......‘
}
}
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.zsl.fglass"
minSdkVersion 10
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
productFlavors {
demo {
applicationId "com.zsl.fglass.demo"
versionName "1.0"
}
full {
applicationId "com.zsl.fglass.full"
versionName "1.1"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(‘proguard-android.txt‘), ‘proguard-rules.pro‘
}
debug {
debuggable true
}
}
//这是应用编译完成
applicationVariants.all { variant ->
variant.outputs.each { output ->
//开始输出
output.outputFile = new File(outputPathName)
}
}
}
dependencies {
compile fileTree(include: [‘*.jar‘], dir: ‘libs‘)
compile ‘com.android.support:appcompat-v7:22.1.1‘
}
描述
这里的核心代码就两个(如下),我们先声明需要输出的路径然后在应用编译完成之后执行输出方法
核心代码总结
- 声明输出路径
def outputPathName = "/Users/zsl/Downloads/Bproject/assets/some.apk"
- 执行输入
//这是应用编译完成
applicationVariants.all { variant ->
variant.outputs.each { output ->
//开始输出
output.outputFile = new File(outputPathName)
}
}
时间: 2024-10-11 23:05:39