美文网首页
android gradle 3.0 androidManife

android gradle 3.0 androidManife

作者: proud2008 | 来源:发表于2018-04-26 10:42 被阅读37次
       android {
           ...
           sourceSets {
               main {
                   manifest.srcFile {
                       /* 多个AndroidManifest拼接,
                       修改AndroidManifest运行时及时更新,
                       clean后不会自动创建,需手动sync,可能是因为分两步的问题*/
                       def _manifests = ['src/comm/AndroidManifest.xml', 'src/pay/AndroidManifest.xml']
                       def main = file('src/main/AndroidManifest.xml')
                       def targetFile = new File(getBuildDir(), "AndroidManifest.xml")
                       if (!targetFile.getParentFile().exists()) {
                           targetFile.getParentFile().mkdirs();
                       }
                       def main_text = main.getText("utf-8")
                       def appIndex = main_text.lastIndexOf("</application>")
                       def targetContent = main_text.substring(0, appIndex)
                       for (item in _manifests) {
                           def c = file(item).getText("utf-8");
                           def appTag = "<application>"
                           def ct = c.substring(c.indexOf(appTag) + appTag.length(), c.lastIndexOf("</application>"))
                           targetContent += ct;
                       }
                       targetContent += main_text.substring(appIndex)
                       targetFile.write(targetContent, "utf-8")
                       return targetFile.getAbsolutePath()
                   }
                   jniLibs.srcDirs = ["libs", 'src/comm/libs', 'src/libs',
                                      'src/main/jniLibs', 'src/main/libs',
                                      'src/view/libs', 'src/pay/libs',
                   ]
                   res.srcDirs = ['src/main/res', 'src/comm/res', "src/view/res", "src/pay/res"]
                   java.srcDirs = ['src/main/java', 'src/comm/java', 'src/view/java', "src/pay/java"]
               }
           }
           ...
       }
    

    相关文章

      网友评论

          本文标题:android gradle 3.0 androidManife

          本文链接:https://www.haomeiwen.com/subject/abdplftx.html