Wizcorp / phonegap-facebook-plugin

The official plugin for Facebook in Apache Cordova/PhoneGap
Other
1.91k stars 2.01k forks source link

Plugin incompatible in Android: https://github.com/phonegap-build/PushPlugin.git #1028

Open danicastanos opened 9 years ago

danicastanos commented 9 years ago

When the two plugins are added to the project in Android this error is shown (in iOS works perfectly): exec] UNEXPECTED TOP-LEVEL EXCEPTION: [exec] com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl; [exec] at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596) [exec] at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554) [exec] at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535) [exec] at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171) [exec] at com.android.dx.merge.DexMerger.merge(DexMerger.java:189) [exec] at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454) [exec] at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303) [exec] at com.android.dx.command.dexer.Main.run(Main.java:246) [exec] at com.android.dx.command.dexer.Main.main(Main.java:215) [exec] at com.android.dx.command.Main.main(Main.java:106) [exec] [exec] :dexRelease FAILED [exec] [exec] BUILD FAILED [exec] [exec] Total time: 30.975 secs [exec] [exec] FAILURE: Build failed with an exception. [exec] [exec] * What went wrong: [exec] Execution failed for task ':dexRelease'. [exec] > com.android.ide.common.internal.LoggedErrorException: Failed to run command: [exec] /Users/danicastanos/Library/Android/sdk/build-tools/22.0.1/dx --dex --output /Users/danicastanos/Documents/koala/app/platforms/android/build/intermediates/dex/release --input-list=/Users/danicastanos/Documents/koala/app/platforms/android/build/intermediates/tmp/dex/release/inputList.txt [exec] Error Code: [exec] 2 [exec] Output: [exec] [exec] UNEXPECTED TOP-LEVEL EXCEPTION: [exec] com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl; [exec] at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596) [exec] at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554) [exec] at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535) [exec] at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171) [exec] at com.android.dx.merge.DexMerger.merge(DexMerger.java:189) [exec] at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454) [exec] at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303) [exec] at com.android.dx.command.dexer.Main.run(Main.java:246) [exec] at com.android.dx.command.dexer.Main.main(Main.java:215) [exec] at com.android.dx.command.Main.main(Main.java:106) [exec] [exec] [exec] [exec] * Try: [exec] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. [exec] ERROR building one of the platforms: Error: /Users/danicastanos/Documents/koala/app/platforms/android/cordova/build: Command failed with exit code 8 [exec] You may not have the required environment or OS to build this project [exec] [exec] /Users/danicastanos/Documents/koala/app/platforms/android/cordova/node_modules/q/q.js:126 [exec] throw e; [exec] ^ [exec] Error code 1 for command: /Users/danicastanos/Documents/koala/app/platforms/android/gradlew with args: cdvBuildRelease,-b,/Users/danicastanos/Documents/koala/app/platforms/android/build.gradle,-Dorg.gradle.daemon=true [exec] Error: /Users/danicastanos/Documents/koala/app/platforms/android/cordova/build: Command failed with exit code 8 [exec] at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23) [exec] at ChildProcess.emit (events.js:98:17) [exec] at maybeClose (child_process.js:766:16) [exec] at Process.ChildProcess._handle.onexit (child_process.js:833:5)

clod986 commented 9 years ago

+1 I've been working on this for a day now

kaansoral commented 9 years ago

I've been working on this for a week, it's still one or the other for me, on android

I guess the logical thing to do is to use an older version of the fb plugin/sdk

augustoabreu commented 9 years ago

My solution:

rm -rf platforms/android/com.phonegap.plugins.facebookconnect/FacebookLib/libs/android-support-v4.jar
cp plugins/com.phonegap.plugins.PushPlugin/src/android/com/plugin/android-support-v13.jar platforms/android/com.phonegap.plugins.facebookconnect/FacebookLib/libs/

Change android:minSdkVersion to 14 on file AndroidManifest.xml of FB Connect (platforms/android/com.phonegap.plugins.facebookconnect/FacebookLib):

<uses-sdk android:minSdkVersion="14" />

I also did the same at platforms/android/AndroidManifest.xml

julienbrument commented 9 years ago

After replace android-support-v4.jar by https://github.com/MobileChromeApps/cordova-plugin-android-support-v4, delete android-support-v13.jar from /platforms/android/libs. Works for me ! (with latest cordova )

mladenp commented 9 years ago

It still not working for me, i replaced fb android support jar with pushPlugins and upgraded minSdk version.

julienbrument commented 9 years ago

fb android need v4 support, not working with v13

kaansoral commented 9 years ago

I've tried various combinations, alternatives, solutions suggested over different versions of the plugins, none worked

augustoabreu commented 9 years ago

I'm using:

Build pass on:

My project files:

platforms/android/libs/gcm.jar

com.phonegap.plugins.facebookconnect/FacebookLib/libs/android-support-v13.jar
com.phonegap.plugins.facebookconnect/FacebookLib/libs/bolts-android-1.1.2.jar

File AndroidManifest.xml:

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="30011" android:versionName="3.0.11" package="YOUR_APP_PACKAGE" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="CordovaApp" android:screenOrientation="portrait" android:theme="@android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/fb_app_id" />
        <activity android:label="@string/fb_app_name" android:name="com.facebook.LoginActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" />
        <activity android:exported="true" android:name="com.plugin.gcm.PushHandlerActivity" />
        <receiver android:name="com.plugin.gcm.CordovaGCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <category android:name="YOUR_APP_PACKAGE" />
            </intent-filter>
        </receiver>
        <service android:name="com.plugin.gcm.GCMIntentService" />
    </application>
    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <permission android:name="br.com.experimento.myexp.permission.C2D_MESSAGE" android:protectionLevel="signature" />
    <uses-permission android:name="br.com.experimento.myexp.permission.C2D_MESSAGE" />
</manifest>

File project.properties:

target=android-22
android.library.reference.1=CordovaLib
android.library.reference.2=com.phonegap.plugins.facebookconnect/FacebookLib

File com.phonegap.plugins.facebookconnect/FacebookLib/AndroidManifest.xml:

<?xml version='1.0' encoding='utf-8'?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.facebook.android">
    <application/>
    <uses-sdk android:minSdkVersion="14" />
</manifest>

File com.phonegap.plugins.facebookconnect/FacebookLib/project.properties:

android.library=true
target=android-22
sgrebnov commented 9 years ago

I've sent the following fix: https://github.com/Wizcorp/phonegap-facebook-plugin/pull/1032

mladenp commented 9 years ago

@augustoabreu example is working fine, just note that in main AndroidManifest you have minSDK set to 19 not 22, so that might be a problem for some peope.. but if you set minSDK in config.xml manifest will be updated.

aivarsak commented 9 years ago

@julienbrument solution worked for me (replace android-support-v4.jar in facebook plugin)

shprink commented 9 years ago

+1

JijeshP commented 9 years ago

if not working try this after making those changes, worked for me.

cordova platform rm android
cordova platfrom add android