Support Center

Android :: Troubleshooting

  • Offline Activation

    If you're unable to activate Mono for Android on Windows, or unable to install the full version of Mono for Android on Mac OS X, please see the Offline Activation page.

  • Android Debug Logs

    The Android Debug Logs may provide additional context regarding any runtime errors you're seeing.

  • Could not locate Android SDK

    There are 2 downloads available from Google for the Android SDK for Windows.  If you choose the .exe installer, it will write registry keys that tell MonoDroid where it was installed.  If you choose the .zip file and unzip it yourself, MonoDroid does not know where to look for the SDK.  You can tell MonoDroid where the SDK is in Visual Studio by going to Tools -> Options -> MonoDroid:

    tools-options.png

  • IDE does not display target device

    Sometimes you will attempt to deploy your application to a device, but the device you want to deploy to isn't shown in the Select Device dialog. This can happen when the Android Debug Bridge decides to go on vacation.

    To diagnose this issue, find the adb program, then run:

    adb devices


    If your device isn't present, then you need to restart the Android Debug Bridge server so that your device can be found:

    adb kill-server
    adb start-server
    

    HTC Sync software may prevent `adb start-server` from working properly. If the `adb start-server` command doesn't print out which port it's starting on, please exit the HTC Sync software and try restarting the adb server.

  • The specified task executable "keytool" could not be run

    This means that your PATH does not contain the directory where the Java SDK's bin directory is located.   Check that you followed those steps from the Installation guide.

  • There is not enough storage space on the device to deploy the package

    This occurs when you don't start the emulator from within Visual Studio. When starting the emulator outside of Visual Studio, you need to pass the -partition-size 512 options, e.g.

    emulator -partition-size 512 -avd MonoDroid

    Ensure you use the correct simulator name, i.e. the name you used when configuring the simulator.

  • Unexpected NullReferenceExceptions

    Occasionally the Android Debug Log will mention NullReferenceExceptions that "cannot happen," or come from Mono for Android runtime code shortly before the app dies:

    E/mono(15202): Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object
    E/mono(15202):   at Java.Lang.Object.GetObject (IntPtr handle, System.Type type, Boolean owned) [0x00000] in <filename unknown="">:0 
    E/mono(15202):   at Java.Lang.Object._GetObject[IOnTouchListener] (IntPtr handle, Boolean owned) [0x00000] in <filename unknown="">:0 
    E/mono(15202):   at Java.Lang.Object.GetObject[IOnTouchListener] (IntPtr handle, Boolean owned) [0x00000] in <filename unknown="">:0 
    E/mono(15202):   at Android.Views.View+IOnTouchListenerAdapter.n_OnTouch_Landroid_view_View_Landroid_view_MotionEvent_(IntPtr jnienv, IntPtr native__this, IntPtr native_v, IntPtr native_e) [0x00000] in <filename unknown="">:0 
    E/mono(15202):   at (wrapper dynamic-method) object:b039cbb0-15e9-4f47-87ce-442060701362 (intptr,intptr,intptr,intptr)</filename></filename></filename></filename>

    This can happen when the process runs out of global references, commonly referred to as GREFs. Dalvik's JNI layer only supports a certain number of JNI object references to be valid at any given point in time. When this limit is exceeded, things break.

    The GREF limit is 2000 references in the emulator, and ~52000 references on hardware.

    You know you're starting to create too many GREFs when you see messages such as this in the Android Debug Log:

    D/dalvikvm(  602): GREF has increased to 1801

    When you reach the GREF limit, a message such as the following is printed:

    D/dalvikvm(  602): GREF has increased to 2001
    W/dalvikvm(  602): Last 10 entries in JNI global reference table:
    W/dalvikvm(  602):  1991: 0x4057eff8 cls=Landroid/graphics/Point; (20 bytes)
    W/dalvikvm(  602):  1992: 0x4057f010 cls=Landroid/graphics/Point; (28 bytes)
    W/dalvikvm(  602):  1993: 0x40698e70 cls=Landroid/graphics/Point; (20 bytes)
    W/dalvikvm(  602):  1994: 0x40698e88 cls=Landroid/graphics/Point; (20 bytes)
    W/dalvikvm(  602):  1995: 0x40698ea0 cls=Landroid/graphics/Point; (28 bytes)
    W/dalvikvm(  602):  1996: 0x406981f0 cls=Landroid/graphics/Point; (20 bytes)
    W/dalvikvm(  602):  1997: 0x40698208 cls=Landroid/graphics/Point; (20 bytes)
    W/dalvikvm(  602):  1998: 0x40698220 cls=Landroid/graphics/Point; (28 bytes)
    W/dalvikvm(  602):  1999: 0x406956a8 cls=Landroid/graphics/Point; (20 bytes)
    W/dalvikvm(  602):  2000: 0x406956c0 cls=Landroid/graphics/Point; (20 bytes)
    W/dalvikvm(  602): JNI global reference table summary (2001 entries):
    W/dalvikvm(  602):    51 of Ljava/lang/Class; 164B (41 unique)
    W/dalvikvm(  602):    46 of Ljava/lang/Class; 188B (17 unique)
    W/dalvikvm(  602):     6 of Ljava/lang/Class; 212B (6 unique)
    W/dalvikvm(  602):    11 of Ljava/lang/Class; 236B (7 unique)
    W/dalvikvm(  602):     3 of Ljava/lang/Class; 260B (3 unique)
    W/dalvikvm(  602):     4 of Ljava/lang/Class; 284B (2 unique)
    W/dalvikvm(  602):     8 of Ljava/lang/Class; 308B (6 unique)
    W/dalvikvm(  602):     1 of Ljava/lang/Class; 316B
    W/dalvikvm(  602):     4 of Ljava/lang/Class; 332B (3 unique)
    W/dalvikvm(  602):     1 of Ljava/lang/Class; 356B
    W/dalvikvm(  602):     2 of Ljava/lang/Class; 380B (1 unique)
    W/dalvikvm(  602):     1 of Ljava/lang/Class; 428B
    W/dalvikvm(  602):     1 of Ljava/lang/Class; 452B
    W/dalvikvm(  602):     1 of Ljava/lang/Class; 476B
    W/dalvikvm(  602):     2 of Ljava/lang/Class; 500B (1 unique)
    W/dalvikvm(  602):     1 of Ljava/lang/Class; 548B
    W/dalvikvm(  602):     1 of Ljava/lang/Class; 572B
    W/dalvikvm(  602):     2 of Ljava/lang/Class; 596B (2 unique)
    W/dalvikvm(  602):     1 of Ljava/lang/Class; 692B
    W/dalvikvm(  602):     1 of Ljava/lang/Class; 956B
    W/dalvikvm(  602):     1 of Ljava/lang/Class; 1004B
    W/dalvikvm(  602):     1 of Ljava/lang/Class; 1148B
    W/dalvikvm(  602):     2 of Ljava/lang/Class; 1172B (1 unique)
    W/dalvikvm(  602):     1 of Ljava/lang/Class; 1316B
    W/dalvikvm(  602):     1 of Ljava/lang/Class; 3428B
    W/dalvikvm(  602):     1 of Ljava/lang/Class; 3452B
    W/dalvikvm(  602):     1 of Ljava/lang/String; 28B
    W/dalvikvm(  602):     2 of Ldalvik/system/VMRuntime; 12B (1 unique)
    W/dalvikvm(  602):    10 of Ljava/lang/ref/WeakReference; 28B (10 unique)
    W/dalvikvm(  602):     1 of Ldalvik/system/PathClassLoader; 44B
    W/dalvikvm(  602):  1553 of Landroid/graphics/Point; 20B (1553 unique)
    W/dalvikvm(  602):   261 of Landroid/graphics/Point; 28B (261 unique)
    W/dalvikvm(  602):     1 of Landroid/view/MotionEvent; 100B
    W/dalvikvm(  602):     1 of Landroid/app/ActivityThread$ApplicationThread; 28B
    W/dalvikvm(  602):     1 of Landroid/content/ContentProvider$Transport; 28B
    W/dalvikvm(  602):     1 of Landroid/view/Surface$CompatibleCanvas; 44B
    W/dalvikvm(  602):     1 of Landroid/view/inputmethod/InputMethodManager$ControlledInputConnectionWrapper; 36B
    W/dalvikvm(  602):     1 of Landroid/view/ViewRoot$1; 12B
    W/dalvikvm(  602):     1 of Landroid/view/ViewRoot$W; 28B
    W/dalvikvm(  602):     1 of Landroid/view/inputmethod/InputMethodManager$1; 28B
    W/dalvikvm(  602):     1 of Landroid/view/accessibility/AccessibilityManager$1; 28B
    W/dalvikvm(  602):     1 of Landroid/widget/LinearLayout$LayoutParams; 44B
    W/dalvikvm(  602):     1 of Landroid/widget/LinearLayout; 332B
    W/dalvikvm(  602):     2 of Lorg/apache/harmony/xnet/provider/jsse/TrustManagerImpl; 28B (1 unique)
    W/dalvikvm(  602):     1 of Landroid/view/SurfaceView$MyWindow; 36B
    W/dalvikvm(  602):     1 of Ltouchtest/RenderThread; 92B
    W/dalvikvm(  602):     1 of Landroid/view/SurfaceView$3; 12B
    W/dalvikvm(  602):     1 of Ltouchtest/DrawingView; 412B
    W/dalvikvm(  602):     1 of Ltouchtest/Activity1; 180B
    W/dalvikvm(  602): Memory held directly by tracked refs is 75624 bytes
    E/dalvikvm(  602): Excessive JNI global references (2001)
    E/dalvikvm(  602): VM aborting

    In the above example (which, incidentally, comes from bug 685215) the problem is that too many Android.Graphics.Point instances are being created; see comment #2 for a list of fixes for this particular bug.

    Typically, a useful solution is to find which type has too many instances allocated -- Android.Graphics.Point in the above dump -- then find where they're created in your source code and dispose of them appropriately (so that their Java-object lifetime is shortened). This is not always appropriate (#685215 is multithreaded, so the trivial solution avoids the Dispose call), but it's the first thing to consider.

  • monodroid.exe or aresgen.exe exited with code 1

    To help you debug this problem, go into Visual Studio and change the MSBuild verbosity level, to do this, select: Tools->Options->Project and Solutions->Build and Run->MSBuild Project Build Output Verbosity and set this value to Normal.