4

I am trying to add this dependency https://github.com/hoang8f/android-flat-button in to my android studio project and I am getting

 Error:(26, 13) Failed to resolve: info.hoang8f:fbutton:1.0.5

I am able to add google play services dependency easily without any problems.

Below is my build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.example.planner"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.google.android.gms:play-services:7.5.0'
    compile 'info.hoang8f:fbutton:1.0.5'
}

Solutions tried:- 1.)Gradle is working in online mode not offline. 2.)Cleaned and builded/rebuilded the project.

3.) Changed to

repositories {
    mavenCentral()
}

in my root gradle file

4.) Tools->android->Sync Project with gradle files

Still no luck in making it work.

P.S.:- Not that it effects the questions, I faced the same problem while trying to add parse sdk via gradle, so I added the jar file independently.

4
  • I added compile 'info.hoang8f:fbutton:1.0.5' in my build.gradle and it's OK, you may try Build->Rebuild project.
    – tianyu
    Dec 16, 2015 at 8:18
  • as i have told in the question, i have already cleaned/ rebuilded the project, my old projects are running fine, just the new project is giving this problem
    – penta
    Dec 16, 2015 at 8:22
  • Stupid question but I need to ask? Is this library really necessary? I think you can do your own flat button like here stackoverflow.com/questions/26346727/… Dec 16, 2015 at 22:49
  • its not about only "this" library, it can effect me some other time when i would try to add another library
    – penta
    Dec 17, 2015 at 3:35

5 Answers 5

1

add

repositories { mavenCentral() }

include android tag

    android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "com.example.planner"
    minSdkVersion 15
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
repositories {
    mavenCentral()
   }}
0
1

Please try this. Add fbutton-1.0.5.aar file into your lib folder.

repositories {
        flatDir {
            dirs 'libs'
        }
    }

Add aar file into dependencies.

dependencies {
    compile(name:'ARFile', ext:'aar')
}
2
  • nope, this does not work, it gives Error:(49) No resource identifier found for attribute 'buttonColor' in package 'com.example.planner' Error:(49) No resource identifier found for attribute 'shadowColor' in package 'com.example.planner' Error:(49) No resource identifier found for attribute 'shadowEnabled' in package 'com.example.planner' Error:(49) No resource identifier found for attribute 'shadowHeight' in package 'com.example.planner' Error:(49) No resource identifier found for attribute 'cornerRadius' in package 'com.example.planner'
    – penta
    Dec 16, 2015 at 8:21
  • Please check this: stackoverflow.com/questions/5819369/… Dec 16, 2015 at 16:26
1

Did you noticed how looks like build.gradle of a demo project? https://github.com/hoang8f/android-flat-button/blob/master/demo/build.gradle

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion '19.1.0'

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 19
        versionCode 2
        versionName "1.1"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    } }

dependencies {
    compile 'com.android.support:appcompat-v7:19.+'
    compile 'com.larswerkman:HoloColorPicker:1.4'
    compile fileTree(dir: 'libs', include: ['*.jar']) //    compile project(':library')
    compile 'info.hoang8f:fbutton:1.0.5'
 }

Check if you're not missing something in your Gradle file or you put something wrong

EDIT: I've put whole your build.gradle file into my new project and it's work fine.

If rebuilding not help, create a new clean project and put this build.gradle. Tell me is it works with new project.

EDIT2:

In your project you have two build.gradle change the second one to

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
        classpath 'com.google.gms:google-services:1.5.0-beta2'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}
3
  • evrything seems fine, your link is invalid
    – penta
    Dec 16, 2015 at 8:26
  • nope, sorry it still does not works, i think i have some problem in gradle rather than project, i tried to make a new project, I still get the same problem
    – penta
    Dec 16, 2015 at 8:48
  • yes, it may be a gradle issue. please check your second build.gradle file Dec 16, 2015 at 8:54
0

I had the same problem. Invalidate cache and restart your android studio. Then sync gradle.

0
0

I cloned the project and used "demo" module to test the lib. The lib that you needed was downloaded successfully and this is expected, because it exists in the maven repo

The only point I noticed - probably you may have problems with gradle, because there's runProguard command, that is not used in gradle no more. So you may just delete it or change to minifyEnabled false.

After doing this, demo project assembles successfully

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.