4

I try several times to add dependency to my project and each time give error the dependency that I want to add them are 'de.hdodenhof:circleimageview:1.3.0' and 'com.github.bumptech.glide:glide:3.6.1' so I want to download these and add to my project manually is it possible and if Yes How?

Here is my application's build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '24.0.0 rc4'

    defaultConfig {
        applicationId "ir.esfandune.material"
        minSdkVersion 23
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    packagingOptions {
        exclude 'classes.dex'
    }
}

repositories {
    jcenter()
    maven { url "https://oss.sonatype.org/content/repositories/snapshots" }

}

dependencies {
    compile 'com.android.support:design:23.0.0'
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.android.support:cardview-v7:23.0.0'
    compile 'com.android.support:recyclerview-v7:23.0.0'
    compile 'com.android.support:support-v4:23.0.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.github.rey5137:material:1.2.1.6-SNAPSHOT'
    compile project(':material-dialogs')
    compile files('lib/de.hdodenhof/circleimageview/1.3.0/jars/classes.jar')
    //*** added from orginal source
    compile 'de.hdodenhof:circleimageview:1.3.0'
    compile 'com.github.bumptech.glide:glide:3.6.1'
}
4
  • 1
    clone the project from github and add the project as module to your project Jun 9, 2016 at 9:29
  • Why is is not working? It's rarely a good idea to add a library manually. And it seems you already have the circleimage added "manually" compile files('lib/de.hdodenhof/circleimageview/1.3.0/jars/classes.jar'). Also it's added twice, which will fail. Either add as jar or as external dependency, i.e. with compile files remove the compile ' de.hd... part and vice versa.
    – zapl
    Jun 9, 2016 at 9:31
  • @zapl i removed 'de.hd... in first time and gradle sync myproject fine but on the running time give forceclose error for this library
    – afzali
    Jun 9, 2016 at 10:51
  • @afzali what error did you get? (edit your question and include the error messages you get - in the logcat window: stackoverflow.com/a/28476685/995891). And more importantly, when you do it in the intended way (and remove the compile files one instead) what error do you get then? That should be your priority to fix. Not to find workarounds with lots of drawbacks.
    – zapl
    Jun 9, 2016 at 14:27

5 Answers 5

6

download the jar/aar file of your library you want

copy files into libs directory in your app folder for *.jar files: add this code to dependency on your gradle file

 compile files('libs/library.jar')

for *.aar files: try from projectstructure / new module/ import from aar/jar

good luck

3

in your project panel expand the GradleScripts tab. you will see 2 build.gradle file there. open the second one build.gradle(module:app) file. in the end of the file you will see a section like:

dependencies {
    compile 'com.android.support:appcompat-v7:23.0.0'
}

add a new dependency here like this:

dependencies {
    compile 'com.android.support:appcompat-v7:23.0.0'

    //manually added dependency
    compile 'com.android.support:design:23.0.0'
}
1

just copy this in dependencies

 compile 'de.hdodenhof:circleimageview:1.3.0'

and press 'sync project with gradle files' button

Then use it wherever you want by pasting the code below

xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/profile_image"
android:layout_width="96dp"
android:layout_height="96dp"
android:src="@drawable/profile"
app:civ_border_width="2dp"
app:civ_border_color="#FF000000"/>
3
  • my cod contain this!
    – afzali
    Jun 9, 2016 at 10:39
  • yes. Then you have to sync the gradle files.There is a button to do so in studio.
    – Phillen
    Jun 9, 2016 at 14:12
  • abd delete the line compile files('lib/de.hdodenhof/circleimageview/1.3.0/jars/classes.jar')
    – Phillen
    Jun 9, 2016 at 14:13
0

I had a similar problem and as @SaravInfern pointed out in the comments, I solved it by importing the project as a module.

  1. Clone the project.
  2. File -> New -> Import module, and follow the steps.
  3. Let the gradle do all the necessary dependencies download once you import that module.
  4. Open the gradle file of this new module and add apply plugin: 'com.android.library' to it (earlier, it might be com.android.library)
  5. In the dependencies block, add this: compile project(":app") where, app is name of the imported module.

Build the project then. It should build successfully. You can refer to this blog and this SO thread for more elaborate solution.

0
Yes you can manually update the dependencies in build.gradle system 

Just copy any of the existing dependency and rename with yours required dependency..

Example:

dependencies {
    compile 'com.android.support:design:23.0.0'// this is default dependency 
    compile 'de.hdodenhof:circleimageview:1.3.0' // this is your dependency..
 }

Issues your get..
1. android machine warn you to use implements instand of complie..(its a warning ignore it)
2. de.hdodenhof:circleimageview:1.3.0 change of version...(use latest if your using latest then change to lower version).

.@Sunil, Try this It will work....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.