Capacitor: @Strings of cordova plugins (i.e. cordova-plugin-facebook4)

Created on 29 Jun 2018  路  8Comments  路  Source: ionic-team/capacitor

Hello everyone and thanks for your work!

I have trouble set plugin related @strings to our project.

For example the cordova-plugin-facebook4 plugin required 2 @strings:

<string name="fb_app_id">123456789</string>
<string name="fb_app_name">CompagnyName</string>

If I set them in android/app/src/main/res/values/strings.xml I get

error: resource string/fb_app_id (aka com.my.app:string/fb_app_id) not found.
Message{kind=ERROR, text=error: resource string/fb_app_id (aka com.my.app:string/fb_app_id) not found., sources=[android/app/build/intermediates/manifests/full/debug/AndroidManifest.xml:111], original message=, tool name=Optional.of(AAPT)}

otherwise if I set them in node_modules/@capacitor/cli/assets/capacitor-android-plugins/src/main/res/values/facebookconnect.xml it's work ! But unfortunetly it's will be erased at the next cap sync

I have the same kind of issue with google-map-plugins that require key to work.

Is there anyway to make the configuration persistant?

Thanks

cordova-compat

Most helpful comment

@PapyElGringo change your platforms/android/app/src/main/res/values/strings.xml to (worked to me):

<?xml version='1.0' encoding='utf-8'?>
<resources>
    <string name="app_name">Melhor da Vez</string>
    <string name="launcher_name">@string/app_name</string>
    <string name="activity_name">@string/launcher_name</string>
    <string name="fb_app_id">ID</string>
    <string name="fb_app_name">APP_NAME</string>
</resources>

All 8 comments

@PapyElGringo change your platforms/android/app/src/main/res/values/strings.xml to (worked to me):

<?xml version='1.0' encoding='utf-8'?>
<resources>
    <string name="app_name">Melhor da Vez</string>
    <string name="launcher_name">@string/app_name</string>
    <string name="activity_name">@string/launcher_name</string>
    <string name="fb_app_id">ID</string>
    <string name="fb_app_name">APP_NAME</string>
</resources>

Sorry but are you suggesting me to put it where it's don't work for me? ^^
platforms/ is cordovq only no?

For me, adding them to the apps string file is working fine. Just had to sync gradle first, and then run. Can you try with latest version of Capacitor?

Hi,
I am developing an application which has linkedin authentication and I am using ionic capacitor. I installed the cordova plugin without any installation variables as capacitor doesn't support it. My question is that where do I put in the installation variables for ios and android and in what tag? Like for facebook app id we use the following tag.

I want to use the following plugin.
https://ionicframework.com/docs/native/linkedin/

what are the strings I need to add for googleplus plugin in capacitor?

I'm going to close this as for me it worked to add them to the strings.xml

For other plugins, better go to the forum or slack as those are not really capacitor issues but questions related to Cordova plugins. Or at least create separate issues to have things organized.

As rule of thumb, what I do is to check the plugin.xml and see what the plugin does with the variables, it usually writes to strings.xml and info.plist and you can see such things in the plugin.xml

you need to just add this in config.xml as the latest facebook4 plugin doesn't do it by itself for some reason. As directly updating strings.xml is not advisable So we should rather do it through config.xml

<config-file parent="/resources" target="./res/values/strings.xml">
        <string name="fb_app_id">12345</string>
        <string name="fb_app_name">App Name</string>
    </config-file>

I don鈥檛 think that works as we don鈥檛 read the config.xml

Editing the project鈥檚 strings.xml file is advisable in capacitor

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stripathix picture stripathix  路  3Comments

json-derulo picture json-derulo  路  3Comments

ebk46 picture ebk46  路  3Comments

TayKara picture TayKara  路  3Comments

json-derulo picture json-derulo  路  3Comments