標籤:
目的是QA可以自己登陸Jenkins選擇要構建的版本,結果以郵件的方式通知(包括構建資訊,靜態程式碼分析結果,APK下載連結,二維碼等),然後存檔。
- 構建使用Gralde。
- 打包,產生二維碼,存檔是Python指令碼實現。
打多渠道包
打多渠道包有很多方法,我用的是,產生一個簽名後的APK,然後在APK包種META-INF目錄下添加一個空檔案,檔案名稱包含渠道資訊,Android中讀這個檔案來擷取資訊,通過代碼的方式設定給友盟。這樣可以避免反覆編譯,簽名。
修改指令碼 Python:
def generate( channel_name ): shutil.copy(apk_file, target_apk) zipped = zipfile.ZipFile(target_apk, 'a', zipfile.ZIP_DEFLATED) content_file = "META-INF/Channel_"+channel_name+".txt" zipped.write(empty_content, content_file) zipped.close() return target_apk
怎樣取渠道資訊然後迴圈修改就看個人情況了
Android中讀取
private static String getContent(Context context, String channelKey){ String sourceDir = context.getApplicationInfo().sourceDir; String key = "META-INF/" + channelKey; String ret = ""; ZipFile zipfile = null; try { zipfile = new ZipFile(sourceDir); Enumeration<?> entries = zipfile.entries(); while (entries.hasMoreElements()) { ZipEntry entry = ((ZipEntry) entries.nextElement()); String entryName = entry.getName(); if (entryName.startsWith(key)) { ret = entryName; break; } } } catch (IOException e) { e.printStackTrace(); } finally { if (zipfile != null) { try { zipfile.close(); } catch (IOException e) { e.printStackTrace(); } } } String[] split = ret.split("_"); String channel = "DEV"; if (split != null && split.length >= 2) { channel = ret.substring(split[0].length() + 1); } return channel;}
給友盟設定給友盟
AnalyticsConfig.setChannel(String channel)
Jenkins+Gradle+Android+多渠道包 (一)