1

我的Android應用程序的build.gradle文件中存在以下依賴項。Build.gradle不同步Android Studio

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    compile files('libs/mxparser.jar') 

    // View dependency injection library by Jake Wharton 
    compile 'com.jakewharton:butterknife:8.5.1' 
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' 

    // apt command comes from the android-apt plugin 
    compile 'com.google.dagger:dagger:2.9' 
    annotationProcessor "com.google.dagger:dagger-compiler:2.9" 
    provided 'javax.annotation:jsr250-api:1.0' 

    // Crash reporting SDK 
    compile('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
     transitive = true; 
    } 
} 

但是當我添加Crashlytics的依賴,我得到以下錯誤:

Error:Failed to resolve: annotationProcessor 
Failed to resolve: com.crashlytics.sdk.android:crashlytics:2.6.7 

項目的build.gradle:

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.3.0' 
     classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1' 

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

回答

1

確保您已經添加

apply plugin: 'io.fabric' 

repositories { 
    maven { url 'https://maven.fabric.io/public' } 
} 

添加到您應用的build.gradle文件,否則Crashlytics不會解決並給出奇怪的錯誤。