Search Unity

Job failed with exception: System.Reflection.TargetInvocationException Unity Error

Discussion in 'Android' started by ArielDeveloper2, Jun 11, 2022.

  1. ArielDeveloper2

    ArielDeveloper2

    Joined:
    Dec 27, 2021
    Posts:
    7
    I recently got this error:
    Job failed with exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Insecure connection not allowed
    and this warning with it:
    Non-secure network connections disabled in Player Settings

    This happens anytime I run the game build to android, force resolve, etc..

    I am using Unity 2022.1.0b2 and have never gotten this error before.

    I have been stuck on this problem for days now and cant find this fix, before that I got a message saying too many error when i build to android but i luckily found a fix by deleting the Plugins folder because it will be created again.

    I use firebase database and authentication which when i build to android and put on google play the firebase just doesn't work and shows nothing (no leader-board and no sign-in/sign-up).
    In the unity editor the firebase stuff works and is fine just not in the build.

    I also use Unity ADS and Unity IAP, both work after build and in editor.
     
  2. ArielDeveloper2

    ArielDeveloper2

    Joined:
    Dec 27, 2021
    Posts:
    7
    I just fixed this problem. It turned out to be in my code where I forgot to use Firebase.FirebaseApp.Create(). I hope this helps someone who gets this same problem.
     
  3. oyunbus

    oyunbus

    Joined:
    Aug 31, 2017
    Posts:
    1
    sorunu bulan varmı
     
  4. ALEKS_YT

    ALEKS_YT

    Joined:
    Nov 20, 2018
    Posts:
    4
    Where should I put that?
     
  5. ArielDeveloper2

    ArielDeveloper2

    Joined:
    Dec 27, 2021
    Posts:
    7
    Just put it in the beginning of the Start function eg.
    void Start() {
    Firebase.FirebaseApp.Create();
    // Your other Start code if you have:

    }
     
    kove2727 likes this.
  6. unity_9F24F13F439C10B39DAA

    unity_9F24F13F439C10B39DAA

    Joined:
    Sep 10, 2021
    Posts:
    1
    this din't Work for me
     
  7. ArielDeveloper2

    ArielDeveloper2

    Joined:
    Dec 27, 2021
    Posts:
    7
    I don't know why, but the message still appears to me even after the Create() function. It seems like the Create() only fixed it for a month. I'll try force resolving again.
     
  8. Roman_34

    Roman_34

    Joined:
    Nov 1, 2018
    Posts:
    19
    I switched to the new version of Unity - 2022.1.22 and started getting this error in the console:

    Job failed with exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Insecure connection not allowed

    at (wrapper managed-to-native) UnityEngine.Networking.UnityWebRequest.BeginWebRequest(UnityEngine.Networking.UnityWebRequest)

    at UnityEngine.Networking.UnityWebRequest.SendWebRequest () [0x00001] in <e0fcda41755546dbb665cb70c72ace16>:0

    at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)

    at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <3dd5df5ef4974f29afeb2d3ba227c5da>:0

    --- End of inner exception stack trace ---

    at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00083] in <3dd5df5ef4974f29afeb2d3ba227c5da>:0

    at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <3dd5df5ef4974f29afeb2d3ba227c5da>:0

    at Google.PortableWebRequest.StartRequest (Google.PortableWebRequest+HttpMethod method, System.String url, System.Collections.Generic.IDictionary`2[TKey,TValue] headers, UnityEngine.WWWForm form) [0x0019e] in /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/PortableWebRequest.cs:508

    at Google.PortableWebRequest+<StartRequestOnMainThread>c__AnonStorey6.<>m__C () [0x00000] in /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/PortableWebRequest.cs:458

    at Google.RunOnMainThread.ExecuteNext () [0x0003d] in /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:486 (at ?)
    UnityEngine.Debug:LogError (object) (at ?)
    Google.RunOnMainThread:ExecuteNext () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:488)
    Google.RunOnMainThread:<ExecuteAllUnnested>m__12 () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:536)
    Google.RunOnMainThread:RunAction (System.Action) (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:343)
    Google.RunOnMainThread:ExecuteAllUnnested (bool) (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:530)
    Google.RunOnMainThread:ExecuteAll () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:512) (at ?)
    UnityEditor.EditorApplication:Internal_CallUpdateFunctions () (at ?)


    Has anyone solved this problem?
     
  9. Roman_34

    Roman_34

    Joined:
    Nov 1, 2018
    Posts:
    19
    Solved this by (Workaround): Edit -> Project Settings -> Player -> Other Settings -> Configuration -> Allow downloads over HTTP
    set "Always allowed"...
     
  10. flintcheeze

    flintcheeze

    Joined:
    Sep 10, 2015
    Posts:
    80
    This didn’t work for me
     
  11. muhit123

    muhit123

    Joined:
    Nov 26, 2021
    Posts:
    1
    Thanks!
    It worked for me.
     
    EmilGlz and akshaypro02 like this.
  12. liuktem

    liuktem

    Joined:
    Nov 5, 2022
    Posts:
    1
    Thanks!
     
    EmilGlz and akshaypro02 like this.
  13. enzoravo

    enzoravo

    Joined:
    Jun 25, 2013
    Posts:
    284
    thanks, worked at my end too!
     
    fdasfsa and EmilGlz like this.
  14. tomdou

    tomdou

    Joined:
    Feb 7, 2022
    Posts:
    2
    Worked for me...
     
  15. Abdulkadir_Gur

    Abdulkadir_Gur

    Joined:
    Mar 14, 2022
    Posts:
    2
    Worked for me thanks
     
  16. cihadturhan_unity

    cihadturhan_unity

    Joined:
    Apr 19, 2021
    Posts:
    66
    That worked, thanks!
    Seems like some unity dev forgot to wrap the http get function with a try/catch block :)
     
  17. wokamoka

    wokamoka

    Joined:
    Jul 3, 2012
    Posts:
    10
    I had this issue because after Unity editor crashed, there were remaining processes "Unity.Accelerator" in the list of processes.
    Killing these remaining processes fixed the problem.
    Hope this helps.
     
  18. SirMammoths

    SirMammoths

    Joined:
    Feb 7, 2023
    Posts:
    1
    obrigado funcionou para mim.
     
    afonsooliveira likes this.
  19. VOXELIUM

    VOXELIUM

    Joined:
    Nov 24, 2022
    Posts:
    49
    I got this error too
    Solved this by
    Edit -> Project Settings -> Player -> Other Settings -> Configuration -> Allow downloads over HTTP
    set "Allowed in development builds"
     
  20. JawadHassan

    JawadHassan

    Joined:
    Jan 7, 2022
    Posts:
    1
    IT WORKED, THANKS ^_^
     
    neokortex likes this.
  21. Virender

    Virender

    Joined:
    Aug 7, 2015
    Posts:
    1
    it worked thanks
     
  22. veAaryanom

    veAaryanom

    Joined:
    Feb 17, 2024
    Posts:
    1
    Man Man Man
    This really helped bro
    Thanks a lot