如何与Android的工作室到资产文件夹中运行复制任务 [英] How to run copy task with android studio into assets folder
问题描述
到目前为止,我还增加了以下我的的build.gradle
的结束 任务copyFiles(类型:复制)copyFiles {
说明='从公用库复制HTML5文件......
从../../www
进入资产/ WWW
包括('**/*')
}
现在我只是需要Ø如何使这项工作得到执行的每次(前)编译Android源一定的帮助。我可以从命令行手动运行复制任务,但我还想有,当我在Android Studio中单击运行运行它。
下面的建议的帮助下,我加入了
clean.dependsOn copyFiles
clean.mustRunAfter copyFiles
和本此外,我可以让我的复制任务做重建运行 - >运行。
这是聊胜于无,但它会很高兴地跳过重建的一步。
下面是整个的build.gradle,即时通讯与Android Studio中使用。
buildscript {
库{
mavenCentral()
}
依赖{
类路径'com.android.tools.build:gradle:0.5.+
}
}
应用插件:'机器人'依赖{
编译文件(/库/ ACRA-4.3.0.jar')
}安卓{
compileSdkVersion 17
buildToolsVersion17 defaultConfig {
8的minSdkVersion
targetSdkVersion 17
}
sourceSets {
主要{
manifest.srcFile'的AndroidManifest.xml
java.srcDirs = ['src'中,'库']
resources.srcDirs = ['src'中]
aidl.srcDirs = ['src'中]
renderscript.srcDirs = ['src'中]
res.srcDirs = ['水库']
assets.srcDirs = ['资产']
} instrumentTest.setRoot(测试)
}
}
任务copyFiles(类型:复制)copyFiles {
说明='从公用库复制HTML5文件......
从../../www
进入资产/ WWW
包括('**/*')
}clean.dependsOn copyFiles
clean.mustRunAfter copyFiles
这样我做的文件资源的定制复制在我的Android-gradle这个构建系统
preBuild.dependsOn copyFiles
So far I have added the following to the end of my "build.gradle"
task copyFiles(type: Copy)
copyFiles {
description = 'Copies html5 files from the common library...'
from '../../www'
into 'assets/www'
include('**/*')
}
Now I just need some help on how o make this task get executed everytime (before) compiling the android source. I can run the copy task manually from command line, but Id like to have it run when I click "run" in android studio.
With the help of suggestion below, I have added
clean.dependsOn copyFiles
clean.mustRunAfter copyFiles
And with this addition I can get my copy task to run by doing rebuild -> run. It's better than nothing but it would be nice to skip the rebuild step.
Here is the whole build.gradle that im using with android studio.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
dependencies {
compile files('/libs/acra-4.3.0.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17"
defaultConfig {
minSdkVersion 8
targetSdkVersion 17
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src','libs']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
task copyFiles(type: Copy)
copyFiles {
description = 'Copies html5 files from the common library...'
from '../../www'
into 'assets/www'
include('**/*')
}
clean.dependsOn copyFiles
clean.mustRunAfter copyFiles
This way I do custom copying of file assets in my android-gradle build system
preBuild.dependsOn copyFiles
这篇关于如何与Android的工作室到资产文件夹中运行复制任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!