xamarin.android App signing does not work

前端 未结 5 1245
醉酒成梦
醉酒成梦 2021-01-21 12:35

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 di

相关标签:
5条回答
  • 2021-01-21 13:14

    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"
    
    0 讨论(0)
  • 2021-01-21 13:18

    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?

    0 讨论(0)
  • 2021-01-21 13:29

    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
    
    0 讨论(0)
  • 2021-01-21 13:29

    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.

    0 讨论(0)
  • 2021-01-21 13:32

    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

    0 讨论(0)
提交回复
热议问题