Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Found item String/google_app_id more than one time #407

Closed
zerdos opened this issue Aug 25, 2017 · 23 comments
Closed

Error: Found item String/google_app_id more than one time #407

zerdos opened this issue Aug 25, 2017 · 23 comments

Comments

@zerdos
Copy link

zerdos commented Aug 25, 2017

Breaking change in the new tag: "cordova-plugin-firebase": "^0.1.24",

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':mergeReleaseResources'.

/Users/zoltan/Developer/myProject/platforms/android/res/values/strings.xml: Error: Found item String/google_app_id more than one time

The content of strings.xml:

<?xml version='1.0' encoding='utf-8'?>
<resources>
    <string name="app_name">My app name</string>
    <string name="launcher_name">@string/app_name</string>
    <string name="activity_name">@string/launcher_name</string>
    <string name="google_app_id">xxxxxxx---xxxxxxx</string>
    <string name="google_api_key">xxxxxxx---xxxxxxx</string>
    <string name="google_app_id">@string/google_app_id</string>
    <string name="google_api_key">@string/google_api_key</string>
</resources>
@zerdos zerdos changed the title Error: Found item String/google_app_id morethan one time Error: Found item String/google_app_id more than one time Aug 25, 2017
@robertarnesson
Copy link
Contributor

you probably have another plugin that is also adding google_app_id and google_api_key

@falcon8823
Copy link

falcon8823 commented Aug 28, 2017

I faced same problem too in 0.1.24. And this problem occurs only release build.
I don't have another plugin that is also adding google_app_id and google_api_key.

@zerdos
Copy link
Author

zerdos commented Aug 28, 2017

To reproduce the issue:

  1. delete the plugins, and platform folder
  2. add the platform android
  3. add the platform ios
  4. try to build the android version

The problem is, that if the ios platform added, then the after_prepare file runs again.
Also it tries:

    copyKey(PLATFORM.IOS);
} else if (directoryExists(ANDROID_DIR)) {
    copyKey(PLATFORM.ANDROID, updateStringsXml)
}

So the copyKey(PLATFORM.ANDROID, updateStringsXml) runs,
it copies the keys, then in the function exception happens, so the callback function won't be called.

@akaushik79
Copy link

Anyone found the solution of this problem. I tried removing few lines from plugin.xml after which build was successful but i saw below error in logs:
GoogleService failed to initialize, status: 10, Missing google app id value from from string resources with name google_app_id.

@inidona
Copy link

inidona commented Aug 30, 2017

hi, i also have this issue, the version 0.1.22 is the last working for me

@pvdyck
Copy link

pvdyck commented Sep 5, 2017

@zerdos confirmed, good analysis.

I was doing cordova platform add android before cordova platform add ios ... now it works.

@Mehuge
Copy link

Mehuge commented Sep 13, 2017

I get this problem every time I do cordova build android, it re-adds the google_app_id / key to res/values/strings.xml every time, and so the build fails.

@dleric
Copy link

dleric commented Sep 15, 2017

@inidona downgrading to 0.1.22 also worked for me.

@fbrun
Copy link
Contributor

fbrun commented Oct 4, 2017

I get the same problem. However, I notice that the content of actual after_prepare is newer than the version of the npm package, though the script was merged in the same date of version ?

@igorPhelype
Copy link

$ cordova clean android worked here

@Mehuge
Copy link

Mehuge commented Oct 18, 2017

The problem I believe is this in the config:-

<config-file parent="/resources" target="res/values/strings.xml">
    <string name="google_app_id">@string/google_app_id</string>
</config-file>
<config-file parent="/resources" target="res/values/strings.xml">
    <string name="google_api_key">@string/google_api_key</string>
</config-file>

Not sure what that is attempting to achieve but I changed mine to

<preference name="API_KEY"/>
<preference name="APP_ID"/>

<config-file parent="/resources" target="res/values/strings.xml">
    <string name="google_app_id">$APP_ID</string>
    <string name="google_api_key">$API_KEY</string>
</config-file>

and I install the plugin by adding

cordova plugin add ../plugins/my-firebase-plugin --variable APP_ID=my-app-id --variable API_KEY=my-api-key

and it works fine now.

@rabinski99
Copy link

I made a change to the cordova-plugin-firebase/scripts/after_prepare.js so that both ios and android get copied if they both exist.

if (directoryExists(IOS_DIR)) {
    copyKey(PLATFORM.IOS);
}

if (directoryExists(ANDROID_DIR)) {
    copyKey(PLATFORM.ANDROID, updateStringsXml);
}

@zstergios
Copy link

Same issue! Any solution?
Firstly I copy the google-services.js after that I add the plugin via cli and and i build it. and I got the above error....

@rabinski99 this a very good suggestion!

@stephdgenius
Copy link

Remove this in strings.xml

<string name="google_app_id">Your API ID</string>
<string name="google_api_key">Your API KEY</string>
<string name="google_app_id">@string/google_app_id</string>
<string name="google_api_key">@string/google_api_key</string>

Work for me

@pamelita04
Copy link

pamelita04 commented Nov 16, 2017

@stephdgenius Excellent! that is the correct solution, delete and nothing else. It worked for me. Thank you very much!

Your API ID
Your API KEY
@string/google_app_id
@string/google_api_key

@harishmahajan
Copy link

@stephdgenius @pamelita04
i removed it, but now i am getting this error.
Error: Cannot set property 'text' of null

@petemcwilliams
Copy link

Updating strings.xml or any file created during the build is not a solution it is a workaround of an issue. We need reliable repeatable builds without manually having to update files.

@Mehuge
Copy link

Mehuge commented Nov 29, 2017

#407 (comment)

Is reliable, and repeatable and doesn't require manually updating files.

@vijeth-ag
Copy link

I removed and re-added android platform, the error( Found item String/google_app_id more than one time) disappeared.

cordova platform rm android
cordova platform add android

@jacquesdev
Copy link

jacquesdev commented Feb 7, 2018

I think I have found the cause of the issue, please see this issue phonegap/phonegap-plugin-push#1660.

Essentially it happens if you are using version < 2.0 of the phonegap-plugin-push cordova plugin, so obviously there is going to be a conflict whatever version of this plugin is used (I tried with 0.1.22, but even that did not work).

Also see https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/INSTALLATION.md#co-existing-with-plugins-that-use-firebase

@robertarnesson
Copy link
Contributor

closing for now, reopen if still an issue with the latest version of the plugin

@Dileep124
Copy link

hi there,
kindly help me please resultTextview always error why?
@OverRide
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

    Button addBtn = (Button) findViewById(R.id.addBtn);
    addBtn.setOnClickListener(new View.OnClickListener()){
        @Override
        public void OnClick(View View){
            EditText FirstNumEditText = (EditText) findViewById(R.id.firstNumEditText);
            EditText SecondNumEditText = (EditText) findViewById(R.id.secoundNumEditText);
            TextView Result = (TextView)findViewById(R.id.resultTextview);

            int num1 = Integer.parseInt(FirstNumEditText.getText() .toString());
            Resources secoundNumEditText;
            int num2 = Integer.parseInt(secoundNumEditText.getText() .toString());
            int result = num1 + num2;
            int result = num1 / num2;
            int result = num1 * num2;
            resultTextview.SetText{result + "");

@Dileep124
Copy link

@OverRide
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

    Button addBtn = (Button) findViewById(R.id.addBtn);
    addBtn.setOnClickListener(new View.OnClickListener()){
        @Override
        public void OnClick(View View){
            EditText FirstNumEditText = (EditText) findViewById(R.id.firstNumEditText);
            EditText SecondNumEditText = (EditText) findViewById(R.id.secoundNumEditText);
            TextView Result = (TextView)findViewById(R.id.resultTextview);

            int num1 = Integer.parseInt(FirstNumEditText.getText() .toString());
            Resources secoundNumEditText;
            int num2 = Integer.parseInt(secoundNumEditText.getText() .toString());
            int result = num1 + num2;
            int result = num1 / num2;
            int result = num1 * num2;
            resultTextview.SetText{result + "");

erro the resultTextView here i don't no reson why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests