https://kotlinlang.org logo
#android
Title
# android
a

Akbar

09/05/2019, 10:10 AM
Does anyone know how to include implementation fileTree(dir: 'libs', include: ['*.aar']) in Deps.kt file
g

gildor

09/05/2019, 10:16 AM
include dependency to Deps.kt? What it mean?
Or you mean just declare
fileTree(dir: 'libs', include: ['*.aar'])
?
Copy code
val localLibs = fileTree(mapOf("dir" to "libs", "include" to listOf("*.aar")))
w

wasyl

09/05/2019, 10:20 AM
You need reference to the
Project
instance in order to create
fileTree
. So there are many options, really:
You could declare
localLibs
as function and apply it in the project:
Copy code
Deps.kt:
val localLibs = { project: Project ->
    project.fileTree(dir: 'libs', include: ['*.aar'])
}

project build.gradle:
implementation(Deps.localLibs(project))
a

Akbar

09/05/2019, 10:25 AM
got it thanks alot
whtas it import for Project
its not recognised
w

wasyl

09/05/2019, 10:29 AM
org.gradle.api.Project
a

Akbar

09/05/2019, 10:30 AM
its giving this error
w

wasyl

09/05/2019, 10:31 AM
Right, at first I thought you were asking about groovy for some reason
a

Akbar

09/05/2019, 10:31 AM
nope
w

wasyl

09/05/2019, 10:31 AM
Andrey pasted proper syntax for fileTree function in Kotlin
a

Akbar

09/05/2019, 10:35 AM
ok but how to mention it in dependencies.gradle file
w

wasyl

09/05/2019, 10:36 AM
You’re not really providing enough details to be able to help you. Perhaps this problem is better suited for stackoverflow
6 Views