本文介绍了减小android facebook SDK的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用 facebook sdk 将用户登录到我们的应用程序。但SDK非常大,因此增加了我们的apk大小。由于我们仅使用登录功能,因此我们不需要SDK(共享,信使等)的其他模块。有什么办法可以在项目中添加SDK的必需功能?

We are using facebook sdk to login the users to our app. But the SDK is pretty large hence it is increasing our apk size. Since we use only the login feature we do not require other modules of SDK (share, messenger etc). Is there any way we can add only the required features of SDK in the project?


  • 如果 Google Play服务,已将额外的maven工件添加到包含单一功能域的Google Repository中。这意味着我们可以仅包含您的应用使用的Google Play服务部分。

  • In case of google play services, additional maven artifacts have been added to the Google Repository that contain single domains of functionality.This means that we can include just those portions of Google Play services that your app uses.

依赖关系{
compile'c​​om.google.android.gms:play-services-ads:6.5。+'
}
()

即使twitter已将其面料SDK分解成较小的模块(Core, Crashlytics,Digits,tweetUI等),这对减少apk的大小非常有帮助。


所以尽量找到最适合您的需要的图书馆

  1. There are some Facebook sdk alternatives on GitHub like:https://github.com/greenhalolabs/facebookloginhttps://github.com/sromku/android-simple-facebookSo try to find the best fitted library for your needs

你可以尝试使用较旧的Facebook图书馆,这将更轻,但也缺乏一些功能。

You can try to use older Facebook library, which would be lighter, but also lack of some functions.

在此之前,请阅读以下文章:

Before you do this point read some articles like this: Facebook authentication without login button


  1. Finally, try to exclude unnecessary libs like in this example:

依赖关系{compile('com.facebook.android:facebook-android-sdk:4.3 .0'){
exclude module:'support-v4'}}

dependencies {compile('com.facebook.android:facebook-android-sdk:4.3.0') { exclude module: 'support-v4' } }

这篇关于减小android facebook SDK的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 03:59
查看更多