Troubleshooting

How to resolve a “NoClassDefFoundError org/apache/http/HttpHost” error?

2021-04-27 19:11:23.145 13751-13967/? E/AndroidRuntime: FATAL EXCEPTION: pool-4-thread-1
    Process: com.teramoto.microvpnbrowser.test1, PID: 13751
    java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/HttpHost;
        at com.citrix.mvpn.MAM.Android.AuthSSO.d.d.<init>(Unknown Source:9)
        at com.citrix.mvpn.MAM.Android.AuthSSO.d.d.a(Unknown Source:19)
        at com.citrix.mvpn.MAM.Android.AuthSSO.proxy.Helper.b(Unknown Source:70)
        at com.citrix.mvpn.MAM.Android.AuthSSO.proxy.Helper.a(Unknown Source:58)
        at com.citrix.mvpn.helper.b.a(Unknown Source:21)
        at com.citrix.mvpn.service.MITMService$b.run(Unknown Source:55)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:923)
    Caused by: java.lang.ClassNotFoundException: org.apache.http.HttpHost
        at com.citrix.mvpn.MAM.Android.AuthSSO.d.d.<init>(Unknown Source:9) 
        at com.citrix.mvpn.MAM.Android.AuthSSO.d.d.a(Unknown Source:19) 
        at com.citrix.mvpn.MAM.Android.AuthSSO.proxy.Helper.b(Unknown Source:70) 
        at com.citrix.mvpn.MAM.Android.AuthSSO.proxy.Helper.a(Unknown Source:58) 
        at com.citrix.mvpn.helper.b.a(Unknown Source:21) 
        at com.citrix.mvpn.service.MITMService$b.run(Unknown Source:55) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:923) 

Cause

MAM SDK uses the legacy Apache HTTP library. The app will explicitly need to allow the use of this library.

Solution

The following needs to be included in the generated AndroidManifest.xml file:

<uses-library android:name="org.apache.http.legacy" android:required="false" />

To do so, add the following in AssemblyInfo.cs (do not modify AndroidManifest.xml directly):

[assembly:Android.App.UsesLibrary (Name = "org.apache.http.legacy", Required = "false")]

See Xamarin’s docs to learn more about working with AndroidManifest.xml.

How to resolve an “invalid opcode ba” error?

“COMPILETODALVIK : Uncaught translation error : com.android.dx.cf.code.SimException: ERROR in com.citrix.mvpn.helper.c.<clinit>:()V: invalid opcode ba - invokedynamic requires --min-sdk-version >= 26 (currently 13)”. 
<!--NeedCopy-->

Solution

Set AndroidDexTool to d8. Add the following property to the .csproj file under the Debug or Release PropertyGroup:

<AndroidDexTool>d8</AndroidDexTool>

Sometimes it will also be necessary to enable desugar by adding the AndroidEnableDesugar property, set to the value True, in the .csproj file under the Debug or Release PropertyGroup:

<AndroidEnableDesugar>True</AndroidEnableDesugar>

What is the .NET standard version supported for the Citrix MAM SDK for Xamarin libraries?

Solution

Current Nuget libraries support .NET standard 2.0 and later.

When the “StartTunnel()” method is invoked, the callback goes to the “OnError()” method and it returns “StartTunnelError = NotMAMEnrolled”

The following error message appears in the ADB logs:

07-22 22:04:40.004 15599 15599 E MVPN-XM-TunnelHandler: NotMAMEnrolled

Solution

This exception occurs when an app is not managed. Perform the following steps to verify if the app is managed:

  1. Verify if Secure Hub is enrolled successfully.
  2. Verify that the app’s APK file has been signed with the same KeyStore used to generate the MDX file. See setting up the Citrix MAM SDK for Xamarin libraries for more details.
  3. Verify that the MDX file is published in the Citrix Endpoint Management console.

When the “StartTunnel()” method is invoked the callback goes to the “OnError()” method and it returns “StartTunnelError = InvalidPolicy”

The following error message appears in the ADB logs as well:

07-30 10:46:01.627 16133 16133 E MVPN-XM-TunnelHandler: InvalidPolicy

Solution

This exception occurs when Citrix Endpoint Management policies are set incorrectly for tunneling. Verify on the Citrix Endpoint Management console that the Network access policy is set to Tunneled - Web SSO.

How to resolve an “ERR_CLEARTEXT_NOT_PERMITTED” response when tunneling a HTTP request?

The webpage at http://… could not be loaded because: net:: ERR_CLEARTEXT_NOT_PERMITTED

Solution

Include the following line in the AssemblyInfo.cs file to allow clear text traffic:

[assembly: Application(UsesCleartextTraffic =true)]

See Xamarin’s docs to learn more about working with AndroidManifest.xml.

How to capture debug logs for the technical support team?

Solution

The following steps can be used to capture the debug logs:

  1. Launch Secure Hub and click the hamburger menu.
  2. Click Help > Report Issue and select the app with the issue.
  3. Click Advanced log settings.
  4. Set Log Level to Level 15 Debug10.
  5. Change Log destination to select both File and Console.
  6. Reproduce the issue.
  7. Add a description of the issue (and optionally attach screenshots).
  8. Click Send and select an email app (such as Secure Mail) to send the error log.

How to resolve a “System.ObjectDisposedException: Cannot access a disposed object” error when tunneling a WebView for Xamarin.Forms?

 2021-06-15 16:58:19.844 3008-3008/? E/AndroidRuntime: FATAL EXCEPTION: main
 Process: com.citrix.browser.droid, PID: 3008
 java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:558)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
 Caused by: java.lang.reflect.InvocationTargetException
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
 Caused by: java.lang.reflect.InvocationTargetException
 at java.lang.reflect.Method.invoke(Native Method)
 at com.citrix.mvpn.g.b.invoke(Unknown Source:38)
 at crc643f46942d9dd1fff9.FormsWebViewClient_Proxy.onReceivedError(Unknown Source:23)
 at g9.handleMessage(chromium-TrichromeWebViewGoogle.apk-stable-447201683:124)
 at android.os.Handler.dispatchMessage(Handler.java:106)
 at android.os.Looper.loopOnce(Looper.java:201)
 at android.os.Looper.loop(Looper.java:288)
 at android.app.ActivityThread.main(ActivityThread.java:7727)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
 Caused by: android.runtime.JavaProxyThrowable: System.ObjectDisposedException: Cannot access a disposed object.
 Object name: 'Android.Webkit.WebView'
 <!--NeedCopy-->

Cause

This error may be seen with Xamarin.Forms 5.x when tunneling a WebView.

Solution

Override the Dispose method in your WebViewRenderer class. This method should dispose the FormsWebViewClient object as shown in the below code snippet.

public class XamarinWebViewRenderer : MvpnWebViewRenderer
{
    bool disposed;
    FormsWebViewClient client;
    public XamarinWebViewRenderer(Context context) : base(context)
    {
    }
    public override WebViewClient CreateWebViewClient()
    {
        return new FormsWebViewClient(this);
        client = new FormsWebViewClient(this);
        return client;
    }
    protected override void Dispose(bool disposing)
    {
        if (disposed)
        {
            Console.WriteLine("Already Disposed.");
            return;
        }
        try
        {
            Console.WriteLine("Disposing objects.");
            base.Dispose(disposing);
            client.Dispose();
            disposed = true;
            Console.WriteLine("Dispose Done.");
        }
        catch (ObjectDisposedException e)
        {
            Console.WriteLine("Dispose Failed:"+ e);
        }
    }
}
<!--NeedCopy-->