Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle 3.0 "compile" to "implementation" migration doesn't work for fileTree

I'm trying to remove all my lint warnings but I'm stuck with one of the compile to implementation migrations.

If I change this:

    compile fileTree(include: ['*.jar'], dir: 'libs')

to this:

    implementation fileTree(include: ['*.jar'], dir: 'libs')

then the app won't build and I get the following error:

Error:Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath: ... unresolved supertypes: veg.mediaplayer.sdk.MediaPlayer.MediaPlayerCallback

Is this a bug or am I supposed to do something different for fileTree? I couldn't find any explanations looking at the documentation: https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html.

I've changed all the other lines in all gradle files from compile to implementation and they all work fine.

Edit: I should also note that this particular module does have a jar in the lib folder. For modules with no jars it works.

Edit 2: I've noticed that actually it doesn't always happen if there is a jar. I have another module with a jar (that I created) and it works fine. Something must be wrong with the mediaplayersdk.jar.

Given that it's only complaining about the callback that is implemented from a file in the jar, I suppose that is where it's getting stuck.

I also tried with Android Studio 3.1.0-beta1 and gradle 4.4 but it didn't help.

like image 205
Michael Vescovo Avatar asked Jan 31 '18 05:01

Michael Vescovo


People also ask

What is compile FileTree in Gradle?

A FileTree represents a hierarchy of files. It extends FileCollection to add hierarchy query and manipulation methods. You typically use a FileTree to represent files to copy or the contents of an archive. Summarizing, you can include any .

Is compileOnly deprecated?

The compileOnly configuration has been deprecated for resolution.

How to specify dependencies in Gradle?

To add a dependency to your project, specify a dependency configuration such as implementation in the dependencies block of your module's build. gradle file. This declares a dependency on an Android library module named "mylibrary" (this name must match the library name defined with an include: in your settings.


1 Answers

Ok I feel like an idiot now. All I had to do was read the documentation more carefully and I would have seen that api is the equivalent of compile and is supported going forward.

Using api works!

i.e. api fileTree(include: ['*.jar'], dir: 'libs')

like image 135
Michael Vescovo Avatar answered Oct 21 '22 12:10

Michael Vescovo