AndroidStudio:在gradle中添加虚拟文件夹

我使用build.gradle文件在我的应用程序的资源文件夹中收集计算机上的多个文件夹:

sourceSets { main { assets.srcDirs = ['../someFolder/', 'src/main/assets'] } } 

这导致我的资产文件夹具有someFolder文件和“原始”资产文件夹:

 //The "physical" folders ../someFolder |- file1.txt |- file2.txt |- file3.txt src/main/assets |- asset1.txt //...become this: assets |- file1.txt |- file2.txt |- file3.txt |- asset1.txt 

如何redirectgradle中的path,以便我的资产文件夹包含来自someFolder所有文件的“someFolder”文件someFolder ,例如:

 assets |- someFolder |--- file1.txt |--- file2.txt |--- file3.txt |- asset1.txt 

Solutions Collecting From Web of "AndroidStudio:在gradle中添加虚拟文件夹"

1)在项目内部创build文件夹作为您的外部资产./extAssets

 sourceSets.main.assets.srcDirs = ['src/main/assets', './extAssets'] 

2)链接此文件夹内的所有外部目录

 $ cd extAssets/ $ ln -s ../../someFolder/ someFolder 

结果你会看到

 assets |- someFolder |--- file1.txt |--- file2.txt |--- file3.txt |- asset1.txt 

没有任何文件复制