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 need to explicitly allow the use of this library.

Fix

Add the following in the AndroidManifest.xml file’s <application> section.

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

How to resolve a “Failed to obtain ContentProviderClient for MDXProvider” error?

Google has updated the Play Store requirements to update target SDK version to 30 starting from August 2021 for new apps, and from November 2021 for app updates. MAM SDK integrated apps targeted for SDK version 30 will fail with this error.

2021-04-27 19:36:05.530 16321-16387/? E/ActivityThread: Failed to find provider info for com.citrix.work.MDXProvider
2021-04-27 19:36:05.530 16321-16387/? E/CORESDK-PolicyAPI: Failed to obtain ContentProviderClient for MDXProvider
2021-04-27 19:36:05.530 16321-16387/? E/CORESDK-PolicyAPI: Failed to obtain ContentProviderClient for MDXProvider
…
021-04-27 19:36:05.557 16321-16392/? E/"MVPN-SHTunnelConfig": "ERROR     ( 2)","Failed to obtain ContentProviderClient for MDXProvider"
…
2021-04-27 19:36:05.557 16321-16387/? E/ActivityThread: Failed to find provider info for com.citrix.work.MDXProvider

Cause

Android SDK version 30 added new restrictions to Package Visibility.

Fix

Add the following in the AndroidManifest.xml file’s <manifest> section.

<queries>
    <package android:name="com.zenprise" />
    <package android:name="com.citrix.Receiver" />
</queries>

Generating MDX file for Android App Bundle and Play App Signing

An app that uses Android App Bundle and Play App Signing cannot generate a valid MDX file.

Cause

Google has updated the Play Store requirement for new apps to use the Android App Bundle starting August 2021. Android App Bundle requires you to opt-in to Play App Signing. With Android App Bundle, the app will no longer generate the APK for submission to the Play Store. Also, Play App Signing will remove your burden to safely manage signing keys. However, the APK file and signing keys are both required for generating an MDX file.

Fix

Support for Play App Signing was introduced in MAM SDK version 21.7.0.

When using a Google Play Store Signing certificate, use the -playappsigningcert switch to generate an MDX file.

Download the Google Play Signing certificate from your Google Play console and then point the new -playappsigningcert switch to its path. Any KeyStore related switches will be ignored and can be omitted.

Example:

java -jar <mamSdkLib path>/tools/managed-app-utility.jar \
  wrap \
    -in "~/Desktop/SampleApps/Sample.apk" \
    -out "~/Desktop/SampleApps/Sample.mdx" \
    -appType 'sdkapp' \
    -playappsigningcert "~/Desktop/deployment_cert.der"

How to resolve an “android_settings.txt file not found” error or “Zipalign binary not found” error?

When generating an MDX file the following error might be seen:

> Task :mvpntestapp:generateMdx FAILED

android_settings.txt file not found.

Zipalign binary not found. This is part of the Android SDK. Please refer to the MDX Toolkit documentation for download instructions.
Apksigner binary not found. This is part of the Android SDK. Please refer to the MDX Toolkit documentation for download instructions.

Cause

This error happens when Android SDK build-tools are not set in the PATH environment variable.

Fix

Setting the Android SDK build-tools into the PATH environment variable should fix the error.

For example:

export ANDROID_SDK_HOME=/Users/<user_name>/Library/Android/sdk
export PATH=$ANDROID_SDK_HOME/tools:$ANDROID_SDK_HOME/build-tools/29.0.3:$ANDROID_SDK_HOME/platform-tools:$PATH

How to resolve a Gradle sync error “Failed to resolve: com.citrix.android.sdk:mamsdk:<mam sdk version>”?

When you launch Gradle build for a MAM SDK app the following error might occur:

Failed to resolve: com.citrix.android.sdk:mamsdk:20.10.5.1
    
Could not determine the dependencies of task ':compileReleaseJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':releaseCompileClasspath'.
> Could not find any version that matches com.citrix.android.sdk:mamsdk:20.10.5.1
<!--NeedCopy-->

Cause

This error happens when the repositories links within an app’s build.gradle file is pointing to a wrong maven URL location for the MAM SDK.

Fix

Verify whether the app’s build.gradle file is pointing to a correct maven URL location for the MAM SDK.

repositories {
    maven { url "https://raw.githubusercontent.com/citrix/citrix-mam-sdks/main/maven" }
    google()
    mavenCentral()
    jcenter()
}

Verify if the MAM SDK Gradle dependency has the correct version.

ext {
    mamSdkVersion = "<Enter MAM SDK Version, e.g. 20.10.5.1>"
}
dependencies {
    implementation "com.citrix.android.sdk:mamsdk:${project.ext.mamSdkVersion}"
}

More details can be found on this page: Setting up the library

How to resolve a Gradle build error “AndroidManifest.xml Error: Attribute application@theme is also present at com.citrix.android:authmanagerlitelib …”?

When you launch Gradle build for a MAM SDK app, the following error might occur:

<project path>/app/src/main/AndroidManifest.xml:11:9-59 Error:
Attribute application@theme value=(@style/Theme.<projectname>) from AndroidManifest.xml:11:9-59
is also present at [com.citrix.android:authmanagerlitelib:Release_21.5.0-1] AndroidManifest.xml:15:9-40 value=(@style/AppTheme).
Suggestion: add 'tools:replace="android:theme"' to <application> element at AndroidManifest.xml:5:5-22:19 to override.
<!--NeedCopy-->

Cause

This error happens during Android Manifest XML merge when the app’s AndroidManifest.xml file also has an application@theme attribute.

Fix

Add xmlns:tools="http://schemas.android.com/tools" to the manifest element in the AndroidManifest.xml file.

Also add tools:replace="android:theme" to the application element in the AndroidManifest.xml file.

How to resolve a Gradle build error for Kotlin Version Mismatch?

When you launch Gradle build for a MAM SDK app the following error might occur:

> Task :app:compileDebugKotlin FAILED
w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
    C:/Users/<username>/.gradle/caches/transforms-2/files-2.1/78d49c020187138fd912e336a9ca0a28/jetified-kotlin-stdlib-jdk7-1.3.30.jar (version 1.3)
    C:/Users/<username>/.gradle/caches/transforms-2/files-2.1/e154b39a1c35ddffc3047fff37fa1703/jetified-kotlin-stdlib-1.4.32.jar (version 1.4)
    C:/Users/<username>/.gradle/caches/transforms-2/files-2.1/f87d6fed6f9f93e0e54dbdf9d66e1af6/jetified-kotlin-stdlib-common-1.4.32.jar (version 1.4)
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath
e: warnings found and -Werror specified
<!--NeedCopy-->

Cause

This error can happen during a Kotlin app’s build after integrating with MAM SDK.

Fix

Include kotlin-stdlib-jdk8 which has dependency to kotlin-stdlib-jdk7 as well.

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

How to resolve a “java.lang.VerifyError: Superclass …WebViewClient_Proxy is declared final …” error or a “java.lang.IncompatibleClassChangeError: Superclass …WebViewClient_Proxy is declared final …” error while calling “MicroVPNSDK.enableWebViewObjectForNetworkTunnel” method?

When an app calls MicroVPNSDK.enableWebViewObjectForNetworkTunnel(…) it might crash with the following error:

2021-07-12 17:21:45.138 32417-32417/com.citrix.mvpntestapp.july12021 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.citrix.mvpntestapp.july12021, PID: 32417
java.lang.VerifyError: Superclass com.citrix.mvpntestapp.webview.CustomWebViewClient of com.citrix.mvpntestapp.webview.CustomWebViewClient_Proxy is declared final (declaration of 'com.citrix.mvpntestapp.webview.CustomWebViewClient_Proxy' appears in /data/user/36/com.citrix.mvpntestapp.july12021/cache/v1/Generated_-1629600291.jar)
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.android.dx.stock.ProxyBuilder.loadClass(ProxyBuilder.java:343)
at com.android.dx.stock.ProxyBuilder.buildProxyClass(ProxyBuilder.java:325)
at com.android.dx.stock.ProxyBuilder.build(ProxyBuilder.java:232)
at com.citrix.mvpn.g.b.a(Unknown Source:21)
at com.citrix.mvpn.e.d.a(Unknown Source:45)
at com.citrix.mvpn.e.d.a(Unknown Source:3)
at com.citrix.mvpn.api.MicroVPNSDK.enableWebViewObjectForNetworkTunnel(Unknown Source:26)
<!--NeedCopy-->

Cause

This error happens when the app’s WebView uses a custom WebView client class that is declared as private, final, or static.

Fix

MicroVPNSDK can enable a WebView for tunneling only if the underlying WebViewClient class is non-private, non-final, and non-static.

How to resolve a “Missing ‘package’ key attribute on element package at AndroidManifest.xml” error when building your app?

/Users/user/citrix-mam-sdk-sample-browser-app-android-java/mvpntestapp/src/main/AndroidManifest.xml:52:9-48 Error:
Missing 'package' key attribute on element package at AndroidManifest.xml:52:9-48
/Users/user/citrix-mam-sdk-sample-browser-app-android-java/mvpntestapp/src/main/AndroidManifest.xml:53:9-55 Error:
Missing 'package' key attribute on element package at AndroidManifest.xml:53:9-55
/Users/user/citrix-mam-sdk-sample-browser-app-android-java/mvpntestapp/src/main/AndroidManifest.xml Error:
Validation failed, exiting
See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':myapp: processDebugManifest'.
> Manifest merger failed with multiple errors, see logs
<!--NeedCopy-->

Cause

You might face this issue when migrating from MAM SDK 21.7.0+ to 21.9.0+. Updated versions of the Android Gradle plugin are required to support Package Visibility. For more information about Package Visibility, see Package Visibility in Android 11.

Fix

Update the Gradle plugin in the build.gradle file of your project’s root folder to a version that supports Package Visibility. The Android Gradle plugin versions that support Package Visibility are outlined in the Android Gradle plugin release notes. Citrix recommends using Android Gradle Plugin versions 4.0.1 or greater. Refer to the build.gradle file in the root folder of the Citrix Android sample app for reference.