Search Unity

DLLs not working on device(Working everywhere else)

Discussion in 'iOS and tvOS' started by Paulo-Henrique025, Apr 13, 2013.

  1. Paulo-Henrique025

    Paulo-Henrique025

    Joined:
    Dec 12, 2010
    Posts:
    230
    HI guys, trying to use Google Docs with my unity3d application, the problem is that it just don't work in iOS! It works on standalone, inside the editor and even works in the iOS Simulator, but if you build it and test on the device, it'll not work.

    The output of the error showed when you try to "login" is the following:

    Code (csharp):
    1. ExecutionEngineException: Attempting to JIT compile method '(wrapper managed-to-native) System.Threading.Interlocked:CompareExchange (Google.GData.Client.ServiceEventHandler,Google.GData.Client.ServiceEventHandler,Google.GData.Client.ServiceEventHandler)' while running with --aot-only.
    2.  
    3.   at Google.GData.Client.Service.add_NewFeed (Google.GData.Client.ServiceEventHandler value) [0x00000] in <filename unknown>:0
    4.   at Google.GData.Spreadsheets.SpreadsheetsService..ctor (System.String applicationName) [0x00000] in <filename unknown>:0
    5.   at FirstTest.SetUp (System.String email, System.String password) [0x00000] in <filename unknown>:0
    6.   at FirstTest.OnGUI () [0x00000] in <filename unknown>:0
    7.  
    8. (Filename:  Line: -1)
    Here is the complete link to the project(9.5mb)
    http://www.mediafire.com/?7388mm9oiq7ki23

    The complete code:

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using Google.GData.Client;
    5. using Google.GData.Extensions;
    6. using Google.GData.Spreadsheets;
    7.  
    8. public class FirstTest : MonoBehaviour {
    9.    
    10.     public List<string> slist = new List<string>();
    11.     public string mail = "";
    12.     public string pass = "";
    13.     void OnGUI()
    14.     {  
    15.         GUILayout.BeginHorizontal();
    16.         GUILayout.Label("email: ");
    17.         mail = GUILayout.TextArea(mail, GUILayout.Width(300));
    18.         GUILayout.EndHorizontal();
    19.  
    20.         GUILayout.Space(30);
    21.  
    22.         GUILayout.BeginHorizontal();
    23.         GUILayout.Label("pass: ");
    24.         pass = GUILayout.TextArea(pass, GUILayout.Width(300));
    25.         GUILayout.EndHorizontal();
    26.  
    27.         if(GUILayout.Button("Login"))
    28.         {
    29.             SetUp (mail, pass);
    30.         }
    31.  
    32.         // Draw all spreadsheets
    33.         PrintAllSpreadSheets();
    34.     }
    35.  
    36.     public void SetUp(string email, string password)
    37.     {
    38.         // Connect to GDocs
    39.         SpreadsheetsService myService = new SpreadsheetsService("exampleCo-exampleApp-1");
    40.         myService.setUserCredentials(email, password);
    41.  
    42.         Debug.Log("Should be Connected");
    43.  
    44.         // Query for spreadsheets
    45.         SpreadsheetQuery query = new SpreadsheetQuery();
    46.         SpreadsheetFeed feed = myService.Query(query);
    47.        
    48.         Debug.Log("Your spreadsheets:");
    49.         foreach (SpreadsheetEntry entry in feed.Entries)
    50.         {
    51.             Debug.Log(entry.Title.Text);
    52.             slist.Add(entry.Title.Text);
    53.         }
    54.     }
    55.  
    56.     public void PrintAllSpreadSheets()
    57.     {
    58.         GUILayout.BeginVertical();
    59.         foreach (string item in slist)
    60.         {
    61.             GUILayout.Label(item);
    62.         }
    63.         GUILayout.EndVertical();
    64.     }
    65.  
    66. }
    67.  
     
    Last edited: Apr 13, 2013
  2. karljj1

    karljj1

    Joined:
    Feb 17, 2011
    Posts:
    440
    It looks like the dll is a native dll. I.e it was written in c or C++. You would need to compile the dll for ios or get one already compiled for you.

    K
     
  3. tomguinther

    tomguinther

    Joined:
    Jul 25, 2012
    Posts:
    5
    The problem is that the JIT compiler is being invoked on iOS which is illegal. Unity applications for iOS use the Mono AOT compiler, where AOT means 'Ahead of time' so that the JIT compiler is not needed.

    All issues I have ever seen with InterlockedExchange results from use of an external .NET assembly referenced from C# Unity Script that uses events without explicitly defining add/remove members.

    For example:

    public event EventHandler<EventArgs> MyEvent ;

    Instead you need the event coded as follows:

    private EventHandler<EventArgs> myEventListeners ;

    public event EventHandler<EventArgs> MyEvent {
    add {
    myEventListeners += value ;
    }

    remove {
    myEventListners -=value ;
    }
    }

    If you do not have the source for the assembly you are mostly out-of-luck.

    There are a variety of reasons that the AOT compiler did not handle this, all beyond the scope of this thread.
     
  4. Paulo-Henrique025

    Paulo-Henrique025

    Joined:
    Dec 12, 2010
    Posts:
    230
    The DLLs were compiled by myself using MonoDevelop, the only one I didn't compiled was one that was missing in the Google API project, some JSON library called Newtonsoft.Json.dll, I've picked the mobile version of this DLL, do you think that compiling it by myself can solve the problem?

    Also, inside unity the API compatibility level must be set to .Net 2.0, if not the AOT compilation in the final build step(inside unity) will fail.
     
  5. tomguinther

    tomguinther

    Joined:
    Jul 25, 2012
    Posts:
    5
    As long as you change the event declaration(s) as I suggested it should work. You are using code that requires a "fuller" version of .NET than the 'Subset' If that is an issue, you need to take a hard look at your dependencies and see if you can eliminate some of them.