2016-06-09 81 views
-1

在我的Android應用程序,我需要使用谷歌Analytics(分析)和下面是我的build.gradle文件應用程序的構建提供了錯誤

dependencies { 
    compile 'junit:junit:4.12' 
    compile 'com.android.support:multidex:1.0.1' 
    compile 'com.android.support:appcompat-v7:23.3.0' 
    compile 'com.google.android.gms:play-services:9.0.1' 
    compile 'com.google.android.gms:play-services-analytics:9.0.1' 
    compile 'com.google.code.gson:gson:2.3.1' 
    compile files('libs/android-mads-4.5.8.jar') 
    compile files('libs/ksoap2-android-assembly-3.3.0-jar-with-dependencies.jar') 
    //compile files('libs/libGoogleAnalyticsServices.jar') 
    compile files('libs/picasso-2.5.2.jar') 
    compile 'com.facebook.android:facebook-android-sdk:4.0.0' 

} 
apply plugin: 'com.google.gms.google-services' 

,但我仍然得到以下錯誤

Error:(8, 45) error: package com.google.analytics.tracking.android does not exist

回答

0

請到通過這link

您還沒有在依賴關係中添加Google服務。

com.google.gms:google-services:3.0.0 
+0

您好,我想這需要被添加到項目層面構建文件,我將它 類路徑「com.android.tools.build:gradle:2.2.0-alpha3」 classpath'com.google.gms:google-services:3.0.0' – beginner

+0

是的,它只在classpath中檢查我發送的鏈接中的其他更改。 – KDeogharkar

+0

我已經做了....我的是一樣的描述在你的和下面的答案的鏈接。但這個問題仍然存在。有時在生成後,我也得到這個錯誤錯誤:執行失敗的任務':transformClassesWithJarMergingForDebug'。 > com.android.build.api.transform.TransformException:java.util.zip.ZipException:重複條目:com/google/android/gms/analytics/internal/Command $ 1.class – beginner

0
以下依賴於項目級的build.gradle文件

classpath 'com.google.gms:google-services:3.0.0' 

的插件添加到您的應用程序級別的底部的build.gradle

apply plugin: 'com.google.gms.google-services' 

現在你應該增加對谷歌的依賴

添加Play Services Inside app level build.gradle,添加以下代碼

compile 'com.google.android.gms:play-services-analytics:9.0.0' 

參考:https://developers.google.com/analytics/devguides/collection/android/v4/#set-up-your-project

相關問題