Closed gabrielfeo closed 5 years ago
You are using a very old Gradle version. Could you try to update to at least Gradle 4.10.2? Or update the Android Gradle Plugin to 3.3.0 and use Gradle 5.2?
On Thu, Feb 7, 2019, 1:44 PM Gabriel Feo notifications@github.com wrote:
Expected Behavior
Declaring a simple statement to include all .jar and all .aar files in the libs folder should enable use of the packaged libraries in the folder from the current module.
dependencies { implementation(fileTree(mapOf("dir" to "libs", "include" to listOf(".jar", ".aar")))) }
Current Behavior
Packaged libraries are not recognized at all. This was tested with the YouTube Player API for Android, packaged as a jar, and with a wearable SDK I have access to, packaged as an aar. However, both packages work if I declare the usual include-everything-from-libs-folder-statement in a separate addLocalDependencies.gradle (not kts) script and declare an apply(from = "addLocalDependencies.gradle") in build.gradle.kts. Context
I'm simply trying to use an aar dependency in my module. My goal is to actually declare the dependency in buildSrc, as I did in this other project https://github.com/gabrielfeo/OpenMovieDbSearch/tree/master/buildSrc, but I tested in the module's build.gradle.kts to see if I could get it work in the regular way at least. Steps to Reproduce (for bugs)
- Add the default include-everything-from-libs-folder-statement, including both jar and aar files, in the build.gradle.kts of the current module:
dependencies { implementation(fileTree(mapOf("dir" to "libs", "include" to listOf(".jar", ".aar")))) }
- Add jar and/or aar packages to a libs folder inside the module folder
- Make project and try to use classes from the local packaged dependencies
Your Environment
- Project Gradle wrapper version: 4.7-all
- Kotlin version used in project: 1.2.71
- Android Gradle plugin version: 3.2.1
- Android Studio info: Android Studio 3.3 Build
AI-182.5107.16.33.5199772, built on December 25, 2018 JRE:
1.8.0_152-release-1248-b01 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o macOS 10.13.6
- Version of the Kotlin Plugin used in Android Studio: 1.3.11-release-Studio3.3-2
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gradle/kotlin-dsl/issues/1342, or mute the thread https://github.com/notifications/unsubscribe-auth/AJwYe3TNfrfTN_MlnMwGpHZz0YAkpStPks5vLB-igaJpZM4anN0Z .
I had some issue with the Kotlin DSL using Android plugin 3.3 with Gradle 5.0, but I can't remember what it was now.
Anyway, I just found out that for some reason I can't write "V2" on the aar name. Does anyone know why this is a problem? Everything works fine if I rename the aar from SmaSdkV2.aar
to SmaSdkV.aar
, SmaSdk2.aar
, etc. The following is now working fine in kts, so I guess this issue should be closed, but I'd really like to know why the "V2" matters.
dependencies {
implementation(group = "", name = "smasdk", ext = "aar")
}
I am still getting this issue. The included aar file is getting added in the library but one level below the code. Has anyone found a solution?
@kaushal-dhruw, what do you mean by "one level below the code"?
Just for future reference here, I was making a big mistake at the time I was having this issue with the dependencies. I was not syncing the Gradle changes on Android Studio, and I was checking whether the dependencies had been included by trying to import new packages on my project classes. I judged the import had failed because the IDE warned me about the import, but I didn't try to compile the project.
The IDE at the time didn't show the "sync needed" message with KTS scripts as it did with Groovy scripts, and for some reason I thought it wasn't necessary with KTS (didn't really understand what syncing was). Syncing is necessary for KTS as well, the IDE needs to configure your build and set up autocomplete and everything.
I recommend not relying on the IDE altogether to see if your script change worked, it's much better to just run assemble on the terminal, and eliminate the risk of forgetting to sync.
A little background: I am creating an android library that produces an aar file when assembled. I want to include another aar file (3rd party) inside my library. Now this works perfectly with groovy scripts in build.gradle when I include the 3rd party aar library in libs folder and use flatDir{dirs 'libs'}
. Recently I switched to Gradle KTS, I imported groovy scripts to Kotlin and I am unable to achieve the same output.
@gabrielfeo I did sync manually. With groovy, my android library is including the aar file in the libs folder and generating the expected file structure, with KTS, the story is something different entirely.
When I unzip my library, it is including the aar in the libs folder of my library but not at the same level it is one level below the code, here is a screenshot of my finder window for more clarity.
I get the classes folder by unarchiving classes.jar.
Expected Behavior
Declaring a simple statement to include all
.jar
and all.aar
files in the libs folder should enable use of the packaged libraries in the folder from the current module.Current Behavior
Packaged libraries are not recognized at all. This was tested with the YouTube Player API for Android, packaged as a jar, and with a wearable SDK I have access to, packaged as an aar. However, both packages work if I declare the usual include-everything-from-libs-folder-statement in a separate
addLocalDependencies.gradle
(not kts) script and declare anapply(from = "addLocalDependencies.gradle")
inbuild.gradle.kts
.Context
I'm simply trying to use an aar dependency in my module. My goal is to actually declare the dependency in buildSrc, as I did in this other project, but I tested in the module's
build.gradle.kts
to see if I could get it work in the regular way at least.Steps to Reproduce (for bugs)
build.gradle.kts
of the current module:Your Environment
4.7-all
1.2.71
3.2.1
Android Studio 3.3 Build #AI-182.5107.16.33.5199772, built on December 25, 2018 JRE: 1.8.0_152-release-1248-b01 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o macOS 10.13.6
1.3.11-release-Studio3.3-2