Forum Xamarin.Android

How to resolve error "Compilation can't be completed because some library classes are missing."?

On building xamarin.android project in release mode giving the following error in visual studio 2019:
Android Options are
Dex compiler : d8
Code Shrinker: r8
Error Compilation can't be completed because some library classes are missing. myproject.Android D:\Xamarin_workspace\projests\...\...\...\myproject.Android\R8

This error start occurring after adding Nuget Xamarin.GooglePlayServices.Ads
if I remove Xamarin.GooglePlayServices.Ads nuGet this error does not occur
Or
I set Android Options to
Dex compiler : dx
Code Shrinker: ProGaurd
then size of apk get increased.

My main concern is to reduce the apk size

Answers

  • LeonLuLeonLu Member, Xamarin Team Xamurai
    edited June 2019

    According to your error message, I research it , I find this link , https://github.com/xamarin/xamarin-android/pull/2736 To fix the problem, the <ReadAndroidManifest/> MSBuild
    task now looks for <uses-library/>, so it adds
    Xamarin.GooglePlayServices.Ads to the @(AndroidExternalJavaLibrary)
    item group. This allows ProGuard/R8 to accept this library as input. You can have a try.

  • artemiousartemious Member ✭✭

    Thanks for pointing out that the problem was in package Xamarin.GooglePlayServices.Ads. It was unnecessary reference in my project, I removed it and it solved the problem.

  • Ravi_98Ravi_98 Member ✭✭

    In my case for a temporary fix, I disabled the multi dex in project properties and everything was built successfully.

Sign In or Register to comment.