中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

網(wǎng)做網(wǎng)站google關鍵詞查詢工具

網(wǎng)做網(wǎng)站,google關鍵詞查詢工具,遵義網(wǎng)站制作一般多少錢,梅州建站公司原理使用Android Studio打一次渠道包,用反編譯工具反編譯后,修改渠道信息重新編譯 準備文件 分渠道配置文件:channel.txt ↓ # 多渠道配置里“統(tǒng)計平臺”、“市場名稱”、“渠道編號”分別代表什么意思? # 統(tǒng)計平臺:…

?原理使用Android Studio打一次渠道包,用反編譯工具反編譯后,修改渠道信息重新編譯

準備文件

分渠道配置文件:channel.txt ↓

# 多渠道配置里“統(tǒng)計平臺”、“市場名稱”、“渠道編號”分別代表什么意思?
# 統(tǒng)計平臺:即android name,應用中集成的數(shù)據(jù)分析sdk的公司名稱,例:umeng_channel(下拉列表里提供了若干選項);
# 市場名稱:各大安卓應用分發(fā)市場(下拉列表里提供了Top20的市場供選擇),以幫助開發(fā)者區(qū)分不同渠道包特征上傳相對應市場;
# 渠道編號:即android value,一般填寫相關channel id。用戶可自行定義區(qū)分各大市場的關鍵字,盡量避免使用特殊字符。
BaiduMobAd_CHANNEL yingyonghui yingyonghui
BaiduMobAd_CHANNEL oppo oppo
BaiduMobAd_CHANNEL 360 360
BaiduMobAd_CHANNEL baidu baidu
BaiduMobAd_CHANNEL xiaomi xiaomi
BaiduMobAd_CHANNEL huawei huawei
BaiduMobAd_CHANNEL lianxiang lianxiang
BaiduMobAd_CHANNEL yingyongbao yingyongbao
BaiduMobAd_CHANNEL aliyun aliyun
BaiduMobAd_CHANNEL sanxing sanxing
BaiduMobAd_CHANNEL vivo vivo
BaiduMobAd_CHANNEL honor honor

(反編譯+對齊+簽名)文件:↓

//?可以在Android SDK目錄里面找到D:\Android\sdk\build-tools\30.0.3\lib

apksigner.jar

// Mac就找【zipalign】,windows就找【zipalign.exe】

zipalign

zipalign.exe

// 官網(wǎng):下載Apktool官網(wǎng)

apktool_2.9.3.jar

app build.gradle文件中這樣配置

?下面需要自己自行調(diào)整

要打多渠道包時點擊運行那個綠色的小三角

核心文件:release.gradle

import java.nio.file.Files
import java.util.regex.Matcher
import java.util.regex.Pattern
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStreamext {SIGN_JAR = rootDir.getPath() + "/tools/apksigner.jar"ZIPALIGN = rootDir.getPath() + "/tools/zipalign"APKTOOL_JAR = rootDir.getPath() + "/tools/apktool_2.9.3.jar"storeFile = rootDir.getPath() + "/app.keystore" //密鑰路徑storePassword = "dmx1234567890" //密鑰密碼keyAlias = "Alias" //密鑰別名keyPassword = "dmx1234567890"//別名密碼// 反編譯目錄unApkPath = buildDir.getPath() + '/outputs/release/unapk'// 渠道Apk輸出路徑channel_apks_path = buildDir.getPath() + '/outputs/release/channels/'// 保存渠道配置CHANNEL_CONFIG = rootDir.getPath() + "/channel.txt"
}
/*** Apk渠道類*/
class ApkChannel {/*** 統(tǒng)計平臺,即 android name*/String name;/*** 市場名稱,即應用分渠道包時,會加上這個名稱 列:app_1.0.0_5_{market}_sign.apk*/String market;/*** 統(tǒng)計渠道,即 android value*/String value;public ApkChannel(String name, String market, String value) {this.name = name;this.market = market;this.value = value;}}static def isWindows() {return org.gradle.internal.os.OperatingSystem.current().isWindows()
}static def isMacOsX() {return org.gradle.internal.os.OperatingSystem.current().isMacOsX()
}
// 這個在MacOS上有時候會刪除不到,會導致編譯出來的包存在.DS_Store文件,懂的可以自己研究處理一下
def deleteDS_Store() {if (isMacOsX()) {exec {commandLine "/bin/sh", "-c", "find ${unApkPath} -name '.DS_Store' -depth -exec rm {} +"}}
}static def String readXml(File xmlFile) {String result = nulltry (InputStream stream = new FileInputStream(xmlFile)) {// 創(chuàng)建byte數(shù)組byte[] buffer = new byte[stream.available()]// 將文件中的數(shù)據(jù)讀到byte數(shù)組中stream.read(buffer)result = new String(buffer, "UTF-8")} catch (Exception e) {throw new Exception(e)}return result
}static def boolean writeXml(File xmlFile, String xmlString) {boolean isWriteXml = false// 寫入文件try (BufferedWriter writer = new BufferedWriter(new FileWriter(xmlFile))) {writer.write(xmlString);isWriteXml = true} catch (IOException e) {throw new Exception(e)}return isWriteXml
}/*** 根據(jù)統(tǒng)計平臺名稱匹配,是否存在該統(tǒng)計平臺的 meta-data* @param xmlString* @param channelName* @return*/
private static boolean isExistsMetaData(String xmlString, String channelName) {String metaDataReg = "\\<meta-data android:name=\\\"" + channelName + "\\\" android:value=\".*?\"/\\>"Pattern pattern = Pattern.compile(metaDataReg)return pattern.matcher(xmlString).find()
}
/*** 替換指定的統(tǒng)計平臺的 meta data* @param xmlString* @param channelName* @param metaData*/
private static String replaceMetaData(String xmlString, String channelName, String metaData) {String metaDataReg = "\\<meta-data android:name=\\\"" + channelName + "\\\" android:value=\".*?\"/\\>"Pattern pattern = Pattern.compile(metaDataReg)Matcher matcher = pattern.matcher(xmlString)if (matcher.find()) {return xmlString.replace(matcher.group(), metaData)}return xmlString
}
/*** 生成 meta data* @param channelName* @param channelValue* @return*/
private static String generateMetaData(String channelName, String channelValue) {return String.format("<meta-data android:name=\"%s\" android:value=\"%s\"/>", channelName, channelValue)
}def List<ApkChannel> initChannels() {List<ApkChannel> channels = new ArrayList<ApkChannel>()println("并初始化channel.txt文件...")File channelFile = new File(CHANNEL_CONFIG)if (!channelFile.exists()) {throw new FileNotFoundException(channelFile.getPath() + "文件不存在!")}try (BufferedReader reader = new BufferedReader(new FileReader(channelFile))) {String linewhile ((line = reader.readLine()) != null) {// 處理每一行數(shù)據(jù)if (line.startsWith("#")) {println(line.replace("# ", ""))} else {String[] arr = line.split(" ")channels.add(new ApkChannel(arr[0], arr[1], arr[2]))}}println("初始化成功,渠道數(shù):" + channels.size())} catch (Exception e) {e.printStackTrace()}return channels
}/*** 反編譯Apk* @param inApkFile 要反編譯的Apk文件* @return 返回反編譯后的文件目錄*/
def File decompileApk(File inApkFile) {println "*************** apktool decompile start ***************"File outDecompileFile = new File(unApkPath, inApkFile.name.replace(".apk", ""))if (outDecompileFile.exists()) {if (!delete(outDecompileFile)) {throw new RuntimeException("delete apktoolOutputDir failure!")}}if (!outDecompileFile.mkdirs()) {throw new RuntimeException("make apktoolOutputDir failure!")}println("apktool decompile out file: " + outDecompileFile)// 解壓APK命令String unApkCommand = String.format("java -jar %s d -o %s %s -f -s",APKTOOL_JAR,outDecompileFile.getPath(),inApkFile.getPath())exec {if (isWindows()) {commandLine "powershell", unApkCommand} else if (isMacOsX()) {commandLine "/bin/sh", "-c", unApkCommand} else {throw new RuntimeException("Please confirm your platform command line!")}}deleteDS_Store()println "*************** apktool decompile finish ***************"return outDecompileFile
}
/*** 編譯Apk* @param inDecompileApkFileDir 輸入反編譯后的文件目錄* @param outCompileApkFileDir 輸出編譯Apk文件存儲目錄* @param outFileName 編譯后的Apk文件名* @return*/
def File compileApk(File inDecompileApkFileDir, File outCompileApkFileDir, String outFileName) {println "*************** apktool compile start ***************"if (!inDecompileApkFileDir.exists()) {throw new FileNotFoundException("no " + inDecompileApkFileDir.getPath() + " has found!")}if (!outCompileApkFileDir.exists()) {outCompileApkFileDir.mkdirs()}File outCompileApkFile = new File(outCompileApkFileDir, outFileName)String buildApkCommand = String.format("java -jar %s b %s -o %s",APKTOOL_JAR,inDecompileApkFileDir.getPath(),outCompileApkFile.getPath())exec {if (isWindows()) {commandLine "powershell", buildApkCommand} else if (isMacOsX()) {commandLine "/bin/sh", "-c", buildApkCommand} else {throw new RuntimeException("Please confirm your platform command line!")}}println "*************** apktool compile finish ***************"return outCompileApkFile
}/*** 對齊Apk* @param inApkFile 要對齊的Apk文件* @return 返回對齊后的Apk文件*/
def File zipalignApk(File inApkFile) {println "*************** zipalign optimize start ***************"String zipalignApkFilename = inApkFile.name.replace(".apk", "_unsigned.apk")File outZipalignApkFile = new File(inApkFile.getParent(), zipalignApkFilename)exec {if (isWindows()) {// zipalign.exe -p -f -v 4 infile.apk outfile.apkString alignApkCommand = String.format("%s.exe -p -f -v 4 %s %s",ZIPALIGN,inApkFile.getPath(),outZipalignApkFile.getPath())commandLine "powershell", alignApkCommand} else if (isMacOsX()) {// zipalign -p -f -v 4 infile.apk outfile.apkString alignApkCommand = String.format("%s -p -f -v 4 %s %s",ZIPALIGN,inApkFile.getPath(),outZipalignApkFile.getPath())commandLine "/bin/sh", "-c", alignApkCommand} else {throw new RuntimeException("Please confirm your platform command line!")}}println "*************** zipalign optimize finish ***************"return outZipalignApkFile
}
/*** 簽名Apk* @param inApkFile 要簽名的Apk文件* @return 返回簽名后的Apk文件*/
def File signerApk(File inApkFile) {println "*************** start apksigner ***************"File outSignerApkFile = new File(inApkFile.getPath().replace("_unsigned.apk", "_signed.apk"))String apksignerCommand = String.format("java -jar %s sign -verbose --ks %s --v1-signing-enabled true --v2-signing-enabled true --v3-signing-enabled false --ks-key-alias %s --ks-pass pass:%s --key-pass pass:%s --out %s %s",SIGN_JAR,storeFile,keyAlias,storePassword,keyPassword,outSignerApkFile.getPath(),inApkFile.getPath())exec {if (isWindows()) {commandLine "powershell", apksignerCommand} else if (isMacOsX()) {commandLine "/bin/sh", "-c", apksignerCommand} else {throw new RuntimeException("Please confirm your platform command line!")}}println "*************** finish apksigner ***************"return outSignerApkFile
}private def processingChannel(File decompileApkFile, String channelMarket) {// 刪除惡心的.DS_StoredeleteDS_Store()// 編譯File compileApkFile = compileApk(decompileApkFile, new File(channel_apks_path), decompileApkFile.name + "_" + channelMarket + ".apk")// 對齊File zipalignApkFile = zipalignApk(compileApkFile)if (zipalignApkFile.exists()) {delete(compileApkFile)}// 簽名File signerApkFile = signerApk(zipalignApkFile)if (signerApkFile.exists()) {delete(zipalignApkFile)}
}task assemblePackageChannel() {dependsOn('assembleAdRelease')doLast {if (isMacOsX()) {exec { commandLine "/bin/sh", "-c", "chmod +x " + SIGN_JAR }exec { commandLine "/bin/sh", "-c", "chmod +x " + ZIPALIGN }exec { commandLine "/bin/sh", "-c", "chmod +x " + APKTOOL_JAR }}List<ApkChannel> channels = initChannels()if (channels.size() <= 0) {throw new Exception("沒有渠道信息!")}FilenameFilter filter = new FilenameFilter() {@Overrideboolean accept(File dir, String name) {return name.endsWith(".apk")}}// 獲得release包地址,暫時固定死String sourceApkDir = buildDir.getPath() + "/outputs/apk/ad/release"File inSourceApkFile = new File(sourceApkDir).listFiles(filter).first()if (inSourceApkFile == null || !inSourceApkFile.exists()) {throw new FileNotFoundException("no apk files has found!")}File decompileApkFile = decompileApk(inSourceApkFile)// 檢測AndroidManifest.xml是否存在File xmlFile = new File(decompileApkFile, "AndroidManifest.xml")if (!inSourceApkFile.exists()) {throw new FileNotFoundException("no AndroidManifest.xml files has found!")}String xmlString = readXml(xmlFile)if (xmlString == null || xmlString.length() <= 0) {throw new NullPointerException("read AndroidManifest.xml is null.")}// 多渠道處理for (ApkChannel channel : channels) {// 檢測是否存在多個平臺if (channel.name.split("\\|").length > 1) {String[] channelNames = channel.name.split("\\|")String[] channelValues = channel.value.split("\\|")for (int i = 0; i < channelNames.length; i++) {String channelName = channelNames[i]String channelValue = channelValues[i]if (isExistsMetaData(xmlString, channelName)) {// 替換渠道信息xmlString = replaceMetaData(xmlString, channelName, generateMetaData(channelName, channelValue))// 寫入渠道信息writeXml(xmlFile, xmlString)processingChannel(decompileApkFile, channel.market)}}} else {if (isExistsMetaData(xmlString, channel.name)) {// 替換渠道信息xmlString = replaceMetaData(xmlString, channel.name, generateMetaData(channel.name, channel.value))// 寫入渠道信息writeXml(xmlFile, xmlString)processingChannel(decompileApkFile, channel.market)}}}}
}

http://www.risenshineclean.com/news/4619.html

相關文章:

  • 幫公司做網(wǎng)站商丘網(wǎng)站seo
  • 公司網(wǎng)站開發(fā)招標書天津優(yōu)化公司哪家好
  • 空間商網(wǎng)站站長之家域名查詢官網(wǎng)
  • 做海外網(wǎng)站推廣直播營銷
  • 自己個人的網(wǎng)站怎么設計營銷策劃的六個步驟
  • 網(wǎng)站使用幫助內(nèi)容銷售策略和營銷策略
  • 網(wǎng)站公司建設網(wǎng)絡營銷方法
  • 可以做產(chǎn)品推廣的網(wǎng)站寧波seo關鍵詞
  • 網(wǎng)站怎么做預約小程序電商網(wǎng)站seo
  • 個人博客網(wǎng)站建設選題說明seo關鍵詞優(yōu)化案例
  • 荊州建設局網(wǎng)站軟件外包公司是什么意思
  • 什么網(wǎng)站可以找到防水工程做網(wǎng)絡推廣的主要工作內(nèi)容
  • 維護一個網(wǎng)站需要多少錢怎么制作網(wǎng)頁廣告
  • 網(wǎng)站空間和數(shù)據(jù)庫空間seo基礎入門視頻教程
  • 做黃金理財?shù)木W(wǎng)站短視頻seo排名
  • 求個網(wǎng)站好人有好報百度貼吧怎么做百度網(wǎng)頁推廣
  • bae做網(wǎng)站市場推廣怎么做
  • redis做緩存的網(wǎng)站并發(fā)數(shù)深圳網(wǎng)絡營銷全網(wǎng)推廣
  • dw做了網(wǎng)站還可以做淘寶詳情嗎西安seo站內(nèi)優(yōu)化
  • 企業(yè)建立網(wǎng)站需要百度廣告投放公司
  • 幫你做海報網(wǎng)站寧波網(wǎng)絡建站模板
  • 網(wǎng)站建設是設計師嗎軟件推廣方案經(jīng)典范文
  • 專門做汽車配件的外貿(mào)網(wǎng)站網(wǎng)站目錄
  • 做網(wǎng)站怎么買服務器嗎關鍵詞推廣價格
  • 南京本地網(wǎng)站百度seo自然優(yōu)化
  • 網(wǎng)站建設方案書內(nèi)容管理制度優(yōu)化seo教程技術
  • css修改Wordpressseo是搜索引擎嗎
  • 在ps中做網(wǎng)站首頁的尺寸品牌營銷策劃方案
  • 17做網(wǎng)店網(wǎng)站池尾百度付費問答平臺
  • wordpress轉(zhuǎn)移服務器免費seo優(yōu)化工具