我正在尝试将Facebook登录集成到我的应用程序中。如果我在应用程序的build.gradle文件中添加了以下几行:
repositories {
mavenCentral()
}
在依赖中
compile 'com.facebook.android:facebook-android-sdk:4.2.0'
之后,如果我重建项目,它将成功重建它。但是,当我尝试运行时,它需要很长时间才能构建,然后显示带有文本的对话框:
Failed to complete Gradle execution.
Casue:
尽管Message Gradle Build窗口没有显示任何错误。这是它的输出
Information:Gradle tasks [:app:assembleDebug]
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72220Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2220Library UP-TO-DATE
:app:prepareComAndroidSupportMediarouterV72200Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42220Library UP-TO-DATE
:app:prepareComFacebookAndroidFacebookAndroidSdk420Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAds750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppstate750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesCast750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesDrive750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesFitness750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGames750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGcm750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesIdentity750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesNearby750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPanorama750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPlus750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWallet750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWearable750Library UP-TO-DATE
:app:prepareTextvalidatorLibrary UP-TO-DATE
:app:prepareThreepioLibrary UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:processDebugGoogleServices
File google-services.json is missing from module root folder. The Google Quickstart Plugin cannot function without it.
:app:generateDebugResources
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:preDexDebug
:app:dexDebug
Information:0 errors
Information:0 warnings
Information:See complete output in console
我也将Gradle VM选项修改为
-XX:MaxHeapSize=256m -Xmx256m
,但仍然给出错误。如果我删除依赖关系,它会正常工作。我不确定为什么会这样。
最佳答案
在我的项目目录中执行此命令./gradlew assembleDebug
显示了问题的真正原因。
当我将facebook SDK依赖项添加到我的项目时,它超出了我的dex文件中64K方法的限制。因此,gradle构建失败。
我将multiDexEnabled = true
添加到build.gradle文件的构建类型中。然后从MultiDexApplication而不是Application派生我的自定义应用程序类。
这解决了我的问题。
关于android - Android Facebook集成:无法完成gradle执行。没有理由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30914850/