BobC
BobC

Reputation: 103

How to resolve Xamarin Android linking problem

My Xamarin Forms Android app works fine in Debug. But in Release, when deployed to either the emulator or to a device, the app is "stopped" after showing the splash screen. The debug log shows these errors, indicating that it can't find class FitWindowsLinearLayout...

10-23 22:24:59.270 14008 14008 E AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #14: Binary XML file line #14: Error inflating class android.support.v7.widget.FitWindowsLinearLayout

10-23 22:24:59.270 14008 14008 E AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #14: Error inflating class android.support.v7.widget.FitWindowsLinearLayout

10-23 22:24:59.270 14008 14008 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.FitWindowsLinearLayout" on path: DexPathList[[zip file "/data/app/zeemerix.NflCalcXF-1/base.apk"],nativeLibraryDirectories=[/data/app/zeemerix.NflCalcXF-1/lib/arm, /data/app/zeemerix.NflCalcXF-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]

Changing Linking to "None" resolves the problem, but then the APK is very large. Should I use "Skip Linking Assemblies"? If so, what to enter?

I tried using a Proguard profile, but when I do, then the MainPage appears as a blank screen, and the debug log says it can't find Help_ObClick(), which is an event handler in the MainPage code behind. The profile I used is this...

-dontobfuscate
-keep class android.support.v7.widget.** { *; }
-dontwarn android.support.v7.widget.**
-keep class android.support.v4.widget.Space { *; }
-dontwarn android.support.v4.widget.Space

My Android Options:

Off: Use shared runtime On: Enable Proguard On: Enable developer instrumentation Linking: Sdk and User Assemblies [Setting it to None resolves problem]

Compile using Android version: 8.1 Min Android version: 7.0 Target Android version: 8.1

My setup:

VS Community 2017, Version 15.7.3 Xamarin 4.10.10.1 Xamarin Android SDK 8.3.3.2 Xamarin Forms 3.3.0.912540 Xamarin support libraries v27.0.2.1

Upvotes: 2

Views: 2164

Answers (2)

Kero Fawzy
Kero Fawzy

Reputation: 700

my poject screenshot

if you want to link SDK and User Assemblies you have to skip linking your .net standard and any projects you use, like customControls in my project. There are many other ways to do this but this is easier.

Upvotes: 1

axa
axa

Reputation: 520

As you know linking 'None' works, try then linking 'Sdk Assemblies Only' If that doesn't work, then you can go into your build folder, copy all the names of all the assemblies minus extension and add them to the "Skip linking assemblies" field

Then set linking to 'Sdk and User Assemblies' and try again. It will take forever but then remove each of these files from the list until you find the one(s) that cause the problem.

For me it was much easier as Link 'Sdk Assemblies Only' worked so i could eliminate all the Sdk assemblies found here:

https://learn.microsoft.com/en-us/xamarin/cross-platform/internals/available-assemblies

The user list was much smaller and thus process of elimination much quicker...

Fwiw, libraries that use reflection are often a problem as they cant be easily identified as used before compile and get marked for delete. In my case it was Json.Net, RestSharp and the like....

My published app size is only a third what it would have been otherwise...

Upvotes: 2

Related Questions