bin/calabash-android-build.rb in calabash-android-0.4.9 vs bin/calabash-android-build.rb in calabash-android-0.4.10.pre1

- old
+ new

@@ -1,14 +1,29 @@ def calabash_build(app) - keystore = read_keystore_info() - if fingerprint_from_keystore != fingerprint_from_apk(app) - puts "#{app} is not signed with the configured keystore '#{keystore["keystore_location"]}' Aborting!" - exit 1 - end + apk_fingerprint = fingerprint_from_apk(app) + log "#{app} was signed with a certificate with fingerprint #{apk_fingerprint}" + keystores = JavaKeystore.get_keystores + keystore = keystores.find { |k| k.fingerprint == apk_fingerprint} + unless keystore + puts "#{app} is not signed with any of the available keystores." + puts "Tried the following keystores:" + keystores.each do |k| + puts k.location + end + puts "" + puts "You can resign the app with #{keystores.first.location} by running: + calabash-android resign #{app}" + puts "" + puts "Notice that resigning an app might break some functionality." + puts "Getting a copy of the certificate used when the app was build will in general be more reliable." + + exit 1 + end + test_server_file_name = test_server_path(app) FileUtils.mkdir_p File.dirname(test_server_file_name) unless File.exist? File.dirname(test_server_file_name) unsigned_test_apk = File.join(File.dirname(__FILE__), '..', 'lib/calabash-android/lib/TestServer.apk') platforms = Dir["#{android_home_path}/platforms/android-*"].sort_by { |item| '%08s' % item.split('-').last } @@ -34,10 +49,10 @@ Zip::ZipFile.new("dummy.apk").extract("AndroidManifest.xml","customAndroidManifest.xml") Zip::ZipFile.open("TestServer.apk") do |zip_file| zip_file.add("AndroidManifest.xml", "customAndroidManifest.xml") end end - sign_apk("#{workspace_dir}/TestServer.apk", test_server_file_name) + keystore.sign_apk("#{workspace_dir}/TestServer.apk", test_server_file_name) begin rescue Exception => e log e raise "Could not sign test server"