2017-10-15 63 views
1

我試圖在我的Android應用程序中使用EmojiCompat支持庫。當我添加-com.android.support:support-emoji:26.1.0 - 在應用程序的Gradle模塊的依賴關係,並嘗試同步它,我得到下面的錯誤 -無法將EmojiCompat庫(com.android.support:support-emoji:26.1.0)添加到我的應用程序gradle

Error:(31, 13) Failed to resolve: com.android.support:support-emoji:26.1.0 

下面是我的build.gradle(

apply plugin: 'com.android.application' 
 

 
android { 
 
    compileSdkVersion 26 
 
    buildToolsVersion "26.0.2" 
 
    defaultConfig { 
 
     applicationId "example.example.com.emojis2" 
 
     minSdkVersion 19 
 
     targetSdkVersion 26 
 
     versionCode 1 
 
     versionName "1.0" 
 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
 
    } 
 
    buildTypes { 
 
     release { 
 
      minifyEnabled false 
 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
 
     } 
 
    } 
 
} 
 

 
dependencies { 
 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
 
     exclude group: 'com.android.support', module: 'support-annotations' 
 
    }) 
 
    compile 'com.android.support:appcompat-v7:26.+' 
 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 
 
    testCompile 'junit:junit:4.12' 
 
    //adding lib 
 

 
    compile 'com.android.support:support-emoji:26.1.0' 
 
}
- 以下項目模塊)

// Top-level build file where you can add configuration options common to all sub-projects/modules. 
 

 
buildscript { 
 
    repositories { 
 
     jcenter() 
 
     maven { url 'https://maven.google.com' } 
 
    } 
 
    dependencies { 
 
     classpath 'com.android.tools.build:gradle:2.3.3' 
 

 
     // NOTE: Do not place your application dependencies here; they belong 
 
     // in the individual module build.gradle files 
 
    } 
 
} 
 

 
allprojects { 
 
    repositories { 
 
     jcenter() 
 
    } 
 
} 
 

 
task clean(type: Delete) { 
 
    delete rootProject.buildDir 
 
}

gradle.script(應用模塊)

我在想什麼,請有人幫忙!在此先感謝...

+0

@Gabriele - 這不是一個重複的問題。在你提到的問題中,圖書館與這裏提到的不同。 –

+0

相同的答案適用於所有支持庫。 –

+0

添加*谷歌()*這樣在*項目級別搖籃*這樣 'buildscript { 庫{ 谷歌() jcenter() } 依賴性{ 類路徑「com.android.tools.build:gradle :3.0.0-alpha9' //注意:不要在這裏放置您的應用程序依賴關係;他們屬於 //各個模塊的build.gradle文件 }} allprojects { 庫在{ 谷歌() jcenter() }} 任務乾淨(類型:刪除){ 刪除rootProject。 buildDir }' –

回答

1

Error:(31, 13) Failed to resolve: com.android.support:support-emoji:26.1.0

你應該在你項目級別build.gradle部分添加此。

allprojects { 
     repositories { 
      jcenter() 
      maven { url 'https://maven.google.com' } 
     } 
    } 

DEMO

buildscript { 
    repositories { 
     jcenter() 
     // You need to add the following repository to download the new plugin. 
     maven { url 'https://maven.google.com' } 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.3.3' 

    } 
} 

allprojects { 
    repositories { 
     jcenter() 
     maven { url 'https://maven.google.com' } 
    } 
} 

FYI

要將它們添加到您的構建,需要首先包括Google's Maven repository在頂層build.gradle文件:

allprojects { 
    repositories { 
     google() 

     // If you're using a version of Gradle lower than 4.1, you must instead use: 
     // maven { 
     //  url 'https://maven.google.com' 
     // } 
     // An alternative URL is 'https://dl.google.com/dl/android/maven2/' 
    } 
} 
+0

對不起,沒有幫助。我更新了我的問題與應用程序模塊和項目模塊的階梯。謝謝你的時間。你能檢查一下嗎? –

+1

@Paathak您已添加到錯誤的倉庫區 –

+1

@IntelliJAmiya - 是的!謝謝,它的工作... :)試圖讓你知道通過upvote。我是新手,在SO上的聲譽非常低。所以它說它已經註冊了我的反饋,但不能增加投票數。再次感謝:) –

相關問題