Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Field currentActivity or type signature not found Error in Player Unity 2020.1

Discussion in 'Scripting' started by mrjaimez, Aug 11, 2020.

  1. mrjaimez

    mrjaimez

    Joined:
    Aug 11, 2020
    Posts:
    1
    Hi All!
    I'm facing the error: Exception: Field currentActivity or type signature not found When i try to play the Start Scene on Player.
    Platform Android
    The only object is a Button that calls Signin with Google.
    There are no errors on compilation, but when try to run the test on player shows the described error.

    As per i saw on others posts, there is no way to play the APP on the player. Is this true? have to deploy and tes on a devica each change that i make to the app?

    Hope you can helpme!!!
     
  2. Powerpbk

    Powerpbk

    Joined:
    Jul 1, 2020
    Posts:
    1
    I have the same problem.Have you found the reason?
     
  3. BeorGames

    BeorGames

    Joined:
    Jul 28, 2018
    Posts:
    65
    Hi, I'm facing the same issue, but my app doesn't work at all, it freezes and crashes when I open it. I kind of understood it has something to do with
    UnityEngine.AndroidJNIModule and
    AndroidJavaObject but I've no idea how to solve it, it's driving me mad. I'm trying to use Google Package Asset Delivery, but when it starts loading the package it calls this helper function
    Code (CSharp):
    1. public static class UnityPlayerHelper
    2.     {
    3.         /// <summary>
    4.         /// Gets the current activity running in Unity. This object should be disposed after use.
    5.         /// </summary>
    6.         /// <returns>A wrapped activity object. The AndroidJavaObject should be disposed.</returns>
    7.         public static AndroidJavaObject GetCurrentActivity()
    8.         {
    9.             using (var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
    10.             {
    11.                 return unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
    12.             }
    13.         }
    14.     }
    And I get this huge error:
    Exception: Field currentActivity or type signature not found
    UnityEngine._AndroidJNIHelper.GetFieldID (System.IntPtr jclass, System.String fieldName, System.String signature, System.Boolean isStatic) (at <1b8d7d6285464cff8aa5ccc91decf4f7>:0)
    UnityEngine.AndroidJNIHelper.GetFieldID (System.IntPtr javaClass, System.String fieldName, System.String signature, System.Boolean isStatic) (at <1b8d7d6285464cff8aa5ccc91decf4f7>:0)
    UnityEngine._AndroidJNIHelper.GetFieldID[ReturnType] (System.IntPtr jclass, System.String fieldName, System.Boolean isStatic) (at <1b8d7d6285464cff8aa5ccc91decf4f7>:0)
    UnityEngine.AndroidJNIHelper.GetFieldID[FieldType] (System.IntPtr jclass, System.String fieldName, System.Boolean isStatic) (at <1b8d7d6285464cff8aa5ccc91decf4f7>:0)
    UnityEngine.AndroidJavaObject._GetStatic[FieldType] (System.String fieldName) (at <1b8d7d6285464cff8aa5ccc91decf4f7>:0)
    UnityEngine.AndroidJavaObject.GetStatic[FieldType] (System.String fieldName) (at <1b8d7d6285464cff8aa5ccc91decf4f7>:0)
    Google.Play.Common.UnityPlayerHelper.GetCurrentActivity () (at Assets/GooglePlayPlugins/com.google.play.common/Runtime/Scripts/UnityPlayerHelper.cs:32)
    Google.Play.AssetDelivery.Internal.AssetPackManager..ctor () (at Assets/GooglePlayPlugins/com.google.play.assetdelivery/Runtime/Scripts/Internal/AssetPackManager.cs:33)
    Google.Play.AssetDelivery.Internal.PlayAssetDeliveryInternal..ctor () (at Assets/GooglePlayPlugins/com.google.play.assetdelivery/Runtime/Scripts/Internal/PlayAssetDeliveryInternal.cs:44)
    Google.Play.AssetDelivery.PlayAssetDelivery.get_Instance () (at Assets/GooglePlayPlugins/com.google.play.assetdelivery/Runtime/Scripts/PlayAssetDelivery.cs:32)
    Google.Play.AssetDelivery.PlayAssetDelivery.RetrieveAssetBundleAsync (System.String assetBundleName) (at Assets/GooglePlayPlugins/com.google.play.assetdelivery/Runtime/Scripts/PlayAssetDelivery.cs:57)
     
  4. heiwa-games

    heiwa-games

    Joined:
    Apr 8, 2018
    Posts:
    8
  5. NRebel

    NRebel

    Joined:
    Sep 13, 2019
    Posts:
    2
    Hi All, I'm getting the same error. Has anyone found a solution?
     
  6. unity_6H9mo6XthbhibA

    unity_6H9mo6XthbhibA

    Joined:
    Nov 18, 2020
    Posts:
    2
    The same error guys, HELP
     
  7. rafayhamid7

    rafayhamid7

    Joined:
    Oct 11, 2018
    Posts:
    1
    I get this error while integrating fb ads. Help
     
  8. Whatevers2011

    Whatevers2011

    Joined:
    Jul 12, 2020
    Posts:
    3
    I solved this by reverting changes I had done the day before. I had commented out code to do with initialising google play and it resulted in this error when trying to call in app review.
     
  9. upendraakki329

    upendraakki329

    Joined:
    Sep 21, 2020
    Posts:
    6
    Does anyone got any solution to this i am also getting the same error
     
  10. shawonRokerz

    shawonRokerz

    Joined:
    Jan 10, 2021
    Posts:
    3
    Same error while using the following asset Contact List !!! Any Idea Guys????
     
  11. KaneKennste

    KaneKennste

    Joined:
    Oct 1, 2019
    Posts:
    7
    Hi,
    i had the same issue. Probably most of you could figure out that the AppUpdateManager is causing this error. For me this meant that building android apk was possible, but "build and run" wasn't.
    I used to initialize the AppUpdateManager as member variable like this:
    Code (CSharp):
    1. private AppUpdateManager appUpdateManager = new AppUpdateManager();
    I fixed it by moving it into Awake() and checking for the platform, like this:
    Code (CSharp):
    1. private void Awake()
    2. {
    3.     if (Application.platform == RuntimePlatform.Android)
    4.     {
    5.         this.appUpdateManager = new AppUpdateManager();
    6.     }
    7. }
    Of course, the remaining code that is relying on the AppUpdateManager, also only runs when the platform is Android.

    I hope this will help some of you.
     
    mfatihbarut likes this.
  12. vickychaudhary8955

    vickychaudhary8955

    Joined:
    May 11, 2021
    Posts:
    1
    me tooo brother have you founded the solution of how to resolve it??
     
  13. moneysolutionsxyz

    moneysolutionsxyz

    Joined:
    Jul 17, 2022
    Posts:
    14
    Me too
     
  14. pmitsolution

    pmitsolution

    Joined:
    Aug 17, 2022
    Posts:
    4
    hey bro did you get the solution ????
     
    alecfilios likes this.
  15. pmitsolution

    pmitsolution

    Joined:
    Aug 17, 2022
    Posts:
    4
    if you get the solution ,please post here
     
    alecfilios likes this.
  16. pmitsolution

    pmitsolution

    Joined:
    Aug 17, 2022
    Posts:
    4
    hey ,did you get the solution ??
     
  17. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,576
    This is nothing to do with 2D at all. Moving it to scripting.
     
    Bunny83 likes this.
  18. pmitsolution

    pmitsolution

    Joined:
    Aug 17, 2022
    Posts:
    4
    @MelvMay
    I did not get exact reason for this error . can you help liitle bit
     
  19. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,576
    I'm on the 2D team so unfortunately not. This is why I moved this thread to scripting as it has a higher chance of someone knowing unlike it being on an inappropriate forum. Sorry.
     
    Bunny83 likes this.
  20. Abhoopendra

    Abhoopendra

    Joined:
    Aug 14, 2022
    Posts:
    2
    @MelvMay
    I tried all solution which are available on internet:( . but I did not get any logistic wayo_Oo_O
    Any approach sir @MelvMay

    error is like :
    Exception: Field currentActivity or type signature not found
    UnityEngine._AndroidJNIHelper.GetFieldID (System.IntPtr jclass, System.String fieldName, System.String signature, System.Boolean isStatic) (at <1b8d7d6285464cff8aa5ccc91decf4f7>:0)
    UnityEngine.AndroidJNIHelper.GetFieldID (System.IntPtr javaClass, System.String fieldName, System.String signature, System.Boolean isStatic) (at <1b8d7d6285464cff8aa5ccc91decf4f7>:0)
    UnityEngine._AndroidJNIHelper.GetFieldID[ReturnType] (System.IntPtr jclass, System.String fieldName, System.Boolean isStatic) (at <1b8d7d6285464cff8aa5ccc91decf4f7>:0)
    UnityEngine.AndroidJNIHelper.GetFieldID[FieldType] (System.IntPtr jclass, System.String fieldName, System.Boolean isStatic) (at <1b8d7d6285464cff8aa5ccc91decf4f7>:0)
    UnityEngine.AndroidJavaObject._GetStatic[FieldType] (System.String fieldName) (at <1b8d7d6285464cff8aa5ccc91decf4f7>:0)
    UnityEngine.AndroidJavaObject.GetStatic[FieldType] (System.String fieldName) (at <1b8d7d6285464cff8aa5ccc91decf4f7>:0)
    Google.Play.Common.UnityPlayerHelper.GetCurrentActivity ()
     
  21. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,576
    So you didn't read what I said above I guess. TLDR? ;)
     
    Bunny83 likes this.
  22. Abhoopendra

    Abhoopendra

    Joined:
    Aug 14, 2022
    Posts:
    2
    yes , i read more than 10 times ,but i didn't get your statement " I moved this thread to scripting"
    and why ? you can have from experts who knows. my request is only for reason behind this error and solution .
    i am trying to solve this error from last 10 days and i repeat all steps carefully more than 15 time but i don't know what i am missing. help please :(
     
  23. moneysolutionsxyz

    moneysolutionsxyz

    Joined:
    Jul 17, 2022
    Posts:
    14
    Not yet!
     
  24. redaaitlaarab

    redaaitlaarab

    Joined:
    Dec 22, 2020
    Posts:
    1
  25. RedForceFT

    RedForceFT

    Joined:
    Aug 5, 2019
    Posts:
    19
    solutions?
     
  26. NayLinHtun

    NayLinHtun

    Joined:
    Sep 30, 2019
    Posts:
    3
    solution??
     
  27. VoidX_HUN

    VoidX_HUN

    Joined:
    Apr 20, 2015
    Posts:
    6
    After pulling out my hair, I found the solution. This is Unity's way of telling you you have to run this from the main thread.
     
  28. Ctapik

    Ctapik

    Joined:
    Mar 10, 2023
    Posts:
    1
    what this mean
     
  29. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,748
    Bunny83 likes this.
  30. Razeen_AG

    Razeen_AG

    Joined:
    Aug 5, 2019
    Posts:
    3
    Did you find any solutions yet??
    I have tried multiple things but I still can't find the solution
     
  31. VoidX_HUN

    VoidX_HUN

    Joined:
    Apr 20, 2015
    Posts:
    6
    You have to call it from OnUpdate/OnLateUpdate/etc. For example, calling from OnAudioFilterRead/timers/tasks will cause this issue, because they are different threads.
     
  32. tahirtekatli

    tahirtekatli

    Joined:
    Jan 19, 2024
    Posts:
    1
    Hello everybody,

    It seems that there is no correct answer here but I wanted to share my experience because it was very annoying. I got this error when I try to build an alert dialog screen in unity 2d via java plugin.

    - Please ensure that your script must be like this:

    AndroidJavaClass unityClass;
    AndroidJavaObject unityActivity;
    AndroidJavaObject pluginInstance;

    void Start()
    {
    InitializePlugins("com.example.nativeplugin.PluginClass");
    CreateAlert();
    }

    void InitializePlugins(string pluginName)
    {
    unityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
    unityActivity = unityClass.GetStatic<AndroidJavaObject>("currentActivity");
    pluginInstance = new AndroidJavaObject(pluginName);
    pluginInstance.CallStatic("receiveUnityActivity",unityActivity);
    }

    void CreateAlert()
    {
    pluginInstance.Call("CreateAlert");
    }

    public void ShowAlert()
    {
    pluginInstance.Call("showAlert");
    }

    - Secondly, after the initiliase the script and plugins, YOU HAVE TO RESTART UNİTY ENGİNE (with Load on Startup = unheck, you can found this plugin setting).

    --I don't know but when i restart the unity engine, plugin work correctly. [Unity engine already stated this situation in warning box and said please restart unity]

    - Thirdly, PLEASE DON'T TEST PLUGİNS WİTHOUT CREATİNG APK BUİLD! Again, I don't know why but when i test the plugin with usb cable via unity remote 5 or any android emulator, that didn't matter, ı couldn't succesfull. But, any try creating an apk file and running it on any android device (which need 6.0+) was successful. You still continue get this error in debug.log but it doesn't a problem.

    Hope it's help!
     
  33. migwellian

    migwellian

    Joined:
    Mar 20, 2018
    Posts:
    16
    Sharing my experience in case it helps someone else in the same situation:

    I installed the "Push Notifications" package and started seeing this error when I press play in the Editor. The call stack was coming through `InitializePackageAsync.CoreRegistryInitializer` i.e. not from my own code.

    Looking at the change log for this package, I saw that it was apparently a known issue that got fixed in version 3.0.1-pre.1. For some reason the Unity Package Manager didn't offer me the latest version, and it had installed version 3.0.0-pre.1. To fix the issue I manually edited `manifest.json` to upgrade to latest (4.0.0-pre.1).


    https://docs.unity3d.com/Packages/com.unity.services.push-notifications@4.0/changelog/CHANGELOG.html
     
  34. y01cu

    y01cu

    Joined:
    Oct 10, 2021
    Posts:
    8

    Thanks a lot, this solved my issue too!
     
  35. muhammadfurqan482059

    muhammadfurqan482059

    Joined:
    Mar 3, 2024
    Posts:
    1
    Worst support = Unity Forum. Seems like Unity Technologies is not capable of solving or guiding on how to solve this issue.