2017-02-03 114 views
2

我已經安裝了Facebook SDK,沒有錯誤,但我似乎無法將其導出爲我的Android項目的一部分。Android Facebook SDK Eclipse Proguard

Warning: com.facebook.applinks.FacebookAppLinkResolver$2: can't find referenced class bolts.Task$TaskCompletionSource 
Warning: com.facebook.applinks.FacebookAppLinkResolver$2: can't find referenced class bolts.AppLink$Target 
Warning: com.facebook.applinks.FacebookAppLinkResolver$2: can't find referenced class bolts.AppLink 
Warning: com.facebook.applinks.FacebookAppLinkResolver$2: can't find referenced class bolts.AppLink$Target 
Warning: com.facebook.messenger.MessengerUtils: can't find referenced class bolts.AppLinks 
Warning: com.facebook.messenger.MessengerUtils: can't find referenced class bolts.AppLinks 
    You should check if you need to specify additional program jars. 
Warning: there were 62 unresolved references to classes or interfaces. 
     You may need to specify additional library jars (using '-libraryjars'). 
java.io.IOException: Please correct the above warnings first. 
at proguard.Initializer.execute(Initializer.java:321) 
at proguard.ProGuard.initialize(ProGuard.java:211) 
at proguard.ProGuard.execute(ProGuard.java:86) 
at proguard.ProGuard.main(ProGuard.java:492) 

我添加了下面我ProGuard的文件,但我仍然得到錯誤:

-keep class com.facebook.** { 
    *; 
} 

我應該如何配置ProGuard的使用Facebook的SDK使ProGuard的,當我得到下面的錯誤?

回答

0

ProGuard告訴您,Facebook SDK引用bolts包中的類,但ProGuard找不到這些類,因爲很可能您沒有在應用程序中包含Bolts。

爲了解決這個問題,你可以:

  1. 泰爾ProGuard的,通過將行

    -dontwarn bolts.** 
    

    到ProGuard的配置文件,忽略缺失的依賴。這樣做不應該導致問題,因爲Facebook SDK可以在內部檢測Bolts是否存在,並且只在該情況下嘗試使用它。

  2. 添加螺栓作爲項目的依賴度將這些線在你的搖籃文件:

    dependencies { 
        compile 'com.parse.bolts:bolts-tasks:1.4.0' 
        compile 'com.parse.bolts:bolts-applinks:1.4.0' 
    } 
    

選項1,可能是最好的選擇,除非你真正需要的螺栓。

3

我用我的ProGuard-project.txt這些設置:

# Facebook Audience Network 
-keep class com.facebook.ads.** { *; } 
-keep class com.facebook.ads.internal.** { *; } 
-keep class com.google.ads.mediation.facebook.FacebookAdapter {*;} 
-keep class com.google.android.exoplayer.** {*;} 

-dontwarn com.facebook.ads.** 
-dontwarn com.google.android.exoplayer.**