Error: does not have a signature matching the target

6,853 views
Skip to first unread message

Thanuja G

unread,
Aug 27, 2012, 5:48:07 AM8/27/12
to calabash...@googlegroups.com
Hi,
 
I am getting signature mismatch error while starting test server: Error is as below:
 
INSTRUMENTATION_STATUS: id=ActivityManagerService
INSTRUMENTATION_STATUS: Error=Permission Denial: starting instrumentation ComponentInfo{myapp.test/sh.calab
a.instrumentationbackend.CalabashInstrumentationTestRunner} from pid=16392, uid=16392 not allowed because package myapp.test does not have a signature matching the target myapp
INSTRUMENTATION_STATUS_CODE: -1
java.lang.SecurityException: Permission Denial: starting instrumentation ComponentInfo{myapp.test/sh.calaba
.instrumentationbackend.CalabashInstrumentationTestRunner} from pid=16392, uid=16392 not allowed because package myapp.test does not have a signature matching the target myapp
 
In one of the post i found out that we can resolve these issue in 2 ways:

a) Sign the target package with debug key as you did to test application or
b) Get the key with which the target application been sign and sign the
test application with the same.

Either of the of the process will yeild you +ve result.

But my query is how can I can find out the debug key used to sign the target package ? What exactly is this debug key ?

 

 

Thanuja G

unread,
Aug 27, 2012, 6:03:47 AM8/27/12
to calabash...@googlegroups.com
Is there any other alternate way to launch the app on device while running script without knowing debug key.

Jonas Maturana Larsen

unread,
Aug 27, 2012, 9:11:36 AM8/27/12
to calabash...@googlegroups.com
Hi Thanuja,

You can resign the app with your own debug key.
That will work for most apps.

Thanuja G

unread,
Aug 28, 2012, 12:26:33 AM8/28/12
to calabash...@googlegroups.com
Thanks Jonas.
 
Please let me know how to do resign the app. I do not have source code of this app. I just get .apk file to test. Is it possible to resign the .apk file ? If so could you please let me know the steps.

Kavi

unread,
Aug 28, 2012, 4:28:56 AM8/28/12
to calabash...@googlegroups.com
Hi Thanuja,

You can change the signature of a apk by following the below steps

* Un-zip the apk file
* Delete the META-¬INF folder
* Re‐zip the apk file
It will zip file as "applicationName.apk.zip" , rename it and make it as "applicationName.apk"
* In Dos prompt/Terminal write following commands

> jarsigner -keystore ~/.android/debug.keystore -storepass android -keypass android
applicationName.apk androiddebugkey
> zipalign 4
applicationName.apk TempApplicationName.apk

Then rename TempApplicationName.apk to applicationName.apk if you need.

Hope This helps u

Thanuja G

unread,
Aug 28, 2012, 5:08:20 AM8/28/12
to calabash...@googlegroups.com
Hi Kavi,
 
Thanks a lot. It worked :) :)
Message has been deleted

Mishal Shah

unread,
Dec 24, 2012, 2:56:15 AM12/24/12
to calabash...@googlegroups.com
Hi

I am getting same Permission denial issue.

How do I resign my application, I have the source code , but not sure how I can resign. Please help.

Thank You!

bootstraponline

unread,
Dec 24, 2012, 3:31:20 PM12/24/12
to calabash-android
Once this pull request is merged, you can simply run calabash-android
resign my.apk

https://github.com/calabash/calabash-android/pull/174

Mishal Shah

unread,
Dec 26, 2012, 2:56:53 PM12/26/12
to calabash...@googlegroups.com
Thanks Bootstraponline, 

I am getting following error 

$ calabash-android resign do_not_checkin/target/x.apk
jarsigner: unable to sign jar: java.util.zip.ZipException: invalid entry crc-32
(expected 0xfab02aa7 but got 0x1d2e6fac)
jarsigner command: "C:\Program Files\Java\jdk1.6.0_37/bin/jarsigner.exe" -sigalg
 MD5withRSA -digestalg SHA1 -signedjar c:/Users/x/workspace/Dec12/shop/do_not_checkin/target/x.apk -storepass android -k
eystore "c:/Users/x/.android/debug.keystore" C:/Users/x/AppData/Loca
l/Temp/d20121226-7360-1wr3vii/unsigned.apk androiddebugkey
c:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.3.8/lib/calabash-android/
helpers.rb:74:in `sign_apk': Could not sign app (C:/Users/x/AppData/Local/
Temp/d20121226-7360-1wr3vii/unsigned.apk (RuntimeError)
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.3.8/lib/cala
bash-android/helpers.rb:57:in `block in resign_apk'
        from c:/Ruby193/lib/ruby/1.9.1/tmpdir.rb:83:in `mktmpdir'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.3.8/lib/cala
bash-android/helpers.rb:42:in `resign_apk'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.3.8/bin/cala
bash-android:87:in `<top (required)>'
        from c:/Ruby193/bin/calabash-android:23:in `load'
        from c:/Ruby193/bin/calabash-android:23:in `<main>'

bootstrap online

unread,
Dec 26, 2012, 3:38:05 PM12/26/12
to calabash...@googlegroups.com

The pull request hasn't been merged yet. That's why it errors.

bootstrap online

unread,
Dec 26, 2012, 3:58:02 PM12/26/12
to calabash...@googlegroups.com

It's merged now. If you rebuild the gem from master then resign will work.

Jonas Maturana Larsen

unread,
Dec 26, 2012, 4:10:12 PM12/26/12
to calabash...@googlegroups.com
And now released as 0.4.0.pre3. You can upgrade by running:

gem install calabash-android --pre

- Jonas

Mishal Shah

unread,
Dec 26, 2012, 9:13:14 PM12/26/12
to calabash...@googlegroups.com
Thank you!

I got the resign working with the apk file now :) 

The new issue i am having now

When the app launch's(using calabash) it opens up bar code scanner. I have a bar code scanner in the app but its button on the landing page. When I open up the app manually it does not launch the bar code scanner, it opens up the correct layout.   Why does it opens up bar code scanner? 

The Steps I used 
calabash-android resign <file.apk>
calabash-android build <file.apk>
calabash-android run <file.apk>

Cat Log: 
12-26 17:15:30.311: W/ActivityManager(301): Duplicate finish request for HistoryRecord{40e70cf0 com.app.android/com.google.zxing.client.android.CaptureActivity}
12-26 17:15:30.441: W/WindowManager(301): Window Window{40e8e6d8 com.app.android/com.google.zxing.client.android.CaptureActivity paused=false} destroyed surface Surface(name=com.app.android/com.google.zxing.client.android.CaptureActivity, identity=-1, mNativeSurface=0), session Session{409f65f8 uid 10127}
12-26 17:15:30.441: W/WindowManager(301): Window Window{408f9510 SurfaceView paused=false} destroyed surface Surface(name=SurfaceView, identity=-1, mNativeSurface=0), session Session{409f65f8 uid 10127}
12-26 17:15:30.451: D/InputTransport(301): Input channel destroyed: name='40e8e6d8 com.app.android/com.google.zxing.client.android.CaptureActivity (server)', ashmemFd=280, receivePipeFd=331, sendPipeFd=290
12-26 17:15:30.451: D/InputTransport(18003): Input channel destroyed: name='40e8e6d8 com.app.android/com.google.zxing.client.android.CaptureActivity (client)', ashmemFd=53, receivePipeFd=54, sendPipeFd=55
12-26 17:15:30.451: D/PowerManagerService(301): releaseWakeLockLocked flags=0x0 tag=KEEP_SCREEN_ON_FLAG myUID=1000 myPID=301 myTID=306
12-26 17:15:30.621: W/InputDispatcher(301): Permission denied: injecting event from pid 18003 uid 10127 to window with input channel 40d64db0 com.sec.android.app.twlauncher/com.sec.android.app.twlauncher.Launcher (server) owned by uid 10025
12-26 17:15:30.621: W/WindowManager(301): Input event injection permission denied.
12-26 17:15:30.632: V/MediaPlayerService(182): Client(33) destructor pid = 18003
12-26 17:15:30.632: V/MediaPlayerService(182): disconnect(33) from pid 18003
12-26 17:15:30.632: D/StagefrightPlayer(182): reset
12-26 17:15:30.632: D/StagefrightPlayer(182): reset over
12-26 17:15:30.632: I/ActivityManager(301): Process com.app.android (pid 18003) has died.
12-26 17:15:30.642: D/StagefrightPlayer(182): reset
12-26 17:15:30.642: D/StagefrightPlayer(182): reset over
12-26 17:15:30.642: V/AudioSink(182): close
12-26 17:15:30.642: I/Process(301): Sending signal. PID: 18025 SIG: 9
12-26 17:15:30.642: W/ActivityManager(301): Crash of app com.app.android running instrumentation ComponentInfo{sh.calaba.android.test/sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner}
12-26 17:15:30.642: I/ActivityManager(301): Force stopping package com.app.android uid=10127
12-26 17:15:30.642: W/ActivityManager(301): Scheduling restart of crashed service com.app.android/com.urbanairship.push.PushService in 5000ms
12-26 17:15:30.642: I/ActivityManager(301):   Force stopping service ServiceRecord{40d138f0 com.app.android/com.urbanairship.push.PushService}

Jonas Larsen

unread,
Dec 27, 2012, 3:52:51 AM12/27/12
to calabash...@googlegroups.com
Try to run with -v and post the output here.
calabash-android run <file.apk> -v

Mishal Shah

unread,
Dec 27, 2012, 2:59:38 PM12/27/12
to calabash...@googlegroups.com
Jonas, 

This is what i got after running with -v 

$ calabash-android run do_not_checkin/target/app-1.1.0.apk -v
2012-12-27 11:53:21 - cucumber -v PACKAGE_NAME=com.x.android MAIN_ACTIVITY=c
om.google.zxing.client.android.CaptureActivity APP_PATH="c:/Users/x/worksp
ace/app_PostPeak_Dec12/app/do_not_checkin/target/app-1.1.0.apk" TEST_APP_P
ATH="test_servers/a2e96bbc31d566985c5625ab4fbf5d16_0.4.0.pre2.apk" TEST_SERVER_P
ORT=34777
Code:
  * features/support/env.rb
  * features/support/app_installation_hooks.rb
  * features/support/app_life_cycle_hooks.rb
  * features/support/hooks.rb
  * features/step_definitions/calabash_steps.rb

Features:
  * features/my_first.feature
Parsing feature files took 0m0.022s

Feature: Login feature

  Scenario: As a valid user I can log into my app # features\my_first.feature:5
2012-12-27 11:53:23 - First scenario in feature - reinstalling apps
2012-12-27 11:53:23 - "C:\Users\x\android-sdks\platform-tools\adb.exe"  fo
rward tcp:34777 tcp:7102
2012-12-27 11:53:23 -
2012-12-27 11:53:23 - Uninstalling: sh.calaba.android.test
2012-12-27 11:53:24 - Success

2012-12-27 11:53:24 - Uninstalling: com.x.android
2012-12-27 11:53:26 - Success

2012-12-27 11:53:26 - Installing: test_servers/a2e96bbc31d566985c5625ab4fbf5d16_
0.4.0.pre2.apk
2399 KB/s (513603 bytes in 0.209s)
2012-12-27 11:53:28 -   pkg: /data/local/tmp/a2e96bbc31d566985c5625ab4fbf5d16_0.
4.0.pre2.apk

Success

2012-12-27 11:53:29 - Installing: c:/Users/x/workspace/app_PostPeak_Dec1
2/app/do_not_checkin/target/app-1.1.0.apk
3087 KB/s (17960693 bytes in 5.681s)
2012-12-27 11:53:41 -   pkg: /data/local/tmp/app-1.1.0.apk

Success

2012-12-27 11:53:42 - Starting test server using:
2012-12-27 11:53:42 - "C:\Users\x\android-sdks\platform-tools\adb.exe"  sh
ell am instrument -e target_package com.x.android -e main_activity com.googl
e.zxing.client.android.CaptureActivity -e class sh.calaba.instrumentationbackend
.InstrumentationBackend sh.calaba.android.test/sh.calaba.instrumentationbackend.
CalabashInstrumentationTestRunner
2012-12-27 11:53:43 - Checking if instrumentation backend is ready
2012-12-27 11:53:44 - Is app running? true
2012-12-27 11:53:44 - Instrumentation backend not yet ready
2012-12-27 11:53:47 - Checking if instrumentation backend is ready
2012-12-27 11:53:47 - Is app running? true
2012-12-27 11:53:47 - Instrumentation backend is ready!
    Then I take a picture                         # calabash-android-0.4.0.pre2/
lib/calabash-android/steps/screenshot_steps.rb:5

1 scenario (1 passed)
1 step (1 passed)
0m24.470s

x@L4351288 ~/workspace/app_PostPeak_Dec12/app

Jonas Larsen

unread,
Dec 27, 2012, 5:08:26 PM12/27/12
to calabash...@googlegroups.com
It looks like calabash-android thinks your main_actvity is com.google.zxing.client.android.CaptureActivity.

That doesn't look right, does it?

I might have to look at your apk to work this out. (We do sign NDAs if that's required)

- Jonas
--
Jonas Maturana Larsen
lesspainful.com

Jebin Varghese

unread,
Aug 16, 2014, 12:08:10 AM8/16/14
to calabash...@googlegroups.com
Hi,
I'm finding it difficult to understand why i'm getting the RunTimeError as below: while executing "start_test_server_in_background"

C:\CalabashProjects\Project1>calabash-android console accountstracker.apk
DL is deprecated, please use Fiddle
*** WARNING: You must use ANSICON 1.31 or higher (https://github.com/adoxa/ansicon/) to get coloured output on Windows
irb(main):001:0> start_test_server_in_background
java.lang.SecurityException: Permission Denial: starting instrumentation ComponentInfo{com.st.accounts.test/sh.calaba.instrumentationbackend.CalabashInstrumenta
tionTestRunner} from pid=30400, uid=30400 not allowed because package com.st.accounts.test does not have a signature matching the target com.st.accounts
        at android.os.Parcel.readException(Parcel.java:1431)
        at android.os.Parcel.readException(Parcel.java:1385)
        at android.app.ActivityManagerProxy.startInstrumentation(ActivityManagerNative.java:3233)
        at com.android.commands.am.Am.runInstrument(Am.java:801)
        at com.android.commands.am.Am.onRun(Am.java:242)
        at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
        at com.android.commands.am.Am.main(Am.java:75)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:297)
        at dalvik.system.NativeStart.main(Native Method)
RuntimeError: App did not start
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/calabash-android-0.5.1/lib/calabash-android/operations.rb:532:in `block in start_test_server_in_background'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/retriable-1.3.3.1/lib/retriable/retriable.rb:31:in `perform'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/retriable-1.3.3.1/lib/retriable/retriable.rb:59:in `retriable'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/calabash-android-0.5.1/lib/calabash-android/operations.rb:531:in `start_test_server_in_background'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/calabash-android-0.5.1/lib/calabash-android/operations.rb:110:in `start_test_server_in_background'
        from (irb):1
        from C:/Ruby200/bin/irb:12:in `<main>'
irb(main):002:0>





Pankaj Khurana

unread,
Jun 27, 2015, 4:05:01 AM6/27/15
to calabash...@googlegroups.com
Hi Jebin Varghese ,


Have you resolved the above issue? 

I am facing the same error.
Reply all
Reply to author
Forward
0 new messages