在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):castorflex/manifestreplace-plugin开源软件地址(OpenSource Url):https://github.com/castorflex/manifestreplace-plugin开源编程语言(OpenSource Language):Groovy 100.0%开源软件介绍(OpenSource Introduction):NoteThe current version works with the gradle plugin 0.13.3 Why is this useful? The android-plugin already uses manifestPlaceholders!The android-plugin uses manifestPlaceholders to replace placeholders in your manifest, but only in some places. You cannot put a placeholder to add a full activity for example. This plugin replace all instances of your placeholder by your values in your manifest. UsageAdd the plugin to your classpath, and apply it! That's all dependencies {
classpath 'com.github.castorflex.manifestreplace:plugin:1.1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'manifestreplace'
// That's all you need, the following is an example
android {
//use the placeholders just like you were doing before
defaultConfig {
manifestPlaceholders = [
myPlaceholderIntentFilter_sessionlist: getManifestIntentFilter("sessionlist", false),
myPlaceholderIntentFilter_sessiondetails: getManifestIntentFilter("sessiondetails", false),
myPlaceholderLabel: "label"
]
}
buildTypes {
debug {
manifestPlaceholders = [
myPlaceholderIntentFilter_sessionlist: getManifestIntentFilter("sessionlist", true),
myPlaceholderIntentFilter_sessiondetails: getManifestIntentFilter("sessiondetails", true)
]
}
}
productFlavors {
free{
manifestPlaceholders = [
myPlaceholderLabel: "labelFree"
]
}
pro {
manifestPlaceholders = [
myPlaceholderLabel: "labelPro"
]
}
}
}
def getManifestIntentFilter(String action, boolean debug) {
String host = (debug ? "debug." : "") + "myapplication.com"
return " <intent-filter>\n" +
" <action android:name=\"android.intent.action.VIEW\"/>\n" +
"\n" +
" <category android:name=\"android.intent.category.DEFAULT\"/>\n" +
" <category android:name=\"android.intent.category.BROWSABLE\"/>\n" +
"\n" +
" <data\n" +
" android:host=\"$host\"\n" +
" android:pathPattern=\"/androiduri/${action}.*\"\n" +
" android:scheme=\"https\"/>\n" +
" </intent-filter>\n"
}
Then, add some placeholders to your manifest: <?xml version="1.0" encoding="utf-8"?>
<manifest ... >
<application ... >
<activity
android:name="testapplication.castorflex.com.myapplication.MainActivity"
android:label="${myPlaceholderLabel}" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
${myPlaceholderIntentFilter_sessiondetails}
${myPlaceholderIntentFilter_sessionlist}
</activity>
</application>
</manifest>
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论