Calabash-android with Appium Ruby sign app with custom keystore

0

Hi,

I'm trying to sign the app with a custom keystore that I upload
To configure the keystore location, resign and build the .apk file, i have to enter text into the terminal. To do this, I used the following method:

printf ./custom.keystore\nsomePassword\nsomeAlias\n | bundle exec calabash-android setup

This would enter the data I need into the prompts the bundle exec calabash-android setup requires.
This approach results in the following conversion:

printf ./custom.keystorensomePasswordnsomeAliasn | bundle exec calabash-android setup

So it seems the preceding "" has been stripped from the command, rendering it useless.
Apart from this, this command also leaves behind a error:

[DeviceFarm] printf ./internal.keystorenstorePasswordnkeyAliasn | bundle exec calabash-android setup
/home/device-farm/.rvm/gems/ruby-2.4.0/gems/calabash-android-0.9.8/bin/calabash-android-setup.rb:21:in `noecho': Inappropriate ioctl for device (Errno::ENOTTY)
	from /home/device-farm/.rvm/gems/ruby-2.4.0/gems/calabash-android-0.9.8/bin/calabash-android-setup.rb:21:in `ask_for_setting'
	from /home/device-farm/.rvm/gems/ruby-2.4.0/gems/calabash-android-0.9.8/bin/calabash-android-setup.rb:10:in `calabash_setup'
	from /home/device-farm/.rvm/gems/ruby-2.4.0/gems/calabash-android-0.9.8/bin/calabash-android:116:in `<top (required)>'
	from /home/device-farm/.rvm/gems/ruby-2.4.0/bin/calabash-android:22:in `load'
	from /home/device-farm/.rvm/gems/ruby-2.4.0/bin/calabash-android:22:in `<main>'
	from /home/device-farm/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:24:in `eval'
	from /home/device-farm/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:24:in `<main>'
Please enter keystore information to use a custom keystore instead of the default
Please enter keystore location
Please enter the password for the keystore

It seems to me I have no option of inserting or interacting with the programs once they have been loaded into the AWS platform.
In case it helps, the test run URL is https://us-west-2.console.aws.amazon.com/devicefarm/home?region=eu-west-3#/projects/ff120e6e-9b52-4dd0-a373-e6fc6d61a184/runs/c986cace-d0ba-4a8a-867e-125ca3b7276a/jobs/00000

I have been trying to get the job done with bash, but it seems it's pretty dificult, even in my local test environment so I think a better option would be using YAML literal style " | " https://yaml.org/spec/1.2/spec.html#id2795688 to do the trick. Right now I'm executing a test run to see if it works but I have no previous experience with YAML.
Has anybody been able to overcome this issue?
Thanks in advance!

Edited by: SergioRosello on Jan 15, 2019 3:22 AM

已提问 5 年前208 查看次数
2 回答
0

Hi

What device Farm does internally is that , it takes the yaml file and construct a shell script from it.
It then executes this shell scripts as a bash shell script.

/bin/bash script.sh

You can download the script form the artifacts section of your job.
There would be a file named "Test spec shell script"

printf ./custom.keystore\nsomePassword\nsomeAlias\n | bundle exec calabash-android setup
The reason \n is getting ignored is because bash shell treats \ as a special character. So you need to double escape it (\). However i tried escaping it but it then gets the same error as reported by you
noecho': Inappropriate ioctl for device (Errno::ENOTTY)

SO workaround for this is
What "bundle exec calabash-android setup" does is it creates a ".calabash_settings" file in current directory . So u can create this file in current directory with below content
{"keystore_location":"./internal.keystore","keystore_password":"somePassword","keystore_alias":"someAlias"}

So u can package the ".calabash_settings" in your test package zip, u dont have to run the above command

important Note

I noticed in your yaml file that you are running the commands

  • printf 'keyPassword\n' | bundle exec calabash-android resign unittest.apk
  • printf 'keyPassword\n' | bundle exec calabash-android build unittest.apk
    As told above, make sure you double escape the \
    So command will become
  • printf 'keyPassword\n' | bundle exec calabash-android resign unittest.apk

  • printf 'keyPassword\n' | bundle exec calabash-android build unittest.apk

Also i noticed that your zip has internal.keystore but the forum post command u pasted above says custom.keystore. make sure you are using the correct name

Let us know if you run into any problems.

I will suggest that you create a local Ruby environment using gemset and replicate the exact command on your local environment which you plan to run inside the yaml file.This will help you debug problems faster

已回答 5 年前
0

Looks like some of the content in the last post did not properly got rendered. When i said you need to double scape it, replace backslash everywhere with two backslashes

Edited by: Anurag@AWS on Jan 15, 2019 2:52 PM

已回答 5 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则