Chad Bingham
Chad Bingham

Reputation: 33846

Gradle Build Failure: Couldn't find outer class

When trying to build, I get this stacktrace:

Exception in thread "main" java.lang.NullPointerException: Couldn't find outer class com/xxx/CheckListPresenter$onAttached$1$5 of com/xxx/CheckListPresenter$onAttached$1$5$1
    at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:1079)
    at com.google.devtools.build.android.desugar.ClassVsInterface.isOuterInterface(ClassVsInterface.java:56)
    at com.google.devtools.build.android.desugar.InterfaceDesugaring.visitOuterClass(InterfaceDesugaring.java:246)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:638)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:500)
    at com.google.devtools.build.android.desugar.Desugar.desugarClassesInInput(Desugar.java:477)
    at com.google.devtools.build.android.desugar.Desugar.desugarOneInput(Desugar.java:361)
    at com.google.devtools.build.android.desugar.Desugar.desugar(Desugar.java:314)
    at com.google.devtools.build.android.desugar.Desugar.main(Desugar.java:711)

I checked the CheckListPresenter class and there doesn't appear to have any issues. I tried deleting the class just to see if it would build, but the error just moved on to another class stating the same issue.

The last time I touched this code was a good few months ago, so I am not sure what triggered the change.

Things that may matter: This is an Android project. This is written in Kotlin. This fails on the transformClassesWithDesugarForDebug gradle task


Edits

These are all just stabs in the dark I tried:

Here is my build scan for what good it will do

New discovery:

This is the snippet of code that is killing me:

view?.let { v ->
    v.getCancelClicks()
        .doOnSubscribe({ disposables.add(it) })
        .subscribe({
           v.showExitDialog()
              .filter { it }
              .subscribe({
                 cancel()
            }, this::onError)
           
         }, this::onError)
    }

What is strange, is neither one of these alone will give me issues

view?.let { v ->
    v.getCancelClicks()
        .doOnSubscribe({ disposables.add(it) })
        .subscribe({
            //removed 
         }, this::onError)
    }
}

or

view?.let { v ->
    v.showExitDialog()
        .filter { it }
        .subscribe({
           cancel()
        }, this::onError)
 }

But together they are a problem.

Something else of note, view is defined in the base class and is a generic.

Currently, my work around is to remove view?.let{ and just use view!!. This is obviously a bug, but I am not sure who to report it to. Gradle, Kotlin, JetBrains, God?

Upvotes: 12

Views: 2003

Answers (4)

yunik
yunik

Reputation: 53

The issue is filed here https://issuetracker.google.com/issues/72750890. Both solutions mentioned there worked for me: adding classpath 'com.android.tools.build:gradle:3.0.1' to build.gradle or adding android.enableD8.desugaring=true to gradle.properties

Upvotes: 1

Aleksandr Urzhumtcev
Aleksandr Urzhumtcev

Reputation: 358

As a workaround you can substitute let by null checking. At least code started to compile after this

if (view!=null)
    view.showExitDialog()
        .filter { it }
        .subscribe({
           cancel()
        }, this::onError)
}

Upvotes: 0

Adrian Blanco
Adrian Blanco

Reputation: 121

The problem resolved itself when I added android.enableD8.desugaring = true to gradle.properties

Upvotes: 12

beokh
beokh

Reputation: 191

I have a way to work around this error: java.lang.NullPointerException: Couldn't find outer class com/iconfitness/iconaudit/common/fragments/SettingsFragment$onCreate$1$1 of com/iconfitness/iconaudit/common/fragments/SettingsFragment$onCreate$1$1$1.

Just move this block code

v.showExitDialog()
              .filter { it }
              .subscribe({
                 cancel()

oo other method. I don't meet this problem anymore. I hope this will help you.

Upvotes: 1

Related Questions