1

我正在尝试为我的 android 应用程序安装 Facebook 广告。

遵循https://developers.facebook.com/docs/getting-started/facebook-sdk-for-android/3.0/中解释的指南。我还从https://github.com/facebook/facebook-android-sdk/archive/sdk-version-3.0.1.b.zip下载了 Facebook-android-sdk

如上述指南中所述,对于此集成,我必须在所有活动的onResume()中编写以下代码:

com.facebook.Settings.publishInstallAsync(this, MY_FACEBOOK_APP_ID);

对于上述集成,我需要 Facebook SDK jar。所以我已将上述项目(Facebook-android-sdk)导入到我的 Eclipse IDE 中,并将其导出为 jar 文件。我已将此新 jar 添加到我的 libs 目录中,该目录也包含在我的 android 应用程序的 Java 构建路径(库)中。

完成上述步骤后,当我尝试调试或运行我的应用程序时,我在控制台中收到以下错误:

[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx 
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/facebook/android/AsyncFacebookRunner$1;
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at com.android.dx.command.dexer.Main.processClass(Main.java:486)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at com.android.dx.command.dexer.Main.processFileBytes(Main.java:455)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at com.android.dx.command.dexer.Main.access$400(Main.java:67)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:394)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at com.android.dx.command.dexer.Main.processOne(Main.java:418)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at com.android.dx.command.dexer.Main.processAllFiles(Main.java:329)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at com.android.dx.command.dexer.Main.run(Main.java:206)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at java.lang.reflect.Method.invoke(Method.java:597)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at com.android.ide.eclipse.adt.internal.build.DexWrapper.run(DexWrapper.java:180)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at com.android.ide.eclipse.adt.internal.build.BuildHelper.executeDx(BuildHelper.java:703)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.build(PostCompilerBuilder.java:577)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:728)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:321)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:396)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at org.eclipse.core.internal.resources.Project$1.run(Project.java:618)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at org.eclipse.core.internal.resources.Project.build(Project.java:124)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at com.android.ide.eclipse.adt.internal.project.ProjectHelper.doFullIncrementalDebugBuild(ProjectHelper.java:1000)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at com.android.ide.eclipse.adt.internal.launch.LaunchConfigDelegate.launch(LaunchConfigDelegate.java:147)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:855)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:704)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1047)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1251)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx     at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Dx 1 error; aborting
[2013-02-21 18:35:09 - com.org.product.view.welcome.WelcomeView] Conversion to Dalvik format failed with error 1

我对上述错误无能为力,我无法调试/运行我的应用程序。

谁能帮我解决这个问题?

4

1 回答 1

0

这是由于 android-support-v4.jar 和我的新 facebook-android-sdk 中的重复依赖问题。

I have created a new jar from the facebook-android-sdk (which uses only the necessary items needed for me) and that fixed.

Thank You.

于 2013-02-21T16:09:59.953 回答