• allatori8.0文档翻译-第十三步:Android Studio整合


    第十三步:Android Studio整合

    相关文件位于“tutorial/step12-maven/files/mouse-gestures ”目录下:

    文件名说明
    build.gradle构建文件样例
    allatori.xml典型的配置文件

    按照下面的步骤在Android Studio中进行配置:

    1. rootDir目录中创建“allatori”目录,拷贝allatori.jar 到目录中
    2. 拷贝配置文件“allatori.xml”到projectDir(项目的build.gradle的目录)
    3. 编辑build.gradle:
    android {
        ...
        // for applications
        applicationVariants.all { variant ->
            variant.javaCompileProvider.get().doLast {
                runAllatori(variant)
            }
        }
        // for libraries
        // libraryVariants.all { variant ->
        //    variant.javaCompileProvider.get().doLast {
        //        runAllatori(variant)
        //     }
        // }
    }
    
    def runAllatori(variant) {
        copy {
            from "$projectDir/allatori.xml"
            into "$buildDir/intermediates/classes/"
            expand(classesRoot: variant.javaCompileProvider.get().destinationDir,
                    kotlinRoot: "${buildDir}/tmp/kotlin-classes/${variant.name}",
                    androidJar: "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar",
                    classpathJars: variant.javaCompileProvider.get().classpath.getAsPath(),
                    logFile: "allatori-log-${variant.name}.xml")
            rename('allatori.xml', "allatori-${variant.name}.xml")
        }
    
        new File("${variant.javaCompileProvider.get().destinationDir}-obfuscated").deleteDir()
        javaexec {
            main = 'com.allatori.Obfuscate'
            classpath = files("$rootDir/allatori/allatori.jar")
            args "$buildDir/intermediates/classes/allatori-${variant.name}.xml"
        }
        new File("${variant.javaCompileProvider.get().destinationDir}").deleteDir()
        new File("${variant.javaCompileProvider.get().destinationDir}-obfuscated").renameTo(new File("${variant.javaCompileProvider.get().destinationDir}"))
    
        // Kotlin support
        // new File("${buildDir}/tmp/kotlin-classes/${variant.name}").deleteDir()
        // new File("${buildDir}/tmp/kotlin-classes/${variant.name}-obfuscated").renameTo(new File("${buildDir}/tmp/kotlin-classes/${variant.name}"))
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
  • 相关阅读:
    java之面向对象编程特性:继承
    Android混淆笔记
    报错缺少class(org.apache.hadoop.hdfs.DistributedFileSystem)
    docker 部署 MongoDB
    lsof的基本应用及恢复误删的文件
    通过UDP实现参数配置
    Go基础语法:map
    【开发必备】单点登录,清除了cookie,页面还保持登录状态?
    Linux学习命令之source
    【LeetCode】102. 二叉树的层序遍历
  • 原文地址:https://blog.csdn.net/jianxuan/article/details/125457667