【发布时间】:2016-03-23 21:49:42
【问题描述】:
我有这个项目结构: ProjectFolder/IosFolder,AndroidFolder,CommonFolder 现在 android 应用程序使用其资产文件夹中的文件。 但我们决定为相同的文件创建 Common 文件夹。
你能帮我制作一个函数,它将文件从 Common 文件夹(这个文件夹在我的项目下,所以在 Android Studio 中我看不到它)复制到 android assets 构建应用之前的文件夹?
Common 文件夹中有一些 .json 文件和字体文件。
据我了解,我需要在 build.gradle 文件中编写此函数 类似的东西:
task copyFiles(type: Copy)
copyFiles {
description = 'Copy files'
from 'Common/'
into 'Android/{projectName}/app/src/main/assets'
}
这是我的文件:
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "amc.amc_mobile_promo2"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
//For Flurry
multiDexEnabled = true
}
//For Flurry
/*compileOptions {
//noinspection GroovyAssignabilityCheck
sourceCompatibility JavaVersion.VERSION_1_7
//noinspection GroovyAssignabilityCheck
targetCompatibility JavaVersion.VERSION_1_7
}*/
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'joda-time:joda-time:2.8.2'
compile 'com.github.orangegangsters:swipy:1.2.0@aar'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.okhttp:okhttp:2.6.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.6.0'
/*compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services-ads:8.3.0'
compile 'com.google.android.gms:play-services-identity:8.3.0'
compile 'com.google.android.gms:play-services-gcm:8.3.0'*/
}
你能告诉我在 Gradle Console 中哪里可以看到执行方法的结果吗?
我需要使用什么路径以及在 build.gradle 文件中的哪个位置放置此方法?
希望你能帮助我。
【问题讨论】:
标签: android android-studio gradle build.gradle pre-build-event