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

mirkarammirkaram Member ✭✭

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 14

    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.

Sign In or Register to comment.