相关疑难解决方法(0)

Android + Gradle:将目录列入文件

我正在尝试将ANT构建中的任务转换为Gradle:

<target name="index-assets" depends="copy-assets">
    <path id="assets.path">
        <!-- contexts (and surplus) -->
        <dirset id="assets.dirset" dir="assets/" defaultexcludes="yes"/>
        <!-- assets -->
        <fileset id="assets.fileset" dir="assets/" includes="**" excludes="asset.index" defaultexcludes="yes"/>
    </path>

    <pathconvert pathsep="${line.separator}" property="assets" refid="assets.path" dirsep="/">
        <mapper>
            <globmapper from="${basedir}/assets/*" to="*" handledirsep="yes"/>
        </mapper>
    </pathconvert>

    <echo file="assets/asset.index">${assets}</echo>

</target>

<target name="-pre-build" depends="index-assets"/>
Run Code Online (Sandbox Code Playgroud)

我想我还没有完全掌握基本的Gradle概念,但这是我尝试过的:

task indexAssets << {

def assets = file("assets")
def contexts = files(assets)
inputs.file(assets)
outputs.file("assets/assets-gradle.index")

def tree = fileTree(dir: 'assets', include: ['**/*'], exclude: ['**/.svn/**', 'asset.index'])

contexts.collect { relativePath(it) }.sort().each { println it }
tree.collect { relativePath(it) }.sort().each …
Run Code Online (Sandbox Code Playgroud)

android gradle

5
推荐指数
1
解决办法
2766
查看次数

Android:如何检测资产文件夹中的目录?

我正在检索这样的文件

String[] files = assetFiles.list("EngagiaDroid"); 
Run Code Online (Sandbox Code Playgroud)

我们如何知道它是文件还是目录?

我想遍历Assets文件夹中的目录,然后复制其所有内容。

java android file exists

4
推荐指数
2
解决办法
6963
查看次数

标签 统计

android ×2

exists ×1

file ×1

gradle ×1

java ×1