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.

penta
  • 2,536
  • 4
  • 25
  • 50
  • 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 '15 at 08: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 '15 at 08:22
  • Stupid question but I need to ask? Is this library really necessary? I think you can do your own flat button like here http://stackoverflow.com/questions/26346727/android-material-design-button-styles – piotrek1543 Dec 16 '15 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 '15 at 03:35

5 Answers5

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()
   }}
hugerde
  • 919
  • 1
  • 12
  • 27
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')
}
Photon Point
  • 798
  • 2
  • 13
  • 23
  • 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 '15 at 08:21
  • Please check this: http://stackoverflow.com/questions/5819369/error-no-resource-identifier-found-for-attribute-adsize-in-package-com-googl – Photon Point Dec 16 '15 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()
    }
}
piotrek1543
  • 19,130
  • 7
  • 81
  • 94
0

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

Prashant Solanki
  • 660
  • 5
  • 10
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

Community
  • 1
  • 1
Silwester
  • 418
  • 5
  • 12