Search Unity

Problem signing Android build with provided keystore

Discussion in 'Unity Build Automation' started by Geshdo_Pierre, Mar 19, 2019.

  1. Geshdo_Pierre

    Geshdo_Pierre

    Joined:
    Mar 16, 2019
    Posts:
    2
    I'm trying to sign an Android application as part of the Unity Cloud Build process.

    These are the steps I've currently completed:
    1. Generate a keystore and key using the Unity utility
    2. Create Unity Cloud Build configuration, targeting Android
    3. Update build Signing Credential configuration to use utilize previously generated keystore and key
    4. Trigger clean build

    This is the resulting log entry of the error causing the build to fail.

    [Unity] ERROR: Execution failed for task ':validateSigningRelease'.
    [Unity] ERROR: > Keystore file '/BUILD_PATH/
    [APP].[BUILD_CONFIG]/Temp/gradleOut/bvr/[GUID].keystore' not found for signing config 'release'.

    I've been trying to locate documentation regarding the signing process, without any luck. Is there any additional steps required to enable signing of Android applications?
     
    dan_ginovker likes this.
  2. Geshdo_Pierre

    Geshdo_Pierre

    Joined:
    Mar 16, 2019
    Posts:
    2
    Solved by downgrading the the Unity Version from Latest 2019.1 BETA to Latest 2018.3
     
  3. MagnoliaStudio

    MagnoliaStudio

    Joined:
    Apr 7, 2019
    Posts:
    1
    Hi. I'm having the some issue with 2019.1 but I would not like to have to downgrade.
    Anyone knows of a workaround ?
    I tried to include the keystone in the project root but it didn't work.
     
    no-luck likes this.
  4. MasoInar

    MasoInar

    Joined:
    Feb 20, 2014
    Posts:
    126
    I'm having exact same problem with 2019.1.0f1 version. Local build works fine though..
     
  5. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    315
    I'm not convinced it's 2019.1 as opposed to something I'm doing wrong.

    Does anyone have any diagnostic steps they've developed for this sort of problem?
     
  6. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    315
    Just on the off chance this really is a bug, I filed one.
     
  7. softone

    softone

    Joined:
    Oct 25, 2013
    Posts:
    8
    I'm having the same issue with 2019.1.0f2 cloud builds. Last week it worked fine with 2018.3.
     
  8. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    Can you please share the case number here? Thank you!
     
  9. stijnvdbmgsp

    stijnvdbmgsp

    Joined:
    Feb 6, 2017
    Posts:
    6
    Hello,

    we're having this same issue with local builds after updating to Unity 2019.1.0f2 (we were on 2018.3.6f1 previously).
    Just submitted the bug report, that case number is 1147233
     
  10. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    315
    Yes. It's 652241. So now you can all see the self-effacing way I engage a product support team. :)
     
    Maxigator likes this.
  11. victorw

    victorw

    Joined:
    Sep 14, 2016
    Posts:
    459
    So we've been having a really "fun" time trying to replicate this issue. At the moment, my working theory is that this bug only happens when there are three factors present:
    • Builds are building on Android in 2019.1.
    • Builds are using Cloud Diagnostics.
    • Some third issue that we have yet to identify.
    From investigation everyone we have found with this issue has also been experiencing the Cloud Diagnostics issue
    Please provide an auth token with USYM_UPLOAD_AUTH_TOKEN environment variable"
    . This error seems to appear shortly before the build failure. We're currently tracking down how exactly to replicate and how to avoid this issue. However, our replications of this issue have not been sufficient to cause the keystore issue, so it's either an unrelated issue or there's a fourth factor that is also necessary to create this failure.

    Conclusion/TL;DR: To help us diagnose, it would be great if you could try disabling Cloud Diagnostics on your failing projects, running a cloud build and then reporting back whether anything changed as a result.
     
  12. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    315
    I'll do that in a few hours if nobody else gets to it before me.

    Edit: I started one. Do you need me to DM you a link or something?
     
  13. MasoInar

    MasoInar

    Joined:
    Feb 20, 2014
    Posts:
    126
    Disabling Cloud Diagnostics didn't help.. Still the same error:
    > Keystore file '/BUILD_PATH/[APP-NAME].default-android/Temp/gradleOut/bvr/fee0ead1-be61-4298-b18a-c68fef6ea4d0.keystore' not found for signing config 'release'.
     
    MaxGuernseyIII likes this.
  14. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    315
    I'm going to try disabling all services, now.
     
  15. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    315
    Here's an interesting ending to that build...

    Code (csharp):
    1.  
    2. 44: [Unity] UnityEngine.Debug:LogWarning(Object)
    3. 45: [Unity] UnityEditor.Android.AndroidSDKTools:detectErrorsAndWarnings(String, String)
    4. 46: [Unity] Assets/PygmyMonkey/ColorPalette/Runtime/Importers/WebsiteImporters/DribbbleWebsiteImporter.cs(16,4): warning CS0618: 'WWW' is obsolete: 'Use UnityWebRequest, a fully featured replacement which is more efficient and has additional features'
    5. 47: [Unity] Assets/PygmyMonkey/ColorPalette/Runtime/Importers/WebsiteImporters/DribbbleWebsiteImporter.cs(16,18): warning CS0618: 'WWW' is obsolete: 'Use UnityWebRequest, a fully featured replacement which is more efficient and has additional features'
    6. 48: [Unity] Assets/Plugins/UnityPurchasing/script/PurchasingCheck.cs(2,10): warning CS1030: #warning: '"Unity IAP plugin is installed, but Unity IAP is not enabled. Please enable Unity IAP in the Services window."'
    7. 49: [Unity] Library/PackageCache/com.unity.cinemachine@2.3.3/Runtime/Behaviours/CinemachineCollider.cs(174,34): warning CS0649: Field 'CinemachineCollider.VcamExtraState.debugResolutionPath' is never assigned to, and will always have its default value null
    8. 50: [Unity] ERROR: Type '[]UnityEngine.Purchasing.ProductCatalogItem' has an extra field 'type' of type 'UnityEngine.Purchasing.ProductType' in the player and thus can't be serialized  (expected 'storeIDs' of type 'System.Collections.Generic.List`1[UnityEngine.Purchasing.StoreID]')
    9. 51: [Unity] ERROR: Fields serialized in Editor, class 'UnityEngine.Purchasing.ProductCatalogItem'
    10. 52: [Unity] ERROR: Fields serialized in target platform, class 'UnityEngine.Purchasing.ProductCatalogItem'
    11. 53: [Unity] ERROR: Error building player because script class layout is incompatible between the editor and the player.
    12. 54: [Unity] Error building player because script class layout is incompatible between the editor and the player.
    13. 55: [Unity] Player export failed. Reason: Library/PackageCache/com.unity.cinemachine@2.3.3/Runtime/Behaviours/CinemachineCollider.cs(174,34): warning CS0649: Field 'CinemachineCollider.VcamExtraState.debugResolutionPath' is never assigned to, and will always have its default value null
    14. 56: publishing finished successfully.
    15.  
     
    Last edited: Apr 20, 2019
  16. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    315
    victorw likes this.
  17. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    315
    In addition to disabling cloud diagnostics having no effect, I also cannot find that error anywhere in the full logs. In fact, I cannot find the string "TOK" anywhere in there. I'd like to know what the builds that work do to make sure that temporary keystore file is generated...
     
    victorw likes this.
  18. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    315
    Like, is there an event I can just hook into to copy my .keystore where it needs to be?
     
  19. MasoInar

    MasoInar

    Joined:
    Feb 20, 2014
    Posts:
    126
    Another project, that I converted from 2018 to 2019 fails also. The error is related to IAP though:
    13: [Unity] Assets/Plugins/UnityPurchasing/script/IAPConfigurationHelper.cs(12,91): error CS0246: The type or namespace name 'ProductCatalog' could not be found (are you missing a using directive or an assembly reference?)
    14: [Unity] Assets/Plugins/UnityPurchasing/script/CodelessIAPStoreListener.cs(21,19): error CS0246: The type or namespace name 'ProductCatalog' could not be found (are you missing a using directive or an assembly reference?)

    And as always, local builds works fine..
     
  20. MasoInar

    MasoInar

    Joined:
    Feb 20, 2014
    Posts:
    126
    I solved that problem. gitignore file was configured incorrectly to not include bin folder.. Anyways, now I got same error than in other project:

    > Keystore file '/BUILD_PATH/[APP_NAME].default-android/Temp/gradleOut/bvr/855150c4-6148-4c7b-bd87-d9ff35b067b4.keystore' not found for signing config 'release'.
     
  21. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    315
    I spent about an hour banging my head against the pre-export event, figuring out that the answer must be "no". I can't seem to find anywhere that tells me where the keystore file is supposed to be, so I can't copy it there. I can't seem to find anywhere that lets me tell the build which keystore to use, so I can't aim the build at where it is.

    Anyone else have any ideas?
     
  22. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    315
  23. brockman

    brockman

    Joined:
    Aug 20, 2018
    Posts:
    1
    Same problem here, no solution found.

    Also noticed that if you configure Unity to use the default debug keystore, and add another keystore in cloud build settings and configure the cloud build target to use that, then the build succeeds, but is signed with the wrong (debug) keystore. This happened after upgrading our project to 2019.1. Previous 2018.x version worked fine.
     
    MaxGuernseyIII and victorw like this.
  24. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    315
    :(
     
  25. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    315
    That's an interesting bit of data.
     
  26. victorw

    victorw

    Joined:
    Sep 14, 2016
    Posts:
    459
    Thanks for mentioning this, this explained why we were having a hard time replicating this behavior - 2019.1 has an extra flag for debug vs release keystore which wasn't being overwritten by UCB. Should be easy enough to fix this up so that it consistently uses the correct keystore as defined in UCB, unfortunately that probably won't fix the underlying issue of the missing keystore files. Eliminating the confusion around what makes the issue happen is a big help though.
     
    MaxGuernseyIII likes this.
  27. MatL

    MatL

    Joined:
    Jan 29, 2014
    Posts:
    43
    Having same issue with with 2019.1.0f2
     
  28. victorw

    victorw

    Joined:
    Sep 14, 2016
    Posts:
    459
    I was able to track down the underlying issue and have just deployed the fix - this should now be resolved! Let me know if you see anything unexpected happening in Android builds.
     
    MasoInar likes this.
  29. MatL

    MatL

    Joined:
    Jan 29, 2014
    Posts:
    43
    Worked thanks for the quick fix!!
     
  30. MasoInar

    MasoInar

    Joined:
    Feb 20, 2014
    Posts:
    126
  31. MaxGuernseyIII

    MaxGuernseyIII

    Joined:
    Aug 23, 2015
    Posts:
    315
    Yep. Build works. Thanks for fixing it.
     
  32. stijnvdbmgsp

    stijnvdbmgsp

    Joined:
    Feb 6, 2017
    Posts:
    6
    Was this fix only for Unity Cloud Builds by any chance? In our case Android builds are failing locally, this is still happening with latest version of Unity (as far as I can tell no updates/patches have been made anyway)
     
  33. MasoInar

    MasoInar

    Joined:
    Feb 20, 2014
    Posts:
    126
    I never had this issue on local builds. Do you have that exact same error (keystore not found) on local build?
     
  34. stijnvdbmgsp

    stijnvdbmgsp

    Joined:
    Feb 6, 2017
    Posts:
    6
    Yes - I've just sent them another bug report reproducing the issue in a blank project (case #1150462 ).
    You get this error when setting signing assets through script (in a pre-build function, for example) - I'm guessing Unity Cloud builds do the exact same thing under the hood.

    Steps to reproduce:
    - Create a blank project
    - Create a keystore and set it in player settings
    - Drop this editor script in the project:
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3. using UnityEditor.Build;
    4. using UnityEditor.Build.Reporting;
    5.  
    6. public class SetKeystore : IPreprocessBuildWithReport
    7. {
    8.     public int callbackOrder {  get { return 0; } }
    9.  
    10.     void IPreprocessBuildWithReport.OnPreprocessBuild(BuildReport report)
    11.     {
    12.         UnityEditor.PlayerSettings.Android.keystoreName = "Path/to/test.keystore";
    13.         UnityEditor.PlayerSettings.Android.keystorePass = "123456";
    14.         UnityEditor.PlayerSettings.Android.keyaliasName = "test";
    15.         UnityEditor.PlayerSettings.Android.keyaliasPass = "123456";
    16.     }
    17. }
    18.  
    - Build

    the error only happens in 2019.1.0f2 - I've tested with 2018.3.12f1 and it worked fine.
     
  35. victorw

    victorw

    Joined:
    Sep 14, 2016
    Posts:
    459
    Yeah that's very similar code to what we run in cloud build so you'll be experiencing the same issue. First there's an API change - you have to ensure that the new
    PlayerSettings.Android.useCustomKeystore
    is set to true, otherwise it may use a debug keystore. Then there's a bug -
    PlayerSettings.Android.keystoreName
    does not support relative paths anymore in 2019.1. I have reported this bug and hopefully we'll see it fixed in a later release but for the moment you will have to switch to using absolute paths for your keystore name.
     
  36. habitoti

    habitoti

    Joined:
    Feb 28, 2013
    Posts:
    141
    How would I enter the absolute path? I can only browse to the keystore via fileselector, and it's then converted to a relative path implicitly.
     
  37. victorw

    victorw

    Joined:
    Sep 14, 2016
    Posts:
    459
    It should work just fine if you're using a file selector, what I said only applies to configuring the keystore programmatically. If you're running into issues setting the keystore using the Unity Editor UI then I'd suggest ensuring that you're running 2019.1 locally and reporting it as a bug in the editor if the bug persists (via Help -> Report a Bug...)
     
  38. habitoti

    habitoti

    Joined:
    Feb 28, 2013
    Posts:
    141
    I had to copy the keystore to a place outside the project hierarchy. Then choosing it via fileselector produced a full qualified path and the build ran through fine. Within the hierarchy it was always stripped to a relative path (which usually makes sense, of course)
     
    GarthSmith and ROONTAMS like this.
  39. unity_cN_8G3BkMlp_Wg

    unity_cN_8G3BkMlp_Wg

    Joined:
    Jun 12, 2018
    Posts:
    1
    Thanks Habitoti! I had the same problem, all local build, not cloud.

    After upgrading to 2019.1.5f1, I got the "keystone file not found" in some Temp directory. I managed to fix this by entering a full path outside the project in Build Settings -> Player Settings -> Project Keystore
     
  40. JunaidGhani

    JunaidGhani

    Joined:
    Nov 14, 2017
    Posts:
    4
    local build: I run into this don't know if it will work for someone else..
    using the same keystore and keystore path: https://ibb.co/SVJmfsJ

    i.e one can see in the image attached that Keystore path is already defined, i still redifined it by clicking on browse keystore.

    A bit awkward i know...
     
  41. ROONTAMS

    ROONTAMS

    Joined:
    Jul 6, 2017
    Posts:
    2
    Thanks..!! I solved it !
     
    GarthSmith likes this.
  42. StacticKoud

    StacticKoud

    Joined:
    Nov 29, 2018
    Posts:
    8
    We were using relative paths for our build scripts and solved the problem by using Path.GetFullPath() method.
    Code (CSharp):
    1. PlayerSettings.Android.keystoreName = relativePath;
    2. -->
    3. PlayerSettings.Android.keystoreName = Path.GetFullPath(relativePath);
     
    ThisGuise likes this.
  43. Jahidulh

    Jahidulh

    Joined:
    Jul 26, 2018
    Posts:
    3
    It's work
     

    Attached Files:

  44. michaeldobele

    michaeldobele

    Joined:
    Oct 25, 2016
    Posts:
    10
    Thanks for this info, I've been trying to setup a Jenkins System to automate our builds and had been struggling to figure out why my Android release builds were failing! This thread and the full path to keystore solution got it working on my Unity 2019.1.14f1 setup.
     
    ThisGuise likes this.
  45. Wang_Sichun

    Wang_Sichun

    Joined:
    Oct 11, 2016
    Posts:
    2
    I solved this by re-selecting the .keystore file again. After that, the ProjectSettings.asset file changed one line.

    from:
    AndroidKeystoreName: Assets/Keystore.keystore
    To:
    AndroidKeystoreName: '{inproject}: Assets/Keystore.keystore'

    I guess in Unity 2018 the Project setting writes only the path of the .keystore file. After 2019 it added a '{inproject}: to mark the .keystore file is in the project. In some way or other, my unity updated without modifying the ProjectSettings.asset file which caused this issue.