Jenkins + Gradle + Android + Multi-Channel package (1), jenkinsgradle
The purpose is that QA can log on to Jenkins and select the version to be built. The result is notified by email (including the build information, static code analysis results, APK download link, QR code, and so on), and then archive it.
- Build using Gralde.
- Package and generate a QR code. archive is implemented using a Python script.
Multi-channel package
Playing multi-channel package has many methods, I use is, generate a signed APK, and then add an empty file under the APK package META-INF directory, the file name contains channel information, read this file in Android to obtain information and set it to umeng through code. This avoids repeated compilation and signature.
Modify the Python script:
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
How to retrieve channel information and modify it cyclically depends on your situation
Read from 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;}
Set umeng to umeng
AnalyticsConfig.setChannel(String channel)