Android Question B4A and Citrix XenMobile?

W. Graf

Member
Licensed User
Longtime User
Good morning,

does anybody have experience in developing apps with B4A, which were deployed via the MDM-System "Citrix XenMobile Enterprise"?

I'm able to compile my app to a *.APK, then I wrap the *.APK to a *.MDX and deploy it on our business phones. But after I install the app on a device, I'm starting it and it crashes immediatly. No error message, just only "App wurde angehalten" (I think in English: "App has been stopped").
The app only shows an activity with a EditText-View. There is no program code (except: Activity.LoadLayout("Layout1") ) and no additional libraries. I tried it with Starter and without Starter service.

I know, there is a Worx SDK, which I can implement into my app. But there is no tutorial. So I'm wondering if somebody ever had tried to develop an app for "Citrix XenMobile"?

Thank you and have a great day!
BR Wolfgang
 

W. Graf

Member
Licensed User
Longtime User
Hi Erel!

Sorry for delay! Thank you for your reply.

I tried to create a log from USB debug mode. Many lines were created, but I think, the Crash created the following:
02-23 06:40:12.600 29586 29586 E AndroidRuntime: FATAL EXCEPTION: main
02-23 06:40:12.600 29586 29586 E AndroidRuntime: Process: b4a.example, PID: 29586
02-23 06:40:12.600 29586 29586 E AndroidRuntime: java.lang.RuntimeException: Unable to create service com.citrix.MAM.Android.ManagedApp.CtxAppManager: java.lang.ClassCastException: android.app.Application cannot be cast to com.citrix.MAM.Android.ManagedApp.CtxProxyApp
02-23 06:40:12.600 29586 29586 E AndroidRuntime: at android.app.ActivityThread.handleCreateService(ActivityThread.java:2830)
02-23 06:40:12.600 29586 29586 E AndroidRuntime: at android.app.ActivityThread.access$1900(ActivityThread.java:174)
02-23 06:40:12.600 29586 29586 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1389)
02-23 06:40:12.600 29586 29586 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
02-23 06:40:12.600 29586 29586 E AndroidRuntime: at android.os.Looper.loop(Looper.java:146)
02-23 06:40:12.600 29586 29586 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5593)
02-23 06:40:12.600 29586 29586 E AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
02-23 06:40:12.600 29586 29586 E AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:515)
02-23 06:40:12.600 29586 29586 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
02-23 06:40:12.600 29586 29586 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
02-23 06:40:12.600 29586 29586 E AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
02-23 06:40:12.600 29586 29586 E AndroidRuntime: Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to com.citrix.MAM.Android.ManagedApp.CtxProxyApp
02-23 06:40:12.600 29586 29586 E AndroidRuntime: at com.citrix.MAM.Android.ManagedApp.CtxAppManager.onCreate(Unknown Source)
02-23 06:40:12.600 29586 29586 E AndroidRuntime: at android.app.ActivityThread.handleCreateService(ActivityThread.java:2820)
02-23 06:40:12.600 29586 29586 E AndroidRuntime: ... 10 more

MAM stands for "Mobile Application Management": in MAM you can create a Container and insert your app into this container. This container normally enables the app to use a micro-vpn-tunnel to your corporate-network. So you can use your mobile device with any free WLAN (for example), but your app is able to communicate with your company servers though a secure channel.

I'm not very familiar with Java and Android. Do you know logs like these (cast-exception for Android.app.Application)? Do you have an idea, what is going wrong? Maybe a missing manifest-entry? I know ... these are a lot of questions ... ;-)

Thank you again!
BR Wolfgang
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to com.citrix.MAM.Android.ManagedApp.CtxProxyApp
You are expected to set a custom application object.

Something like:
B4X:
SetApplicationAttribute(android:name, "com.citrix.MAM.Android.ManagedApp.CtxProxyApp")
 
Upvote 0

W. Graf

Member
Licensed User
Longtime User
Hi Erel,
thanks for your reply!!

At first, I added this line into the manifest-file
SetApplicationAttribute(android:name, "com.citrix.MAM.Android.ManagedApp.CtxProxyApp")

Then I got this error:
AndroidRuntime: java.lang.RuntimeException: Unable to create service com.citrix.MAM.Android.ManagedApp.CtxAppManager: java.lang.ClassCastException: com.citrix.MAM.Android.ManagedApp.CtxProxyApp cannot be cast to com.citrix.APIContainment.helper.ObjectContext


After adding this line
SetApplicationAttribute(android:name, "com.citrix.APIContainment.helper.ObjectContext")

I got this error:
AndroidRuntime: java.lang.RuntimeException: Unable to instantiate application com.citrix.APIContainment.helper.ObjectContext: java.lang.InstantiationException: can't instantiate class com.citrix.APIContainment.helper.ObjectContext


I'm afraid to say, that I don't know, what these manifest-line do.
Do you have any additional ideas?

Thank you again so much!
BR Wolfgang
 
Upvote 0

W. Graf

Member
Licensed User
Longtime User
Hi Erel,

again I have a question please ...

Citrix publishs a list of restrictions for apps, which were deployed by it's MDM-system (see also on: https://docs.citrix.com/en-us/mdx-t...view/xmob-mdx-dev-android-best-practices.html)

Does the compiled B4A-code meet the following limitations:

Hooking Limitations
-----------------------
MDX injects functionality into a binary Android app by modifying the DEX code in the APK. Several limits are present:
1.) XenMobile might not manage deprecated framework classes from the pre-4.0 Android SDK versions. Be sure to avoid those deprecated classes.
2.) Most functionality is injected into the Java/Android framework APIs. Native (C/C++) code is generally not managed. One exception is that even for native code, file encryption still occurs.
3.) Native code that uses JNI to access Java functionality must only target code in the user app. In other words, don't use JNI to directly invoke Java or Android framework methods. Instead, use the proxy design pattern to "wrap" the desired framework class in a Java class of your own. Then invoke your class from the native code.

Thank you again!
BR Wolfgang
 
Upvote 0

W. Graf

Member
Licensed User
Longtime User
Good afternoon,

I know, this is an old thread from myself. But this question is related to this thread ...

In the meantime, the Problems which I have described above, where solved. Citrix developed an update and the Problems were gone. But now, Citrix again deployed an update and I have a new Problems. After compiling my App and convert it to the Citrix-Format, my app crashes. I found the following Errors in the log:

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{b4a.example/b4a.example.main}: java.lang.ClassNotFoundException: Didn't find class "b4a.example.main" on path: DexPathList[[zip file "/data/app/b4a.example-1.apk"],nativeLibraryDirectories=[/data/app-lib/b4a.example-1, /vendor/lib, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2305)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2470)
at android.app.ActivityThread.access$900(ActivityThread.java:174)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1307)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5593)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "b4a.example.main" on path: DexPathList[[zip file "/data/app/b4a.example-1.apk"],nativeLibraryDirectories=[/data/app-lib/b4a.example-1, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at com.citrix.mdx.b.b.a(Unknown Source)
at com.citrix.mdx.b.b.loadClass(Unknown Source)
at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2296)
... 11 more

Before I open a call at Citrix, I want to ask you, what this means?
I think, the MAIN-activity is lost, right?
Is there a possibility to add an additional "special entry" to the manifest, which explicitly defines the MAIN?
Is the manifest, which is created from Basic4Android different from the one, created with Android Studio?
Sorry, I have no great Knowledge of JAVA- and Android-programming.

Thank you for your time!
Kind regards,
Wolfgang
 
Upvote 0

W. Graf

Member
Licensed User
Longtime User
Thank you.
I will create a call at Citrix.
Is it ok for Anywhere Software and for you, if I provide all generated files from the folder "Objects" (an subdirs) to Citrix (I don't want to violate any Copyrights)?
 
Upvote 0
Top