2017-02-03 116 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.**