Unable to sign app with default keystore

1,116 views
Skip to first unread message

Aniket Gadre

unread,
Jul 4, 2013, 9:35:37 AM7/4/13
to appium-...@googlegroups.com
When I didn't pass -use--keystore argument and app was signed with appium certificate, Appium was not able to launch the required activity

I tried executing below command independently and it failed
adb -s 015d24a428641a0d shell am start -n com.test.amdocs/.activity.LauncherActivity


Error Log:
Starting: Intent { cmp=com.test.amdocs/.activity.LauncherActivity }
java.lang.SecurityException: Permission Denial: starting Intent { flg=0x10000000
 cmp=com.test.amdocs/.activity.LauncherActivity } from null (pid=8992, uid=2000) not exported from uid 10078
        at android.os.Parcel.readException(Parcel.java:1425)
        at android.os.Parcel.readException(Parcel.java:1379)
        at android.app.ActivityManagerProxy.startActivityAsUser(ActivityManagerNative.java:1921)
        at com.android.commands.am.Am.runStart(Am.java:494)
        at com.android.commands.am.Am.run(Am.java:109)
        at com.android.commands.am.Am.main(Am.java:82)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:235)
        at dalvik.system.NativeStart.main(Native Method)



So tried using default keystore but it seems app re-signing is failing due to some issue

info: Checking whether we need to run fast reset
debug: checkKeystoreMD5
debug: Printing keystore md5: "C:\Program Files\Java\jdk1.7.0_07\bin\keytool.exe" -v -list -alias "androiddebugkey" -keystore "C:\Users\aniketg\.android\debug.keystore" -storepass "android"
debug:  Keystore MD5: 86:3B:7C:C8:99:3C:B6:6F:99:93:35:E2:20:9A:8C:5F
debug: checkApkMD5
debug: Entry: META-INF/CERT.RSA
debug: entryPath: C:\Windows\Temp\com.test.amdocs\cert
debug: entryFile: C:\Windows\Temp\com.test.amdocs\cert\META-INF\CERT.RSA
debug: extracted!
debug: Printing apk md5: "C:\Program Files\Java\jdk1.7.0_07\bin\keytool.exe" -v -printcert -file C:\Windows\Temp\com.test.amdocs\cert\META-INF\CERT.RSA
debug: entryHash MD5: E8:9B:15:8E:4B:CF:98:8E:BD:09:EB:83:F5:37:8E:87
debug:  keystore MD5: 86:3B:7C:C8:99:3C:B6:6F:99:93:35:E2:20:9A:8C:5F
debug: Matches keystore? false
debug: checkApkCert match? false
debug: checkKeystoreMD5
debug: Printing keystore md5: "C:\Program Files\Java\jdk1.7.0_07\bin\keytool.exe" -v -list -alias "androiddebugkey" -keystore "C:\Users\aniketg\.android\debug.keystore" -storepass "android"
debug:  Keystore MD5: 86:3B:7C:C8:99:3C:B6:6F:99:93:35:E2:20:9A:8C:5F
debug: checkApkMD5
debug: Entry: META-INF/CERT.RSA
debug: entryPath: C:\Windows\Temp\com.test.amdocs\cert
debug: entryFile: C:\Windows\Temp\com.test.amdocs\cert\META-INF\CERT.RSA
debug: extracted!
debug: Printing apk md5: "C:\Program Files\Java\jdk1.7.0_07\bin\keytool.exe" -v -printcert -file C:\Windows\Temp\com.imdb.mobile\cert\META-INF\CERT.RSA
debug: entryHash MD5: 6C:7A:55:37:B0:5F:DB:E3:57:60:BB:32:96:6D:B7:CA
debug:  keystore MD5: 86:3B:7C:C8:99:3C:B6:6F:99:93:35:E2:20:9A:8C:5F
debug: Matches keystore? false
debug: checkApkCert match? false
debug: App signed? false C:\Amdocs\Automation Frameworks\Appium\Test Apps\test\test.apk
info: Building fast reset
info: Checking whether aapt is present
info: [ADB] Using aapt from C:\Program Files\Android\android-sdk\build-tools\17.
0.0\aapt.exe
info: Compiling manifest C:\Windows\Temp\AndroidManifest.xml
debug: "C:\Program Files\Android\android-sdk\build-tools\17.0.0\aapt.exe" package -M "C:\Windows\Temp\AndroidManifest.xml" --rename-manifest-package "com.test.amdocs.clean" --rename-instrumentation-target-package "com.test.amdocs" -I "C:\Program Files\Android\android-sdk\platforms\android-17\android.jar" -F "C:\Windows\Temp\AndroidManifest.xml.apk" -f
debug: Compiled manifest
info: Inserting manifest, src: C:\Amdocs\Automation Frameworks\Appium\appium-git\app\android\Clean.apk, dst: C:\Windows\Temp\com.test.amdocs.clean.apk
debug: Extracting manifest
info: Unzipping C:\Windows\Temp\AndroidManifest.xml.apk
info: Testing zip archive: C:\Windows\Temp\AndroidManifest.xml.apk
info: Zip archive tested clean
info: Unzip successful
debug: Writing tmp apk. C:\Amdocs\Automation Frameworks\Appium\appium-git\app\android\Clean.apk to C:\Windows\Temp\com.test.amdocs.clean.apk
debug: Testing new tmp apk.
info: Testing zip archive: C:\Windows\Temp\com.test.amdocs.clean.apk
info: Zip archive tested clean
AndroidManifest.xml
debug: Inserted manifest.
debug: Signing app and clean apk.
debug: Unsigning apk with: "C:\Program Files\Java\jdk1.7.0_07\bin\java.exe" -jar
 "C:\Amdocs\Automation Frameworks\Appium\appium-git\app\android\unsign.jar" "C:\Windows\Temp\com.test.amdocs.clean.apk"
debug: Unsigning apk with: "C:\Program Files\Java\jdk1.7.0_07\bin\java.exe" -jar
 "C:\Amdocs\Automation Frameworks\Appium\appium-git\app\android\unsign.jar" "C:\Amdocs\Automation Frameworks\Appium\Test Apps\IMDB\IMDb_3.2.2.apk"
warn: Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:C:\PROGRA~1\HP\QUICKT~1\bin\JAVA_S~1\classes;C:\PROGRA~1\HP\QUICKT~1\bin\JAVA_S~1\classes\jasmine.jar

error: Failed to start an Appium session, err was: Error: Could not unsign apk.
Are you sure the file path is correct: "C:\\Windows\\Temp\\com.test.amdocs.clean.apk"
info: Responding to client with error: {"status":6,"value":{"message":"A session
 is either terminated or not started (Original error: Could not unsign apk. Are
you sure the file path is correct: \"C:\\\\Windows\\\\Temp\\\\com.test.amdocs.clean.apk\")","origValue":"Could not unsign apk. Are you sure the file path is cor



bootstrap online

unread,
Jul 4, 2013, 9:39:46 AM7/4/13
to Aniket Gadre, appium-...@googlegroups.com
This is a Windows specific issue because both signing strategies work on OS X.
> --
> http://appium.io
> ---
> You received this message because you are subscribed to the Google Groups
> "Appium-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to appium-discus...@googlegroups.com.
> Visit this group at http://groups.google.com/group/appium-discuss.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Rejish R

unread,
Aug 20, 2014, 11:20:29 PM8/20/14
to appium-...@googlegroups.com
Hi Ankit,

Were you able to resolve the below issue.

I am also facing the same issue. 

My use case is: I have a signed app, which when signed by appium debug cert, it is not able to launch the required activity because at the launch time it checks the certificate authenticity. So I am trying to re-sign the apk with existing certificate itself.

Kindly provide some input.

Below is the stack trace for it:
 debug: Set app process to: com.example
> debug: Not uninstalling app since server not started with --full-reset
> debug: Printing keystore md5: "C:\Java\jdk1.7.0_55\bin\keytool.exe" -v -list -alias "myalias" -keystore "C:\android\key.keystore" -storepass "password"
> debug: Keystore MD5: 1A:FE:DF:49:1A:D3:13:AE:EA:7A:DE:41:C4:3A:58:27
> debug: Entry: META-INF/CERT.RSA
> debug: entryPath: C:\Windows\Temp\com.example\cert
> debug: entryFile: C:\Windows\Temp\com.example\cert\META-INF\CERT.RSA
> debug: extracted!
> debug: Printing apk md5: "C:\Java\jdk1.7.0_55\bin\keytool.exe" -v -printcert -file C:\Windows\Temp\com.example\cert\META-INF\CERT.RSA
> debug: Unsigning apk with: "C:\Java\jdk1.7.0_55\bin\java.exe" -jar "C:\Users\rrajgopa\node_modules\appium\node_modules\appium-adb\jars\unsign.jar" "C:\Users\rrajgopa\workspace\testdroidappium\example.apk"
> debug: Signing apk with: "C:\Java\jdk1.7.0_55\bin\jarsigner.exe" -sigalg MD5withRSA -digestalg SHA1 -keystore "C:\android\key.keystore" -storepass "password" -keypass "myalias" "C:\Users\rrajgopa\workspace\testdroidappium\example.apk" "myalias"
> warn: 
> debug: Stopping logcat capture
> debug: Logcat terminated with code null, signal SIGTERM
> debug: Sent shutdown command, waiting for UiAutomator to stop...
> warn: UiAutomator did not shut down fast enough, calling it gone
> debug: Cleaning up android objects
> debug: Cleaning up appium session
> info: <-- POST /wd/hub/session 500 11489.192 ms - 422 
> error: Failed to start an Appium session, err was: Error: Could not sign apk. Are you sure the file path is correct: "C:\\Users\\rrajgopa\\workspace\\testdroidappium\\example.apk"
> debug: Error: Could not sign apk. Are you sure the file path is correct: "C:\\Users\\rrajgopa\\workspace\\testdroidappium\\example.apk"
>     at C:\Users\rrajgopa\node_modules\appium\node_modules\appium-adb\lib\adb.js:428:19
>     at ChildProcess.exithandler (child_process.js:641:7)
>     at ChildProcess.EventEmitter.emit (events.js:98:17)
>     at maybeClose (child_process.js:743:16)
>     at Process.ChildProcess._handle.onexit (child_process.js:810:5)
> debug: Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Could not sign apk. Are you sure the file path is correct: \"C:\\\\Users\\\\rrajgopa\\\\workspace\\\\testdroidappium\\\\example.apk\")","origValue":"Could not sign apk. Are you sure the file path is correct: \"C:\\\\Users\\\\rrajgopa\\\\workspace\\\\testdroidappium\\\\example.apk\""},"sessionId":null}

Thanks in advance....

Regards,
Rejish

bootstrap online

unread,
Aug 21, 2014, 8:34:37 AM8/21/14
to Rejish R, appium-...@googlegroups.com
use a custom keystore with appium. this is explained in the docs
> --
> http://appium.io
> ---
> You received this message because you are subscribed to the Google Groups
> "Appium-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to appium-discus...@googlegroups.com.
> Visit this group at http://groups.google.com/group/appium-discuss.
> For more options, visit https://groups.google.com/d/optout.

Rejish

unread,
Aug 21, 2014, 9:49:45 AM8/21/14
to bootstrap online, appium-...@googlegroups.com
Thanks bootstraponline...😊

I tried the same during the day and its working now.

Regards,
Rejish

From: bootstrap online
Sent: ‎21-‎08-‎2014 18:04
To: Rejish R
Cc: appium-...@googlegroups.com
Subject: Re: [appium-discuss] Re: Unable to sign app with default keystore

Rejish R

unread,
Aug 22, 2014, 1:34:06 AM8/22/14
to bootstrap online, appium-...@googlegroups.com
Hi Bootstrap online,

While executing the test cases with custom keystore, I am getting below error.

error: Unhandled error: TypeError: Arguments to path.resolve must be strings
at Object.exports.resolve (path.js:313:15)
at ADB.checkCustomApkCert (/var/lib/jenkins/appiumHome/appium/node_modules/appium-adb/lib/adb.js:495:22)
at ADB.checkApkCert (/var/lib/jenkins/appiumHome/appium/node_modules/appium-adb/lib/adb.js:471:17)
at ADB.checkAndSignApk (/var/lib/jenkins/appiumHome/appium/node_modules/appium-adb/lib/adb.js:1360:8)
at androidCommon.installAppForTest (/var/lib/jenkins/appiumHome/appium/lib/devices/android/android-common.js:448:12)
at /var/lib/jenkins/appiumHome/appium/node_modules/async/lib/async.js:610:21
at /var/lib/jenkins/appiumHome/appium/node_modules/async/lib/async.js:249:17
at iterate (/var/lib/jenkins/appiumHome/appium/node_modules/async/lib/async.js:149:13)
at /var/lib/jenkins/appiumHome/appium/node_modules/async/lib/async.js:160:25


Kindly suggest a solution to this issue.


Regards,
Rejish

bootstrap online

unread,
Aug 22, 2014, 7:33:42 AM8/22/14
to Rejish R, appium-...@googlegroups.com
Make sure you're using appium 1.2.1 and specifying all the necessary
caps for a custom keystore.
https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/caps.md

If it still doesn't work, open an issue on github.
Reply all
Reply to author
Forward
0 new messages