如何解決整合Firebase和Facebook Ad包衝突的問題

來源:互聯網
上載者:User

標籤:android   facebook   firebase   衝突   ad   

手頭開發的APP整合了Facebook Ad jar 包AudienceNetwork.jar,打算更新到其最新版本4.14.1。


刪除本地lib庫裡的老的AudienceNetwork.jar,在app的build.gradle的dependencies裡添加


compile (‘com.facebook.android:audience-network-sdk:4.14.1‘)


編譯報錯如下資訊:


FAILURE: Build failed with an exception.


* What went wrong:

Execution failed for task ‘:transformClassesWithJarMergingForDebug‘.

> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzaa.class


* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


BUILD FAILED


從duplicate entry看是有重複的類被打包導致Excepion,查閱Gradle文檔,可以排除重複檔案打包,接下來的問題是排查下是哪個檔案有問題,從上述資訊看,應該是從com.google.android.gms下的某個類,考慮到之前使用facebook jar單獨打包並沒有發生此問題,那麼就應該是編譯依賴的4.14.1導致的。


到依賴倉庫jcenter的老家Jfrog bintray逛逛,搜尋facebook,找到audience-network-sdk:4.14.1的對應檔案,有2個分別是aar和pom尾碼的檔案,我們只看設定檔就好,如下:


<?xml version="1.0" encoding="UTF-8"?>

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <modelVersion>4.0.0</modelVersion>

  <groupId>com.facebook.android</groupId>

  <artifactId>audience-network-sdk</artifactId>

  <version>4.14.1</version>

  <packaging>aar</packaging>

  <name>Audience-Network-SDK</name>

  <description>Facebook Audience Network SDK for Android</description>

  <url>https://developers.facebook.com/products/app-monetization/audience-network/</url>

  <licenses>

    <license>

      <name>Facebook Platform License</name>

      <url>https://github.com/facebook/facebook-android-sdk/blob/master/LICENSE.txt</url>

      <distribution>repo</distribution>

    </license>

    <license>

      <name>Apache License Version 2.0</name>

      <url>http://www.apache.org/licenses/LICENSE-2.0</url>

      <distribution>repo</distribution>

    </license>

  </licenses>

  <developers>

    <developer>

      <id>facebook</id>

      <name>Facebook</name>

    </developer>

  </developers>

  <scm>

    <url>https://developers.facebook.com/docs/android/downloads</url>

  </scm>

  <dependencies>

    <dependency>

      <groupId>com.google.android.gms</groupId>

      <artifactId>play-services-ads</artifactId>

      <version>8.4.0</version>

      <scope>compile</scope>

    </dependency>

    <dependency>

      <groupId>com.android.support</groupId>

      <artifactId>appcompat-v7</artifactId>

      <version>23.1.0</version>

      <scope>compile</scope>

    </dependency>

    <dependency>

      <groupId>com.android.support</groupId>

      <artifactId>recyclerview-v7</artifactId>

      <version>23.1.0</version>

      <scope>compile</scope>

    </dependency>

  </dependencies>

</project>


顯然,報錯就是在打包play-services-ads時產生的,因為需要整合Firebase,在build.gradle中添加了


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

導致把google服務的全家桶都加了進來,自然也會有廣告服務,衝突由此產生。


找到原因就很好解決了,在編譯時間把重複的去除就可以了。


原build.gradle裡依賴部分:

dependencies {    compile fileTree(: , : [])    compile compile compile compile compile }apply :


更新後:

dependencies {    compile fileTree(: , : [])    compile compile compile compile compile () {        exclude : exclude : exclude : }}apply :



再次編譯,成功!

本文出自 “天藍工作學習手記” 部落格,請務必保留此出處http://pisota.blog.51cto.com/3109961/1835669

如何解決整合Firebase和Facebook Ad包衝突的問題

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.