Skip to content

Instantly share code, notes, and snippets.

@huangxiangdan
Created November 12, 2012 12:07
Show Gist options
  • Save huangxiangdan/4059014 to your computer and use it in GitHub Desktop.
Save huangxiangdan/4059014 to your computer and use it in GitHub Desktop.
auto_build_for_umeng
require 'yaml'
# exec 'apktool d kecheng.apk output'
@cfg = YAML.load_file('config.yml')
default_channel = @cfg['default_channel']
system 'apktool d -f kecheng.apk output'
last_channel = default_channel
@cfg['channels'].split.each do |channel|
if channel != default_channel
puts "work with #{channel}"
# <meta-data android:value="Web" android:name="UMENG_CHANNEL"/>
str = IO.readlines('output/AndroidManifest.xml').join.gsub(Regexp.new("android:value=\"#{last_channel}\""), "android:value=\"#{channel}\"")
file = File.new('output/AndroidManifest.xml', "w")
file.write(str)
file.close
last_channel = channel
system "apktool b output kecheng_#{channel}.apk"
end
end
system "rm -r output"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment