cordova-plugin-accountkit icon indicating copy to clipboard operation
cordova-plugin-accountkit copied to clipboard

AndroidManifest string duplicates when using with cordova-plugin-facebook4

Open uzumakinaruto123 opened this issue 8 years ago • 28 comments
trafficstars

Tried updated version , and it has duplicate string resources.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':mergeDebugResources'.
> [string/fb_app_id] C:\xampp\htdocs\ionic2\AccountTest\platforms\android\res\values\accountkit.xml        [string/fb_app_id] C:
\xampp\htdocs\ionic2\AccountTest\platforms\android\res\values\facebookconnect.xml: Error: Duplicate resources
[string/fb_app_name] C:\xampp\htdocs\ionic2\AccountTest\platforms\android\res\values\accountkit.xml        [string/fb_app_name]
C:\xampp\htdocs\ionic2\AccountTest\platforms\android\res\values\facebookconnect.xml: Error: Duplicate resources

uzumakinaruto123 avatar Jan 06 '17 06:01 uzumakinaruto123

It seems that you are using cordova-plugin-facebook4, aren't you? Did you just add it now or do you really think that this was introduced with v1.2.0? This might be a much bigger problem...

gurisko avatar Jan 06 '17 10:01 gurisko

Yes ! I am using cordova-plugin-facebook4. The previous version of accountkit I tried , I didn't have facebook plugin installed ! I had to comment the duplicate variables in android.json and delete existing ones from one of the string xml's to make it work.

UPDATE :-

Actually , they don't work together if strings duplicate is removed.

uzumakinaruto123 avatar Jan 06 '17 11:01 uzumakinaruto123

Since this can be considered as a common scenario and our plugin is the one at the beginning of its path, we have to fix this on our side.

Probably adding internally some prefixes such as akp_. I don't like it much, but I don't see any other solution.

gurisko avatar Jan 06 '17 14:01 gurisko

For now, there is not much we can do. Even if we change our strings internally to start with a prefix, it will fail at the next build steps (specifically :processDebugManifest) because AndroidManifest.xml will contain duplicates of com.facebook.sdk.ApplicationId and com.facebook.accountkit.ApplicationName. We can't remove any of those settings tho.

Let's keep this open until this bug is resolved in cordova.

gurisko avatar Jan 07 '17 00:01 gurisko

Yeah ! currently I got it working . :) Isn't there a way to keep check on string variable if it exists ? (I have no clue :P ) That way plugin could decide if those string variables are to be created or not. Anyways , till then a doc update will be good for getting rid of those duplicates manually.

uzumakinaruto123 avatar Jan 07 '17 06:01 uzumakinaruto123

hi uzumakinaruto123, how you make it working? i'm facing the same problem. i manage to compile after i remove fb_app_id/name from json and xml. but when i run AccountKitPlugin.loginWithPhoneNumber in android, nothing happened.

Anything i'm missed?

l1nknyto avatar Feb 09 '17 04:02 l1nknyto

Additional info for my previous comment: i couldn't find any log in console, which called either in success or error callback.

Now it's working too. (Account kit UI is show and can working). I don't know what is actually happened. Maybe because of some changes in my facebook app setting.

l1nknyto avatar Feb 09 '17 09:02 l1nknyto

@gurisko best way is to add prefix like you suggested akp_ why not

mohamedsharaf avatar Jul 13 '17 13:07 mohamedsharaf

@mohamedsharaf Doesn't it fail at the next build step :processDebugManifest after your changes?

gurisko avatar Jul 13 '17 14:07 gurisko

@gurisko i am not really sure if it will fail i think :processDebugManifest fail in different sdk version

but if it will break just make this release as version 2 of the plugin but I think no one will go for account kit before he passes through the Facebook login so what u think

mohamedsharaf avatar Jul 13 '17 14:07 mohamedsharaf

@gurisko i can confirm you it fails in :mergeDebugResources any suggestion i am not android expert on how to solve this i just need it to work

do u think if i changed plugin name will make this work ?

mohamedsharaf avatar Jul 13 '17 14:07 mohamedsharaf

@mohamedsharaf Changing the plugin name won't help either. You can make this work by changing the generated JSON somewhere in Android folder. I will have my hands on my laptop in about 2 hours and I will try to give you more specific steps.

gurisko avatar Jul 13 '17 14:07 gurisko

@gurisko thx will wait your help i dont have any problem modifing JSon file manually

mohamedsharaf avatar Jul 13 '17 20:07 mohamedsharaf

i tried to change string names with prefix the problem will reside in the android

i think this is android bug

i fot it to work by manually modifing files

mohamedsharaf avatar Jul 20 '17 19:07 mohamedsharaf

Since this question depends on an Apache Cordova bug ...

Is there any alternative to running cordova projects fast? Just like ionic cordova run android or cordova run android

If there is an alternative to this question could they make it clear to users of the plugin?

allansduarte avatar Sep 14 '17 15:09 allansduarte

@gurisko , thanks for the great job you've done so far. Do you have any insights on if and when this bug could be resolved? I have your plugin running and am keen to use the Facebook4 native plugin in parallel.

Kind regards

caskes avatar Sep 26 '17 09:09 caskes

@gurisko is there any solution for this problem?

lucasgalli avatar Nov 08 '17 19:11 lucasgalli

I need too

adrianovcar avatar Nov 21 '17 14:11 adrianovcar

Add string resources into (I am using linux ubuntu this is my ionic project path) file : /home/user/js/fb4/platforms/android/app/src/main/res/values/strings.xml

<string name="fb_app_id">59523234234</string>
<string name="fb_app_name">hajmo.ba</string>

and my project now works!

nezirz avatar Dec 30 '17 13:12 nezirz

no any solution for this until now ? i'm using ionic , and i'm using cordova-plugin-facebook4 with cordova-plugin-accountkit and i'm still getting error. thanks for advance

YousefRabieKhalil avatar Mar 15 '18 09:03 YousefRabieKhalil

Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.

java.io.IOException: Can't write [<project_path>/platforms/android/app/build/intermediates/multi-dex/debug/componentClasses.jar] (Can't read [<project_path>/platforms/android/app/build/intermediates/transforms/desugar/debug/54.jar(;;;;;;**.class)] (Duplicate zip entry [54.jar:android/support/v7/app/ActionBar$DisplayOptions.class]))

Getting this error after placing --

<string name="fb_app_id">2107.....5215</string>
<string name="fb_app_name">MyApp</string>

in this file <project_path>/platforms/android/app/src/main/res/values/strings.xml in my Ionic 3 project

Debnarayan avatar Mar 23 '18 11:03 Debnarayan

I have a suggestion on this front. You could split this plugin into 2 plugins. The second plugin is responsible for setting the 2 conflicting strings mentioned earlier. That way, one could use both plugins if only using this plugin, or just the first of also using the facebook4 plugin. I've seen this approach used in firebase cordova plugins, where a separate plugin is used to load google-services.json and is depended on by all the other firebase plugins.

loban avatar May 01 '18 17:05 loban

i ended up with fork of this plugin that works with facebook4 simple modification u can install my version

cordova plugin add https://github.com/mohamedsharaf/cordova-plugin-accountkit.git --save
--variable APP_ID="123456789"
--variable APP_NAME="myApplication"
--variable CLIENT_TOKEN="abcdefghijklmnopqrstuvwxyz"
--variable API_VERSION="v1.1"

mohamedsharaf avatar May 01 '18 19:05 mohamedsharaf

@mohamedsharaf I tried your solution but getting the following errors. Please help. Thank you.

AAPT: No resource found that matches the given name (at 'value' with value '@string/fpak_app_name'). AAPT: No resource found that matches the given name (at 'value' with value '@string/accountkit_token'). Error: No resource found that matches the given name (at 'value' with value '@string/fpak_app_name'). error: Error: No resource found that matches the given name (at 'value' with value '@string/accountkit_token').

Any help is much appreciated. Thank you.

2xSamurai avatar Dec 18 '18 10:12 2xSamurai

So I found a pretty straightforward workaround.

  1. Remove:

config-file parent="/*" target="app/src/main/res/values/strings.xml" string name="fb_app_id">exampleAppId</string string name="fb_app_name">YourApp</string /config-file

from your config.xml -- this way the ionic build wont keep appending these values into strings.xml

  1. Create a before_build hook which will insert/update the fb_app_id and fb_app_name in the strings.xml android file.

It is not ideal, but it works like a charm.

orzsikodon avatar Feb 27 '19 09:02 orzsikodon

@orzsikodon

Post code u made for the build hook here if u can

mohamedsharaf avatar Feb 27 '19 11:02 mohamedsharaf

my own fix for this problem was to add <string name="accountkit_token">your CLIENT_TOKEN</string> in yourprojectDir\platforms\android\res\values

after that build was successful

myrealjay avatar Apr 11 '19 23:04 myrealjay

Hello, to date this problem is still being presented in ionic 4, I want to use login with facebook and with accountkit, what to do when building the project what creates two files in the path: "platforms\android\app\src\main\res\values":

accountkit.xml:

<?xml version='1.0' encoding='utf-8'?> <resources> <string name="accountkit_token">12345</string> <string name="fb_app_name">nameApp</string> <string name="fb_app_id">1234</string> </resources>

facebookconnect.xml:

<?xml version='1.0' encoding='utf-8'?> <resources> <string name="fb_app_name">nameApp</string> <string name="fb_app_id">1234</string> <bool name="fb_hybrid_app_events">false</bool> </resources>

Giving the following in error in console:

`Execution failed for task ':app:mergeDebugResources'.> [string/fb_app_name] C:\wamp64\www\nameProject\repo\platforms\android\app\src\main\res\values\accountkit.xml
[string/fb_app_name] C:\wamp64\www\nameProject\repo\platforms\android\app\src\main\res\values\facebookconnect.xml: Error: Duplicate resources

[string/fb_app_id] C:\wamp64\www\nameProject\repo\platforms\android\app\src\main\res\values\accountkit.xml
[string/fb_app_id] C:\wamp64\www\nameProject\repo\platforms\android\app\src\main\res\values\facebookconnect.xml: Error: Duplicate resources`

After several days looking for a solution on the internet and not find anything to help in my problem and need to advance my project, what occurred to me was that somehow in these two files these variables were not placed, if I know it's a "hack" solution but I had to find a solution?

What I did was the following:

  1. edit the file in the following path: "platforms\android\android.json"
  2. search the file "app/src/main/res/values/facebookconnect.xml"
  3. edit json staying as follows: "parents": { "/*": [ { "xml": "<bool name=\"fb_hybrid_app_events\">false</bool>", "count": 1 } ] }

save changes and return to build last run on the phone and prove that everything works well. in my case, it works, not what problems this "hack" solution may bring in the future, but for now I could solve this and hope that someone does not know if, from Facebook itself, solve this problem, remember that this process should be done every time that the platform be removed.

Hopefully someone will save you a lot of time with this, and if someone has a better solution please share.

ionic cli 4.12.0 8.1.2 ([email protected]) npm 6.4.1 node v10.15.3

2diegoduque avatar Apr 19 '19 17:04 2diegoduque