TransWikia.com

Gradle Issue when trying to add local library

Stack Overflow Asked by ilovesomething23 on December 11, 2021

I’m trying to add a local library(in this case it is Butterknife, yes I know it is deprecated) and I’m having some trouble.

apply plugin: 'com.android.library'
apply plugin: 'com.jakewharton.butterknife'
buildscript {
repositories {
    jcenter()
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
    maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
    google()
}
dependencies {
    classpath "com.android.tools.build:gradle:3.6.1"
    classpath files('libs/butterknife-gradle-plugin-10.2.1.jar')
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'], excludes: ['butterknife-compiler-10.2.1.jar', 'butterknife-gradle-plugin-10.2.1.jar'])
api fileTree(dir: 'libs', include: ['*.aar'])
annotationProcessor files('libs/butterknife-compiler-10.2.1.jar')

This is how the relevant part of my gradle looks, and to the libs directory I added the following locally(downloaded from maven): butterknife-10.2.1.aar , butterknife-annotations-10.2.1.jar , butterknife-compiler-10.2.1.jar , butterknife-gradle-plugin-10.2.1.jar, butterknife-runtime-10.2.1.aar .
I know I could add the library another way but I need to do it from the local files. The Gradle sync is succesful, then when I try to run the app I get the following errors:

Unable to load class 'butterknife.OnCheckedChanged'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)

The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)

Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

One Answer

Instead of trying to add manually each library I found an alternative https://docs.gradle.org/current/userguide/dependency_management.html#sub:cache_copy This helped me achieve what I wanted

Answered by ilovesomething23 on December 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP