euc-releases / wsone-sdk-xamarin

Workspace ONE SDK for Xamarin
Other
6 stars 7 forks source link

Errors with Nuget package AWSDK and Xamarin Android project Target Framework Android 12 when building #20

Open Auto72 opened 2 years ago

Auto72 commented 2 years ago

Steps to reproduce the errors:

1) Create a Xamarin Android App with Target Android 12. 2) Add the NuGet pakckage AWSDK 3) Build the progect.

You get the following errors and warnings:

1>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1432,3): warning XA4214: The managed type AndroidX.AppCompat.Widget.ResourceManagerInternal.IResourceManagerHooks exists in multiple assemblies: Xamarin.AndroidX.AppCompat.AppCompatResources, Xamarin.AndroidX.AppCompat.Resources. Please refactor the managed type names in these assemblies so that they are not identical. 1>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1432,3): warning XA4214: References to the type AndroidX.AppCompat.Widget.ResourceManagerInternal.IResourceManagerHooks will refer to AndroidX.AppCompat.Widget.ResourceManagerInternal.IResourceManagerHooks, Xamarin.AndroidX.AppCompat.AppCompatResources. 1>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1432,3): warning XA4214: The managed type Android.Support.V4.Media.Session.MediaSessionCompat.IOnActiveChangeListenerImplementor exists in multiple assemblies: Xamarin.Android.Support.Media.Compat, Xamarin.AndroidX.Media. Please refactor the managed type names in these assemblies so that they are not identical. 1>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1432,3): warning XA4214: References to the type Android.Support.V4.Media.Session.MediaSessionCompat.IOnActiveChangeListenerImplementor will refer to Android.Support.V4.Media.Session.MediaSessionCompat.IOnActiveChangeListenerImplementor, Xamarin.Android.Support.Media.Compat. 1>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1432,3): error XA4215: The Java type androidx.appcompat.widget.ResourceManagerInternal$ResourceManagerHooks is generated by more than one managed type. Please change the [Register] attribute so that the same Java type is not emitted. 1>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1432,3): error XA4215: androidx.appcompat.widget.ResourceManagerInternal$ResourceManagerHooks generated by: AndroidX.AppCompat.Widget.ResourceManagerInternal+IResourceManagerHooks, Xamarin.AndroidX.AppCompat.AppCompatResources, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 1>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1432,3): error XA4215: androidx.appcompat.widget.ResourceManagerInternal$ResourceManagerHooks generated by: AndroidX.AppCompat.Widget.ResourceManagerInternal+IResourceManagerHooks, Xamarin.AndroidX.AppCompat.Resources, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 1>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1432,3): error XA4215: The Java type mono.android.support.v4.media.session.MediaSessionCompat_OnActiveChangeListenerImplementor is generated by more than one managed type. Please change the [Register] attribute so that the same Java type is not emitted. 1>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1432,3): error XA4215: mono.android.support.v4.media.session.MediaSessionCompat_OnActiveChangeListenerImplementor generated by: Android.Support.V4.Media.Session.MediaSessionCompat+IOnActiveChangeListenerImplementor, Xamarin.Android.Support.Media.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null 1>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1432,3): error XA4215: mono.android.support.v4.media.session.MediaSessionCompat_OnActiveChangeListenerImplementor generated by: Android.Support.V4.Media.Session.MediaSessionCompat+IOnActiveChangeListenerImplementor, Xamarin.AndroidX.Media, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

akalghatgi commented 2 years ago

@Auto72 Can you please share the complete build logs, also can you share the Visual Studio details.

Regards, Amit

Auto72 commented 2 years ago

Here you are.

Build_LOG_verbose.zip Visual Studio 2022 details.txt

Auto72 commented 2 years ago

Here the application, so you can test it yourself.

App5.zip

akalghatgi commented 2 years ago

Hi @Auto72, Thanks for sharing logs and App sample. Kindly update the packages to following version and add few new ones as mentioned.

<ItemGroup>
    <PackageReference Include="AWSDK" Version="22.1.0" />
    <PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.2.0.5" />
    <PackageReference Include="Xamarin.Google.Android.Material" Version="1.3.0" />
    <PackageReference Include="Xamarin.Essentials" Version="1.6.1" />
    <PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.2.0.3" />
    <PackageReference Include="Xamarin.AndroidX.Preference" Version="1.0.0" />
  </ItemGroup> 

Kindly let me know if it build for you.

Thanks Amit

Auto72 commented 2 years ago

With the references you reported above

the build still produces errors.

Build started... NU1605: Detected package downgrade: Xamarin.AndroidX.AppCompat from 1.2.0.7 to 1.2.0.5. Reference the package directly from the project to select a different version. App5 -> AWSDK 22.1.0 -> Xamarin.AndroidX.ConstraintLayout 2.0.4.2 -> Xamarin.AndroidX.AppCompat (>= 1.2.0.7) App5 -> Xamarin.AndroidX.AppCompat (>= 1.2.0.5) NU1605: Detected package downgrade: Xamarin.AndroidX.AppCompat from 1.2.0.6 to 1.2.0.5. Reference the package directly from the project to select a different version. App5 -> Xamarin.Google.Android.Material 1.3.0 -> Xamarin.AndroidX.AppCompat (>= 1.2.0.6) App5 -> Xamarin.AndroidX.AppCompat (>= 1.2.0.5) 1>------ Build started: Project: App5, Configuration: Debug Any CPU ------ Restored C:\Users\mconti\Documents\GitHub\App5\App5\App5.csproj (in 11.86 sec). 1>C:\Users\mconti\Documents\GitHub\App5\App5\Resources\drawable\com_mixpanel_android_nocolor_list.xml : warning XA1001: AndroidResgen: Warning while updating resource XML 'C:\Users\mconti\Documents\GitHub\App5\App5\obj\Debug\120\lp\8\jl\res\drawable\com_mixpanel_android_nocolor_list.xml': Length cannot be less than zero. 1>C:\Users\mconti\Documents\GitHub\App5\App5\Resources\drawable\com_mixpanel_android_nocolor_list.xml : warning XA1001: Parameter name: length 1>C:\Users\mconti\Documents\GitHub\App5\App5\obj\Debug\120\lp\145\jl\res..\flat\145.flata : error APT2000: The device does not recognize the command. (22). ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Auto72 commented 2 years ago

I also tried to update the above NuGet packages to the latest version, but the result is the same. It doesn't work.

Build started... 1>------ Build started: Project: App5, Configuration: Debug Any CPU ------ Restored C:\Users\mconti\Documents\GitHub\App5\App5\App5.csproj (in 965 ms). 1>C:\Users\mconti\Documents\GitHub\App5\App5\Resources\drawable\com_mixpanel_android_nocolor_list.xml : warning XA1001: AndroidResgen: Warning while updating resource XML 'C:\Users\mconti\Documents\GitHub\App5\App5\obj\Debug\120\lp\8\jl\res\drawable\com_mixpanel_android_nocolor_list.xml': Length cannot be less than zero. 1>C:\Users\mconti\Documents\GitHub\App5\App5\Resources\drawable\com_mixpanel_android_nocolor_list.xml : warning XA1001: Parameter name: length 1>C:\Users\mconti\Documents\GitHub\App5\App5\obj\Debug\120\lp\5\jl\res\values\values.xml(4): error APT2260: resource style/Preference_TextAppearanceMaterialBody2 (aka com.companyname.app5:style/Preference_TextAppearanceMaterialBody2) not found. 1>C:\Users\mconti\Documents\GitHub\App5\App5\obj\Debug\120\lp\5\jl\res\values-v17\values-v17.xml(2): error APT2260: resource style/Preference_TextAppearanceMaterialBody2 (aka com.companyname.app5:style/Preference_TextAppearanceMaterialBody2) not found. 1>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Aapt2.targets(157,3): error APT2062: failed linking references. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

akalghatgi commented 2 years ago

@Auto72 are you missing these 2 packages?

<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.2.0.3" />
<PackageReference Include="Xamarin.AndroidX.Preference" Version="1.0.0" />
Auto72 commented 2 years ago

No, I don't.

<ItemGroup>
    <PackageReference Include="AWSDK" Version="22.1.0" />
    <PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.2.0.5" />
    <PackageReference Include="Xamarin.Google.Android.Material" Version="1.3.0" />
    <PackageReference Include="Xamarin.Essentials" Version="1.6.1" />
    <PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData" Version="2.2.0.3" />
    <PackageReference Include="Xamarin.AndroidX.Preference" Version="1.0.0" />
</ItemGroup>
Auto72 commented 2 years ago

Please, find in attachment the application with all the references above.

App5.zip

akalghatgi commented 2 years ago

@Auto72 try compiling this. App5_new.zip

Auto72 commented 2 years ago

Yes, this App5_new.zip DOES build properly, even if has same warnings.

Build started... NU1605: Detected package downgrade: Xamarin.AndroidX.AppCompat from 1.2.0.6 to 1.2.0.5. Reference the package directly from the project to select a different version. App5 -> Xamarin.Google.Android.Material 1.3.0 -> Xamarin.AndroidX.AppCompat (>= 1.2.0.6) App5 -> Xamarin.AndroidX.AppCompat (>= 1.2.0.5) NU1605: Detected package downgrade: Xamarin.AndroidX.AppCompat from 1.2.0.7 to 1.2.0.5. Reference the package directly from the project to select a different version. App5 -> AWSDK 22.1.0 -> Xamarin.AndroidX.ConstraintLayout 2.0.4.2 -> Xamarin.AndroidX.AppCompat (>= 1.2.0.7) App5 -> Xamarin.AndroidX.AppCompat (>= 1.2.0.5) Restored C:\App\App5\App5\App5.csproj (in 1.31 sec). 1>------ Build started: Project: App5, Configuration: Debug Any CPU ------ 1>C:\App\App5\App5\Resources\drawable\com_mixpanel_android_nocolor_list.xml : warning XA1001: AndroidResgen: Warning while updating resource XML 'C:\App\App5\App5\obj\Debug\120\lp\8\jl\res\drawable\com_mixpanel_android_nocolor_list.xml': Length cannot be less than zero. 1>C:\App\App5\App5\Resources\drawable\com_mixpanel_android_nocolor_list.xml : warning XA1001: Parameter name: length 1> App5 -> C:\App\App5\App5\bin\Debug\App5.dll ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ========== 1

If I updates the NuGet packages to the latest version it doesn't build properly.

Build started... 1>------ Build started: Project: App5, Configuration: Debug Any CPU ------ Restored C:\App\App5\App5\App5.csproj (in 298 ms). 1>C:\App\App5\App5\Resources\drawable\com_mixpanel_android_nocolor_list.xml : warning XA1001: AndroidResgen: Warning while updating resource XML 'C:\App\App5\App5\obj\Debug\120\lp\8\jl\res\drawable\com_mixpanel_android_nocolor_list.xml': Length cannot be less than zero. 1>C:\App\App5\App5\Resources\drawable\com_mixpanel_android_nocolor_list.xml : warning XA1001: Parameter name: length 1>C:\App\App5\App5\obj\Debug\120\lp\5\jl\res\values\values.xml(4): error APT2260: resource style/Preference_TextAppearanceMaterialBody2 (aka com.companyname.app5:style/Preference_TextAppearanceMaterialBody2) not found. 1>C:\App\App5\App5\obj\Debug\120\lp\5\jl\res\values-v17\values-v17.xml(2): error APT2260: resource style/Preference_TextAppearanceMaterialBody2 (aka com.companyname.app5:style/Preference_TextAppearanceMaterialBody2) not found. 1>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Aapt2.targets(157,3): error APT2062: failed linking references. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 2 3

akalghatgi commented 2 years ago

@Auto72 Got your point...As of now Android Native SDK doesn't support Android 12 and API 31...also we will be updating the packages in coming releases.

Auto72 commented 2 years ago

I look forward the new release to start using the AWSDK package. I hope it will be soon :-) Thanks.

Auto72 commented 2 years ago

I just downloaded the example here: https://github.com/vmwareairwatchsdk/vmware-ws1-sdk-xamarin

and built them with Visual Studio 2019, without touching anything. I does build, but if you try to deploy and run it on the Android emulator I get the following error:

Java.Lang.UnsatisfiedLinkError Message=Bad JNI version returned from JNI_OnLoad in "/data/app/~~I5gh7OJSOqNhbvxtf_zzZw==/com.airwatch.sample.app-o_Y-RQYw3J1EwxWE8jhgkg==/lib/x86_64/libfips_main.so": -3


[atch.sample.ap] Attempt to remove non-JNI local reference, dumping thread [TetheringManager] registerTetheringEventCallback:com.airwatch.sample.app [AirWatch_SDKLogRetriever] initializeLogger() called: false [AirWatch_DefaultLogPipeline] initializeAggregator called [AirWatch_SDKRollingFileAggregator] Initializing aggregator [AirWatch_SDKRollingFileAggregator] Aggregator has been initialized [AirWatch_AWSDKApplicationDelegate] Feature Module is not enabled, skip initializing feature module [AirWatch_AWSDKApplicationDelegate] Application started [AirWatch_PreferenceProvider] sdk not initialized returning query null from provider [AW_Native] Registering natives [AirWatch_OpenSSLCryptUtil] Create new instance of crypto library [AirWatch] onSDKException: Report from secure preference. code = COMPROMISE_STATUS [AW_Native] aw_initialize_crypto_library: Initializing OpenSSL Library, isOpenSslInitialized: 0 [AW_Native] aw_initialize_crypto_library: Initializing OpenSSL Library [AirWatchSDK] Agent is not installed on device. Searching for Workspace ONE now [AirWatchSDK] Workspace ONE is not installed on device. Searching for Agent(Connect) now [AirWatchSDK] Agent(Connect) is not installed on device. Searching for Workspace now [AirWatchSDK] Workspace is not installed on device. Searching for Workspace(Connect) now [AirWatchSDK] Workspace(Connect) is not installed on device. [AirWatchSDK] Agent and Workspace, neither is installed. Returning null as the binding Package [AirWatchSDK] Agent is not installed on device. Searching for Workspace ONE now [AirWatchSDK] Workspace ONE is not installed on device. Searching for Agent(Connect) now [AirWatchSDK] Agent(Connect) is not installed on device. Searching for Workspace now [AirWatchSDK] Workspace is not installed on device. Searching for Workspace(Connect) now [AndroidRuntime] at java.l03-24 14:22:54.614 D/AirWatchSDK(21955): Workspace(Connect) is not installed on device. [AirWatchSDK] Agent and Workspace, neither is installed. Returning null as the binding Package [AW_Native] JNI_OnLoad: Failed to initialise the crypto library [AndroidRuntime] Shutting down VM [AndroidRuntime] FATAL EXCEPTION: main [AndroidRuntime] Process: com.airwatch.sample.app, PID: 21955 [AndroidRuntime] java.lang.UnsatisfiedLinkError: Bad JNI version returned from JNI_OnLoad in "/data/app/~~I5gh7OJSOqNhbvxtf_zzZw==/com.airwatch.sample.app-o_Y-RQYw3J1EwxWE8jhgkg==/lib/x86_64/libfips_main.so": -3 [AndroidRuntime] at java.lang.Runtime.loadLibrary0(Runtime.java:1087) [AndroidRuntime] at java.lang.System.loadLibrary(System.java:1664) [AndroidRuntime] at com.android.internal.os.RuntimeInit$MethodAndArg03-24 14:22:54.615 E/AndroidRuntime(21955): at com.airwatch.crypto.openssl.OpenSSLWrapper.(Unknown Source:40) [AndroidRuntime] at com.airwatch.crypto.openssl.OpenSSLCryptUtil.(Unknown Source:9) [AndroidRuntime] at com.airwatch.crypto.openssl.OpenSSLCryptUtil.createInstance(Unknown Source:40) [AndroidRuntime] at com.airwatch.crypto.provider.AWSecurityProvider.(Unknown Source:11) [AndroidRuntime] at com.airwatch.app.AWSDKApplicationDelegate.initSecurityProvider(Unknown Source:6) [AndroidRuntime] at com.airwatch.app.AWSDKApplicationDelegate.onCreate(Unknown Source:174) [AndroidRuntime] at com.airwatch.app.AWApplication.onCreate(Unknown Source:7) [AndroidRuntime] at com.airwatch.app.AWApplication.onCreate(Unknown Source:6) [AndroidRuntime] at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192) [AndroidRuntime] at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6712) [AndroidRuntime] at android.app.ActivityThread.access$1300(ActivityThread.java:237) [AndroidRuntime] at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913) [AndroidRuntime] at android.os.Handler.dispatchMessage(Handler.java:106) [AndroidRuntime] at android.os.Looper.loop(Looper.java:223) [AndroidRuntime] at android.app.ActivityThread.main(ActivityThread.java:7656) [AndroidRuntime] at java.lang.reflect.Method.invoke(Native Method) [AndroidRuntime] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) Java.Lang.UnsatisfiedLinkError: 'Bad JNI version returned from JNI_OnLoad in "/data/app/~~I5gh7OJSOqNhbvxtf_zzZw==/com.airwatch.sample.app-o_Y-RQYw3J1EwxWE8jhgkg==/lib/x86_64/libfips_main.so": -3'

[atch.sample.ap] Waiting for a blocking GC ProfileSaver [AirWatch_TaskQueue] attempting to quit task queue handler SecurePreferences after timeout [AirWatch_TaskHandler] quit safe=true, hasPostMessages=false, hasPostDelayMessages=false [AirWatch_TaskQueue] removing queue after quit safely success for task queue handler SecurePreferences


Even if the App5_new.zip was able to compile, I was unable to debug the app. It seems to me this SDK doesn't work at all with Xamarin Android. I hope you will fix it soon.

akalghatgi commented 2 years ago

@Auto72 You cannot directly deploy on emulator and Test... There are few pre-requisite.... Kindly read this GettingStarted