Skip to content

D8-R8 fails with Missing class error without enough information #2670

Closed

Description

@EmilAlipiev

I have enabled d8 and r8, disabled multidex and proguard. my configuration file can be seen here.
https://gist.github.com/EmilAlipiev/3ca3f0df6e054703d379250dd9237219

Project has definetly no reference mentioned classes in warnings below. I dont understand why do i get those warnings.

8>  R8 : warning : Missing class: com.amazon.device.messaging.ADMMessageReceiver
8>  R8 : warning : Missing class: com.amazon.device.messaging.ADMMessageHandlerBase
8>  R8 : warning : Missing class: com.amazon.device.iap.PurchasingListener
8>  R8 : warning : Missing class: org.apache.http.client.methods.HttpEntityEnclosingRequestBase

I dont even know if actually error mentioned in the log file related to those or some other classes

(Rebuild;BuiltProjectOutputGroup;BuiltProjectOutputGroupDependencies;DebugSymbolsProjectOutputGroup;DebugSymbolsProjectOutputGroupDependencies;DocumentationProjectOutputGroup;DocumentationProjectOutputGroupDependencies;SatelliteDllsProjectOutputGroup;SatelliteDllsProjectOutputGroupDependencies;SGenFilesOutputGroup;SGenFilesOutputGroupDependencies target) (1) ->
8>(_CompileToDalvikWithD8 target) -> 
8>  R8 : error : Compilation can't be completed because some library classes are missing.

see attached sample project
App1.zip

Activity

  1. added
    bug
    Area: App+Library Build
    on Jan 30, 2019
  2. added this to the d16-1 milestone on Jan 30, 2019
  3. EmilAlipiev commented on Jan 30, 2019

    @EmilAlipiev
    Author

    Problem seems to be with the onesignal nuget package referencing those namespaces and classes. please see the repro attached. it is still not clear for me why r8 returns warning or error for those. because i dont want to keep those classes and no where in my project, i access them.

  4. jonathanpeppers commented on Feb 21, 2019

    @jonathanpeppers
    Member

    org.apache.httpclient

    Part of this error is solved by: #2736

    After adding to AndroidManfest.xml:

    <application android:label="App1.Android">
    	<uses-library android:name="org.apache.http.legacy" android:required="false" />
    </application>
    

    Errors about org.apache.http go away: R8 : warning : Missing class: org.apache.http.client.methods.HttpEntityEnclosingRequestBase

    It will be coming in a future VS 2019 release.

    Amazon

    First I downloaded the Amazon SDKs here: https://developer.amazon.com/sdk-download

    I put these two jar files in the Android project:

    • amazon-device-messaging-1.0.1.jar
    • in-app-purchasing-2.0.76.jar

    Then I added to my csproj:

    <ItemGroup>
        <AndroidExternalJavaLibrary Include="amazon-device-messaging-1.0.1.jar" />
        <AndroidExternalJavaLibrary Include="in-app-purchasing-2.0.76.jar" />
    </ItemGroup>

    What this does is pass -libraryjar to proguard and -lib to r8. It allows these command-line tools to know about these libraries, but they won't get included in your final APK.

    What can you do now? About the org.apache.httpclient thing?

    You can find C:\Program Files (x86)\Android\android-sdk\platforms\android-28\optional\org.apache.http.legacy.jar. Include it in your Android project the same way as the Amazon stuff:

    <AndroidExternalJavaLibrary Include="org.apache.http.legacy.jar" />

    You will also need the AndroidManifest.xml changes. Here is a full project that worked for me with VS 2019 Preview 3: App1.zip

    Hope this solves your issue!

  5. added a commit that references this issue on Feb 21, 2019
  6. softlion commented on Mar 27, 2020

    @softlion

    Another quicker solution is to enable D8 as dex compiler, and R8 as code shrinker, and disable multidex in debug mode only.
    All warnings will disappear as these missing classes are not used anyway, and will be optimized away by R8.

  7. ghost locked as resolved and limited conversation to collaborators on Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area: App+Library Buildbug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions