d8-r8-releasebranchReproduces on Windows 10, macOS and AppCenter build
Solution is built successfully.
Compilation fails with
R8 : warning : Missing class: org.apache.http.client.methods.HttpEntityEnclosingRequestBase
In Debug configuration, solution is built successfully.
There're similar issues, but I don't understand what is the right fix for the issue:
As suggested in the issues above, I copied _C:\Program Files (x86)\Android\android-sdk\platforms\android-27\optional\org.apache.http.legacy_ to the Andoid project and modified Android csproj. It solves the issue, but it seems like a workaround.
<AndroidExternalJavaLibrary Include="org.apache.http.legacy.jar" />
I managed to workaround this build error in my project by including this in the AndroidManifest.xml (as a child of the application element):
<uses-library android:name="org.apache.http.legacy" android:required="false" />
Like most manifest elements, you can also add it using an assembly attribute.
[assembly: UsesLibrary("org.apache.http.legacy", false)]
I disabled MutliDex and that solved my issue. Is that the correct thing to do?
I disabled MutliDex and that solved my issue. Is that the correct thing to do?
Same just worked for me. New VS2019 solution. Not thrilled about this work around as its a large app and I have concerns about the number of methods exceeding the single dex limit.
https://developer.android.com/studio/build/multidex
Hopefully it will be properly fixed before we hit that limit.
I have same problem but warning is different please check:
(_CompileToDalvikWithD8 target) ->
2> R8 : warning : Missing class: org.apache.commons.digester.AbstractObjectCreationFactory
2> R8 : warning : Missing class: org.apache.commons.digester.Rule
2> R8 : warning : Missing class: javax.swing.tree.TreeNode
@jonathanpeppers ... I have been facing the same problem... We are getting this error in 8.5 Preview.
R8 : warning : Missing class: org.apache.http.impl.client.DefaultHttpClient
R8 : warning : Missing class: org.apache.http.auth.AuthSchemeFactory
R8 : warning : Missing class: org.eclipse.jetty.npn.NextProtoNego$ClientProvider
R8 : warning : Missing class: org.jboss.marshalling.ByteOutput
R8 : warning : Missing class: org.apache.tomcat.jni.CertificateVerifier
R8 : warning : Missing class: java.lang.ClassValue
R8 : warning : Missing class: org.apache.tomcat.jni.CertificateRequestedCallback
R8 : warning : Missing class: org.eclipse.jetty.alpn.ALPN$ClientProvider
R8 : warning : Missing class: org.apache.http.conn.routing.HttpRoutePlanner
R8 : warning : Missing class: org.jboss.marshalling.ByteInput
R8 : warning : Missing class: org.eclipse.jetty.alpn.ALPN$ServerProvider
R8 : warning : Missing class: org.eclipse.jetty.npn.NextProtoNego$ServerProvider
R8 : warning : Missing class: org.apache.http.auth.AuthScheme
R8 : warning : Missing class: org.apache.http.HttpRequestInterceptor
R8 : warning : Missing class: com.sun.nio.sctp.AbstractNotificationHandler
R8 : error : Compilation can't be completed because some library classes are missing
.
@amitrkalghatgi you must add this to your AndroidManifest.xml:
https://github.com/xamarin/xamarin-android/issues/3444#issuecomment-521949460
You can also do it from C#:
https://github.com/xamarin/xamarin-android/issues/3444#issuecomment-535049639
@jonathanpeppers After adding we are these warning... not all are gone...
R8 : warning : Missing class: org.jboss.marshalling.ByteInput
R8 : warning : Missing class: org.eclipse.jetty.npn.NextProtoNego$ClientProvider
R8 : warning : Missing class: org.jboss.marshalling.ByteOutput
R8 : warning : Missing class: org.eclipse.jetty.npn.NextProtoNego$ServerProvider
R8 : warning : Missing class: org.eclipse.jetty.alpn.ALPN$ServerProvider
R8 : warning : Missing class: org.apache.tomcat.jni.CertificateVerifier
R8 : warning : Missing class: org.apache.tomcat.jni.CertificateRequestedCallback
R8 : warning : Missing class: java.lang.ClassValue
R8 : warning : Missing class: com.sun.nio.sctp.AbstractNotificationHandler
R8 : warning : Missing class: org.eclipse.jetty.alpn.ALPN$ClientProvider
R8 : error : Compilation can't be completed because some library classes are missing.
@amitrkalghatgi so these are actually real problems... These classes are missing from your app and there is Java code that depends on them.
Is there a way you can narrow down which NuGet package or library causes this? Can you file a new issue with an MSBuild log?
I think this issue is actually resolved by https://github.com/xamarin/xamarin-android/pull/2736 (going to close).
Anyone else, please file a new issue, thanks!
@amitrkalghatgi so these are actually real problems... These classes are missing from your app and there is Java code that depends on them.
Is there a way you can narrow down which NuGet package or library causes this? Can you file a new issue with an MSBuild log?
I think this issue is actually resolved by #2736 (going to close).
Anyone else, please file a new issue, thanks!
Hi @jonathanpeppers ,
After another Visual studio 2019 16.5 update, my app started missing in 3 packages, before the update compiling with not error.
4> R8 : warning : Missing class: org.apache.commons.digester.AbstractObjectCreationFactory
4> R8 : warning : Missing class: org.apache.commons.digester.Rule
4> R8 : warning : Missing class: javax.swing.tree.TreeNode
I must adopt the solution suggested by #2736 ?
@pbarros1979 the difference you are seeing is that d8 is the default now in 16.5. You would need this in your manifest if you are using org.apache.*:
AndroidManifest.xml:
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
</application>
Note that if your app actually _called_ any org.apache.* classes it would crash at runtime.
An alternative is to revert back to dx, but Google has announced they will completely remove dx in Feb 2021:
.csproj:
<AndroidDexTool>dx</AndroidDexTool>
I disabled MutliDex and that solved my issue. Is that the correct thing to do?
I think it is the correct thing, yeah! since Xamarin.Android implemented the Dex compiler to be the default to D8. This worked for me in all current Android projects.
I think it is the correct thing, yeah! since Xamarin.Android implemented the Dex compiler to be the default to D8.
If that works for you, then sure, but it's not the correct thing. Multidex is a good feature and, in fact, required in some larger projects.
Anyway, I solved the issue by updating all of my Android.Support libraries and Xamarin Forms itself.
Most helpful comment
I managed to workaround this build error in my project by including this in the AndroidManifest.xml (as a child of the application element):
<uses-library android:name="org.apache.http.legacy" android:required="false" />