2015-12-16 24 views
4

我試圖添加到我的Android Studio項目這種依賴https://github.com/hoang8f/android-flat-button和我得到無法在gradle這個添加dependecy(Android Studio中)

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

我能夠加入谷歌輕鬆播放服務的依賴性不任何問題。

下面是我的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' 
} 

解決方案嘗試: - 1)搖籃在聯機模式下無法脫機工作。 2.)清理和建造/重建項目。

3)變更爲

repositories { 
    mavenCentral() 
} 

在我的根文件的gradle

4)工具 - > android->同步項目的gradle與文件

仍然在使其工作沒有運氣。 P:不是它影響問題,我在通過gradle添加解析sdk時面臨同樣的問題,所以我獨立添加了jar文件。

+0

我接着說:編譯「info.hoang8f:fbutton:1.0.5''在我的'build.gradle'和它沒關係,您可以嘗試'建設 - >重建project'。 – tianyu

+0

正如我已經告訴過的問題,我已經清理/重建項目,我的舊項目運行良好,只是新項目給這個問題 – penta

+0

愚蠢的問題,但我需要問?這個圖書館真的有必要嗎?我認爲你可以做你自己的平按鈕像這裏http://stackoverflow.com/questions/26346727/android-material-design-button-styles – piotrek1543

回答

2

添加

repositories { mavenCentral() }

包括Android的標籤

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

nope,不起作用 – penta

1

請試試這個。將fbutton-1.0.5.aar文件添加到lib文件夾中。

repositories { 
     flatDir { 
      dirs 'libs' 
     } 
    } 

將依賴文件添加到文件中。

dependencies { 
    compile(name:'ARFile', ext:'aar') 
} 
+0

nope,這是行不通的,它給出錯誤:(49)沒有找到包'com.example.planner'中的屬性'buttonColor'的資源標識符 錯誤:(49)未找到包'com.example.planner'中的屬性'shadowColor'的資源標識符 錯誤:(49)找不到包'com.example.planner'中包含的屬性'shadowEnabled'的資源標識符 錯誤:(49)在包'com.example.planner' 中找不到包含屬性'shadowHeight'的資源標識符錯誤:(49)未找到屬性'cornerRadius'的資源標識符, com.example.planner' – penta

+0

請檢查:http://stackoverflow.com/questions/5819369/error-no-resource-identifier-found-for-attribute-adsize-in-package-com-googl –

1

你有沒有注意到如何看起來像一個demo項目build.gradlehttps://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' 
} 

檢查,如果您不會錯過在搖籃文件的東西,或者你把一些錯誤

編輯:我已經把你的整個文件的build.gradle到我的新項目,它的做工精細。

如果重建不起作用,創建一個新的乾淨的項目,並把這個build.gradle。告訴我它是否適用於新項目。

EDIT2:

在你的項目中,有兩個build.gradle變化,第二個指向

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() 
    } 
} 
+0

evrything似乎很好,你的鏈接無效 – penta

+0

感謝您的通知,我已編輯我的帖子 – piotrek1543

+0

不,我很抱歉,它仍然無法正常工作,我想我在gradle而不是項目中遇到了一些問題,我試着做一個新項目,我仍然得到同樣的問題 – penta

0

我有同樣的問題。 緩存失效並重新啓動你的android studio。然後同步gradle。

+0

不,對不起兄弟沒有工作 – penta

0

我克隆了項目並使用「demo」模塊來測試lib。你需要的lib已成功下載,並預計,因爲它在我注意到maven repo

唯一點存在 - 也許你可能有gradle這個問題,因爲有runProguard命令,未在gradle這個使用不再。 因此,您可以將其刪除或更改爲minifyEnabled false。

這樣做了以後,示範項目成功組裝

相關問題