简体   繁体   English

Android Facebook SDK Eclipse Proguard

[英]Android Facebook SDK Eclipse Proguard

I've installed the Facebook SDK and has no errors but I can't seem to export it as part of my android project. 我已经安装了Facebook SDK,并且没有错误,但似乎无法将其导出为我的android项目的一部分。 I get the below error when enabling ProGuard: 启用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)

I added the below to my ProGuard file but I still get the error: 我将以下内容添加到我的ProGuard文件中,但仍然出现错误:

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

How should I configure ProGuard to use the Facebook SDK? 如何配置ProGuard以使用Facebook SDK?

I am using these settings in my proguard-project.txt: 我在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.**

ProGuard is telling you that the Facebook SDK references classes in the bolts package but ProGuard can't find those classes because, most likely, you're not including Bolts in your application. ProGuard告诉您,Facebook SDK引用了bolts包中的类,但ProGuard找不到这些类,因为很可能您的应用程序中没有包含Bolts。

To fix this, you can either: 要解决此问题,您可以:

  1. Tell ProGuard to ignore the missing dependency by adding the line 通过添加以下行来告诉ProGuard忽略缺少的依赖项

     -dontwarn bolts.** 

    to the ProGuard configuration file. 到ProGuard配置文件。 Doing this shouldn't cause a problem because the Facebook SDK can detect internally whether Bolts is present and only try to use it in that case. 这样做不会造成问题,因为Facebook SDK可以在内部检测是否存在Bolts,并且仅在这种情况下才尝试使用它。

  2. Add Bolts as a dependency of your project by putting these lines in your Gradle file: 通过将以下几行添加到Gradle文件中,将Bolts添加为项目的依赖项:

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

Option 1 is probably the best choice unless you actually need Bolts. 除非您确实需要螺栓,否则选项1可能是最佳选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM