cordova-plugin-accountkit
cordova-plugin-accountkit copied to clipboard
AndroidManifest string duplicates when using with cordova-plugin-facebook4
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
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...
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.
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.
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.
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.
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?
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.
@gurisko best way is to add prefix like you suggested akp_ why not
@mohamedsharaf Doesn't it fail at the next build step :processDebugManifest after your changes?
@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
@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 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 thx will wait your help i dont have any problem modifing JSon file manually
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
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?
@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
@gurisko is there any solution for this problem?
I need too
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!
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
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
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.
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 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.
So I found a pretty straightforward workaround.
- 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
- 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
Post code u made for the build hook here if u can
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
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:
- edit the file in the following path: "platforms\android\android.json"
- search the file "app/src/main/res/values/facebookconnect.xml"
- 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