How to run copy task with android studio into assets folder

后端 未结 7 993
温柔的废话
温柔的废话 2020-12-01 11:53

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 c         


        
7条回答
  •  感情败类
    2020-12-01 12:31

    I had a very similar problem to yours and I was able to solve it as follows:

    android.buildTypes.all{ buildType ->    
        task "${buildType.name}CopyFiles" (type: Copy)
        "${buildType.name}CopyFiles" {
            description = 'Copies html5 files from the common library...'
            from '../../www'
            into 'assets/www'
            include('**/*')
        }
    
        tasks.getByPath(":${project.name}:assemble${buildType.name.capitalize()}").dependsOn "${buildType.name}CopyFiles"
    }
    

    The problem is, that Android Studio seems to call a specific assemble task like assembleDebug when you click on run, that's why you have to make sure to make all assemble tasks depend on your copy task.

提交回复
热议问题