2

So im trying to publish my new android app to the Google PlayStore. From reading this tutorial I understand that I have to sign my app before releasing it to the PlayStore. I did exactly the same as in the tutorial. After uploading it to the PlayStore I tried to install the App on my device. I got the message "Package file was not signed correctly". This is strage.. In xamaran studio I get the message "Package succesfully signed".

If I try to install the App from the apk on the device I get the message "Unable to install"

What could be wrong here?

Im using Xamarin Studion on a Mac.

Florian Schaal
  • 2,586
  • 3
  • 39
  • 59
  • Are you using Xamarin Studio or Visual Studio? Are you running OSX or Windows? – Tom Opgenorth May 13 '13 at 18:54
  • From my experience, I would recommend manually sign your application.http://docs.xamarin.com/guides/android/deployment%2C_testing%2C_and_metrics/publishing_an_application/part_1_-_preparing_an_application_for_release#Manually_Signing_the_APK – Aaron He May 13 '13 at 22:47
  • @AaronHe Ok Manual signing worked just fine but when I try to zipalign I get the message "No such command" Googled for a bit and found that you have to do ./zipalign but then I get the message "No such file or directory". – Florian Schaal May 14 '13 at 07:19
  • @AaronHe It worked now I zipaligned and signed my package. When I upload it now to the Playstore its says "Your APK has been signed with multiple certificates. Please only sign it with one certificate and upload it again." – Florian Schaal May 14 '13 at 08:46

5 Answers5

8

Found the problem..This is a JAVA tooling problem. This occurs frequently with mixing JDK and JRE tools on the system.

DO NOT USE THE TOOLS FROM Java 7!

Only use the tools from JDK 6. You can check what version you have by typing:

java -version

If you are still unsure whether the signing was succesfull you can type:

which jarsigner

jarsigner -verify -verbose -certs myapp.apk
Florian Schaal
  • 2,586
  • 3
  • 39
  • 59
  • 2
    Just ran into this problem, and wanted to add that the path (at least on OSX 10.9) to JDK 6 is /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home and you can set this in Xamarin Studio in Preferences -> SDK Locations -> Android – Dave Wolfe Jul 31 '14 at 23:18
  • I'm not sure if it's only Java 6 that works, but I can confirm that Java 8 didn't work for me on OSX Yosemite. I didn't change any of the tools or Java versions used within my development environment (which is Java 8 from `java -version`)... and the Dev environment is Xamarin... but I can say that when I used the Java 6 version of `jarsigner`, that I was then able to run the app from the Google Play store, and wasn't otherwise able to do so. – Phil Ryan Nov 06 '14 at 03:51
1

When publishing on a Mac, I automate the process using rake. This gist is a sample rake file showing how to do so. This rake file will version the assembly, compile the application, and then sign/zipalign the APK.

Note that the Albacore gem must also be installed.

Tom Opgenorth
  • 1,511
  • 1
  • 12
  • 19
  • Already fixed it by using a different version of java. There is a bug in Java 7 JDK. But this looks much easyer. Ill try it asap. – Florian Schaal May 15 '13 at 08:19
1

this seems to be caused by switching from JDK 1.6 to JDK 1.7. Instead of sticking to JDK 1.6 (which is not an option in some cases), I recommend to create a small script for creating the signed&aligned apk based on http://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/publishing_an_application/part_1_-_preparing_an_application_for_release/

# First clean the Release target.
msbuild.exe HelloWorld.csproj /p:Configuration=Release /t:Clean

# Now build the project, using the Release target.
msbuild.exe HelloWorld.csproj /p:Configuration=Release /t:PackageForAndroid

# At this point there is only the unsigned APK - sign it.
# The script will pause here as jarsigner prompts for the password.
# It is possible to provide they keystore password for jarsigner.exe by adding an extra command line parameter -storepass, for example
#    -storepass <MY_SECRET_PASSWORD>
# If this script is to be checked in to source code control then it is not recommended to include the password as part of this script.
& 'C:\Program Files\Java\jdk1.6.0_24\bin\jarsigner.exe' -verbose -sigalg SHA1withRSA -digestalg SHA1  -keystore ./xample.keystore -signedjar ./bin/Release/mono.samples.helloworld-signed.apk ./bin/Release/mono.samples.helloworld.apk publishingdoc

# Now zipalign it.  The -v parameter tells zipalign to verify the APK afterwards.
& 'C:\Program Files\Android\android-sdk\tools\zipalign.exe' -f -v 4 ./bin/Release/mono.samples.helloworld-signed.apk ./helloworld.apk

The important part is to use the parameters -sigalg SHA1withRSA -digestalg SHA1 which force JDK 1.7 to use the expected digest algorithm (instead of SHA-256 which seems to be the default in JDK 1.7 and is not accepted by all Android versions).

Note that you can find the msbuild location with

$dotNetVersion = "4.0"
$regKey = "HKLM:\software\Microsoft\MSBuild\ToolsVersions\$dotNetVersion"
$regProperty = "MSBuildToolsPath"

$msbuildExe = join-path -path (Get-ItemProperty $regKey).$regProperty -childpath "msbuild.exe"
Philipp
  • 11,549
  • 8
  • 66
  • 126
0

I found the solution here https://forums.xamarin.com/discussion/comment/72399/#Comment_72399.

The answer from Felix Alcala works perfect. No more "App not installed" messages on device.

Open the SDK Locations in Xamarin Studio

Preferences/Projects/SDK Locations/Android

and set Java SDK(JDK) to

/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

Francisco
  • 41
  • 4
-1

When using the Google Play service component ICS from Xamarin the following error appears if you are using JDK 6.

2>JAVAC : warning : com\google\ads\mediation\MediationBannerListener.class(com\google\ads\mediation:MediationBannerListener.class): major version 51 is newer than 50, the highest major version supported by this compiler.
2>JAVAC : warning : com\google\ads\mediation\MediationBannerAdapter.class(com\google\ads\mediation:MediationBannerAdapter.class): major version 51 is newer than 50, the highest major version supported by this compiler.

Error building Xamarin.Android project with Google Play Services

This error is solved by changing from JDK 6 to JDK 7. Because of that now my app that is already deployed to the Google Play Store is throwing "Package file was not signed correctly" in some smartphones.

Is there a way to sign app correctly using JDK 7 and Xamarin?

Community
  • 1
  • 1
user1261620
  • 377
  • 2
  • 5
  • 12