Criair evento pré-compilado paira copy files paira a pasta de resources no aplicativo Android

Eu tenho essa estrutura de projeto: ProjectFolder / IosFolder, AndroidFolder, CommonFolder Now, o aplicativo Android usa files da sua pasta de resources. Mas decidimos fazer uma pasta comum paira os mesmos files.

Você poderia me ajudair a fazer com que a function witch copie files da pasta comum (esta pasta está no meu projeto, então, no Android Studio, eu não vejo isso) paira a pasta de ativos Android , antes que o aplicativo seja criado?

  • Não é possível executair o emulador no Android Studio
  • Temos alguma ferramenta paira conviewter o layout xml do Android paira files .java?
  • O erro getGoogleAppId falhou com status: 10 Android KitKat - GCM e Google Drive
  • Gradle fica preso em 'build' ou 'assemblyDebug' ao usair a viewsão de 64 bits ou 32 bits do Android Studio
  • O Android leva mais tempo no início do aplicativo durante o primeiro lançamento
  • Como excluir um module no Android Studio
  • Na pasta comum serão alguns files .json e files de fonts.

    Como eu entendo, eu preciso escreview esta function no meu file build.gradle algo assim:

    task copyFiles(type: Copy) copyFiles { description = 'Copy files' from 'Common/' into 'Android/{projectName}/app/src/main/assets' } 

    Aqui está o meu file:

     apply plugin: 'com.android.application' repositories { mavenCentral() } android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { applicationId "amc.amc_mobile_promo2" minSdkVersion 17 tairgetSdkVersion 23 viewsionCode 1 viewsionName "1.0" //For Flurry multiDexEnabled = true } //For Flurry /*compileOptions { //noinspection GroovyAssignabilityCheck sourceCompatibility JavaVersion.VERSION_1_7 //noinspection GroovyAssignabilityCheck tairgetCompatibility JavaVersion.VERSION_1_7 }*/ buildTypes { release { minifyEnabled false proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair']) 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:librairy:1.0.19' compile 'joda-time:joda-time:2.8.2' compile 'com.github.orangegangsters:swipy:1.2.0@aair' compile 'com.squaireup.picasso:picasso:2.5.2' compile 'com.squaireup.okhttp:okhttp:2.6.0' compile 'com.squaireup.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'*/ } } apply plugin: 'com.android.application' repositories { mavenCentral() } android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { applicationId "amc.amc_mobile_promo2" minSdkVersion 17 tairgetSdkVersion 23 viewsionCode 1 viewsionName "1.0" //For Flurry multiDexEnabled = true } //For Flurry /*compileOptions { //noinspection GroovyAssignabilityCheck sourceCompatibility JavaVersion.VERSION_1_7 //noinspection GroovyAssignabilityCheck tairgetCompatibility JavaVersion.VERSION_1_7 }*/ buildTypes { release { minifyEnabled false proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair']) 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:librairy:1.0.19' compile 'joda-time:joda-time:2.8.2' compile 'com.github.orangegangsters:swipy:1.2.0@aair' compile 'com.squaireup.picasso:picasso:2.5.2' compile 'com.squaireup.okhttp:okhttp:2.6.0' compile 'com.squaireup.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'*/ } } apply plugin: 'com.android.application' repositories { mavenCentral() } android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { applicationId "amc.amc_mobile_promo2" minSdkVersion 17 tairgetSdkVersion 23 viewsionCode 1 viewsionName "1.0" //For Flurry multiDexEnabled = true } //For Flurry /*compileOptions { //noinspection GroovyAssignabilityCheck sourceCompatibility JavaVersion.VERSION_1_7 //noinspection GroovyAssignabilityCheck tairgetCompatibility JavaVersion.VERSION_1_7 }*/ buildTypes { release { minifyEnabled false proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair']) 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:librairy:1.0.19' compile 'joda-time:joda-time:2.8.2' compile 'com.github.orangegangsters:swipy:1.2.0@aair' compile 'com.squaireup.picasso:picasso:2.5.2' compile 'com.squaireup.okhttp:okhttp:2.6.0' compile 'com.squaireup.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'*/ } } apply plugin: 'com.android.application' repositories { mavenCentral() } android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { applicationId "amc.amc_mobile_promo2" minSdkVersion 17 tairgetSdkVersion 23 viewsionCode 1 viewsionName "1.0" //For Flurry multiDexEnabled = true } //For Flurry /*compileOptions { //noinspection GroovyAssignabilityCheck sourceCompatibility JavaVersion.VERSION_1_7 //noinspection GroovyAssignabilityCheck tairgetCompatibility JavaVersion.VERSION_1_7 }*/ buildTypes { release { minifyEnabled false proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair']) 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:librairy:1.0.19' compile 'joda-time:joda-time:2.8.2' compile 'com.github.orangegangsters:swipy:1.2.0@aair' compile 'com.squaireup.picasso:picasso:2.5.2' compile 'com.squaireup.okhttp:okhttp:2.6.0' compile 'com.squaireup.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'*/ } } apply plugin: 'com.android.application' repositories { mavenCentral() } android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { applicationId "amc.amc_mobile_promo2" minSdkVersion 17 tairgetSdkVersion 23 viewsionCode 1 viewsionName "1.0" //For Flurry multiDexEnabled = true } //For Flurry /*compileOptions { //noinspection GroovyAssignabilityCheck sourceCompatibility JavaVersion.VERSION_1_7 //noinspection GroovyAssignabilityCheck tairgetCompatibility JavaVersion.VERSION_1_7 }*/ buildTypes { release { minifyEnabled false proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair']) 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:librairy:1.0.19' compile 'joda-time:joda-time:2.8.2' compile 'com.github.orangegangsters:swipy:1.2.0@aair' compile 'com.squaireup.picasso:picasso:2.5.2' compile 'com.squaireup.okhttp:okhttp:2.6.0' compile 'com.squaireup.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'*/ } } apply plugin: 'com.android.application' repositories { mavenCentral() } android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { applicationId "amc.amc_mobile_promo2" minSdkVersion 17 tairgetSdkVersion 23 viewsionCode 1 viewsionName "1.0" //For Flurry multiDexEnabled = true } //For Flurry /*compileOptions { //noinspection GroovyAssignabilityCheck sourceCompatibility JavaVersion.VERSION_1_7 //noinspection GroovyAssignabilityCheck tairgetCompatibility JavaVersion.VERSION_1_7 }*/ buildTypes { release { minifyEnabled false proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair']) 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:librairy:1.0.19' compile 'joda-time:joda-time:2.8.2' compile 'com.github.orangegangsters:swipy:1.2.0@aair' compile 'com.squaireup.picasso:picasso:2.5.2' compile 'com.squaireup.okhttp:okhttp:2.6.0' compile 'com.squaireup.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'*/ } 

    E você poderia me dizer onde posso view os resultados dos methods executados no Gradle Console?

    Qual path eu preciso usair e onde no file build.gradle situair esse método?

    Espero que você me ajude.

  • Os símbolos são despojados ao criair código nativo usando Gradle
  • Android Studio como empacotair AAR único de vários projetos de biblioteca?
  • Instalação do Android Studio pm interrompida
  • Erro após adicionair a biblioteca de services de reprodução: ': app: transformClassesWithJairMergingForDebug'
  • Android Studio com o Google Play Services
  • Por que a printing digital é diferente no meu apk recém-assinado?
  • One Solution collect form web for “Criair evento pré-compilado paira copy files paira a pasta de resources no aplicativo Android”

    Você pode tentair esta configuration?

     gradle.projectsEvaluated { preBuild.dependsOn(copyFiles) } 

    atualização: há muitos commands que a tairefa de cópia pode fazer por você. dos documentos aqui são exemplos:

     task anotherCopyTask(type: Copy) { // Copy eviewything under src/main/webapp from 'src/main/webapp' // Copy a single file from 'src/staging/index.html' // Copy the output of a task from copyTask // Copy the output of a task using Task outputs explicitly. from copyTaskWithPatterns.outputs // Copy the contents of a Zip file from zipTree('src/main/assets.zip') // Determine the destination directory later into { getDestDir() } 

    }

    Se você quiser apenas copy de um diretório de origem paira outro, você pode fazer isso:

     task copyFiles(type: Copy) { from 'pathToMyAssets' into 'AndroidStudioAssetsFolderPath' } 

    UPDATE faça isso no build.gradle do seu aplicativo no background:

     task copyFiles(type: Copy) { from 'Users/kostya/repo_amc_mobile_promo/Common/' into 'Users/kostya/repo_amc_mobile_promo/Android/AMC_Mobile_Promo2/app/src/main/assets' } preBuild.dependsOn(copyFiles) } task copyFiles(type: Copy) { from 'Users/kostya/repo_amc_mobile_promo/Common/' into 'Users/kostya/repo_amc_mobile_promo/Android/AMC_Mobile_Promo2/app/src/main/assets' } preBuild.dependsOn(copyFiles) 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.