2

This reddit thread has a solution to one of my problems and this comment

...a better option is to create a task which copies the file into "$project.buildDir/readme/res/raw/", register that folder with the Android plugin as a generated resource root, and register the task with the Android plugin as resource-generating task.

seems to be suggesting a better way but I am not sure what is meant by 'register as a resource-generating task'.

Community
  • 1
  • 1
Krishnaraj
  • 2,360
  • 1
  • 32
  • 55
  • What are you trying to accomplish and what have you tried? – JBirdVegas Jan 07 '16 at 17:14
  • The solution in the thread is to copy the file to the 'src' directory which does work but the comment says it's better to copy directly to the build folder by registering as a resource generating task. This is what I am clueless about. – Krishnaraj Jan 07 '16 at 18:21
  • What I am trying to achieve is stated in another stackoverflow question. Didn't want to duplicate it here... – Krishnaraj Jan 07 '16 at 18:23
  • Still not sure what your trying to accomplish. Do you want to include a `README.txt` file in your apk/aar? If so what is the goal? Just have the file exist inside the archive or do you need to reference it via java? Please explicitly state what your trying to accomplish – JBirdVegas Jan 07 '16 at 19:44
  • I am trying to include a file from the root directory of my project into the apk file. Complete details here - http://stackoverflow.com/questions/34595582/android-gradle-how-to-include-assets-from-the-root-project – Krishnaraj Jan 08 '16 at 14:28

2 Answers2

1

They're probably referring to variant.registerResGeneratingTask. This doesn't appear to be publicly documented so it may be subject to change, but it is used by various third-party plugins such as this one.

mhsmith
  • 6,675
  • 3
  • 41
  • 58
0

Ok, think it means registering to mergeResources task like below

variant.mergeResources.doLast {
    copy {
       from ("path/to/some/file")
       into ("$outputDir/raw")
    }
}
Krishnaraj
  • 2,360
  • 1
  • 32
  • 55