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 since firebase update on March 20th. Would you set firebase sdk version? #612

Closed
XCarle opened this issue Mar 22, 2018 · 21 comments
Closed

Comments

@XCarle
Copy link

XCarle commented Mar 22, 2018

Since : https://firebase.google.com/support/releases March 20th.

Error

AndroidRuntime: java.lang.NoSuchMethodError: No static method zza(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; in class Lcom/google/android/gms/common/internal/zzbq; or its super classes (declaration of 'com.google.android.gms.common.internal.zzbq'

@tryadelion
Copy link

this is a critical issue.

@ulisesvera
Copy link

Hi, I have other error due to the same firebase update. When I type:

cordova build android

in the console, I get this output:

BUILD FAILED

Total time: 4.529 secs
FAILURE: Build failed with an exception.

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

Error: more than one library with package name 'com.google.android.gms.license'`

I have been looking for the answer through the web but the solutions I found (solution1, solution2, solution3) doesn't work for me.

The error appears to be due to the Play Services update. I cannot build my android app until I have remove this plugin.

I hope this critical issue could be solve to install the plugin again.

@tryadelion
Copy link

there is a temporary fix to this, force the services and firebase versions to 11.8.0.

how to:
put this inside the tag of config.xml with the content:

<hook src="fixFirebasePlugin.js" type="before_build" />

create the JS file on your project root:

module.exports = function(context) {
	var fs = require('fs');
	var path = require('path');

	var rootdir = context.opts.projectRoot;

	var platformDir = 'platforms/android';
        //change the path to your external gradle file
	var srcFile = path.join(rootdir, 'src/android/build-extras.gradle');
	var destFile = path.join(rootdir, platformDir, 'build-extras.gradle');

	console.log("copying "+srcFile+" to "+destFile);
	fs.createReadStream(srcFile).pipe(fs.createWriteStream(destFile));
}

create inside the src folder a android fodler and create inside that a file called build-extras.gradle with the content:

configurations.all {
   resolutionStrategy {
       force "com.google.android.gms:play-services-ads:11.8.0"
       force "com.google.android.gms:play-services-base:11.8.0"
       force "com.google.android.gms:play-services-gcm:11.8.0"
       force "com.google.android.gms:play-services-analytics:11.8.0"
       force "com.google.android.gms:play-services-location:11.8.0"
       force "com.google.android.gms:play-services-basement:11.8.0"
       force "com.google.android.gms:play-services-tagmanager:11.8.0"
       force 'com.google.firebase:firebase-core:11.8.0'
       force 'com.google.firebase:firebase-crash:11.8.0'
       force 'com.google.firebase:firebase-auth:11.8.0'
       force 'com.google.firebase:firebase-common:11.8.0'
       force 'com.google.firebase:firebase-config:11.8.0'
       force 'com.google.firebase:firebase-messaging:11.8.0'
   }
}

remove and re add platform (tested on 6.3.0), perform a cordova build android, and it's fixed.

after that, a run/build --prod, whatever you want.

@ulisesvera
Copy link

@tryadelion, I have tried your solution exactly as you mentioned, but I got the same error in console :(

@tryadelion
Copy link

have you removed the platform, readded as android@6.3.0 and performed a "~: cordova build android", no prod, no run, no ionic? that's what did the trick for me!

@ulisesvera
Copy link

Yes, I did everything (config.xml, fixFirebasePlugin.js, build-extras.gradle, platform android@6.3.0), but every run or build command I execute produce the same output:

firebase-build-failed

My project is not an ionic one, I don't know if this could be important to this issue.

@tryadelion
Copy link

tryadelion commented Mar 22, 2018

did you try any prior "hotfix" to this? like hand-changing the versions on the plugin's XML? i had to remove and readd it because i messed with it's files. it has worked so far on 3 different projects, all ionic though, but the hook system is the same as it's cordova powered.

@ulisesvera
Copy link

Before that, I have only changed /platforms/android/project.properties and /platforms/android/build.gradle but after that I have removed and re-added the plugin (first), and the platform android@6.3.0. (after).

I don't know what could be the reason of the fail, butI think my project still have both versions: 12.0 and 11.8.0 because in the console I see this:

firebase-build-failed-2

I don't know where could be specified the 12.0.0 version.

@tryadelion
Copy link

remove node-modules, remove platforms/android, remove every services-using plugin in /plugins, NPM i, readd every plugin that you removed, add platform android, and try again. that's what i would do.

@ulisesvera
Copy link

Ok, I'll try to re-install every component I have. Thank you very much for your help!!

@XCarle
Copy link
Author

XCarle commented Mar 22, 2018

@tryadelion Thanks for sharing. I was about to fork cordova-plugin-firebase and force versions. Anyway, i implemented your solution.

We are working with android@6.4.0 that is working as well.

@ulisesvera
Copy link

Finally I solve the problem modifying the file /platforms/android/build.gradle this way:

allprojects {

    repositories {
    // Temp fix for com.google.android.gms.license
            // Added from here
            configurations.all {
                resolutionStrategy {

                    // Put your gms packages here with 11.8.0 attached
                    force "com.google.android.gms:play-services-analytics:11.8.0"
                    force "com.google.android.gms:play-services-auth:11.8.0"
                    force "com.google.android.gms:play-services-gcm:11.8.0"
                    force "com.google.android.gms:play-services-location:11.8.0"
                }
            }
            // until here

        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

(Solution read from facebook/react-native#18479)

Thanks again!

@jotefer
Copy link

jotefer commented Mar 22, 2018

For Ionic v1.1.0 and cordova-plugin-firebase v0.1.25 this hook solved my problem:

//before_build/010_add_gradle_extras.js

#!/usr/bin/env node

var fs = require('fs');
var path = require('path');

var rootdir = process.argv[2];
var platformDir = 'platforms/android';

var srcfile = path.join(rootdir, 'build-extras.gradle');
var destfile = path.join(rootdir, platformDir, 'build-extras.gradle');
var destdir = path.dirname(destfile);

if (fs.existsSync(srcfile) && fs.existsSync(destdir)) {
  fs.createReadStream(srcfile).pipe(fs.createWriteStream(destfile));
  process.stdout.write('Hook: build-extras.gradle added');
} 
//build-extras.gradle

configurations.all {
   resolutionStrategy {
       force "com.google.android.gms:play-services-ads:11.8.0"
       force "com.google.android.gms:play-services-base:11.8.0"
       force "com.google.android.gms:play-services-gcm:11.8.0"
       force "com.google.android.gms:play-services-analytics:11.8.0"
       force "com.google.android.gms:play-services-location:11.8.0"
       force "com.google.android.gms:play-services-basement:11.8.0"
       force "com.google.android.gms:play-services-tagmanager:11.8.0"
       force 'com.google.firebase:firebase-core:11.8.0'
       force 'com.google.firebase:firebase-crash:11.8.0'
       force 'com.google.firebase:firebase-auth:11.8.0'
       force 'com.google.firebase:firebase-common:11.8.0'
       force 'com.google.firebase:firebase-config:11.8.0'
       force 'com.google.firebase:firebase-messaging:11.8.0'
   }
}

Remove and adding new android platform was also a key factor.

@remisture
Copy link

@tryadelion, any idea why I get this error when I try your approach?

A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_debugApkCopy'.
   > Could not find com.google.gms:google-services:11.8.0.
     Required by:
         project :

@yosikal
Copy link

yosikal commented Mar 26, 2018

I did what jotefer said and it makes the build work. However, remote config stopped working. Any idea?

@yosikal
Copy link

yosikal commented Mar 26, 2018

Diving into the issue that fetch is not working I found out that it's because of the following exception which is being thrown when calling fetch:

Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.util.ArraySet" on path: DexPathList

Any idea?

@tryadelion
Copy link

@remisture i had that issue happen when another gradle file was still referencing 12.X, try build cleaning.

@codesundar
Copy link

codesundar commented Mar 26, 2018

I solved by updating platforms/android/build.gradle
Before

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

After:

allprojects {
    repositories {
        //start here
        configurations.all {
            resolutionStrategy.eachDependency { DependencyResolveDetails details ->
                def requested = details.requested
                if (requested.group == 'com.google.android.gms') {
                    details.useVersion '11.8.0'
                }
                if (requested.group == 'com.google.firebase') {
                    details.useVersion '11.8.0'
                }
            }
        }
        //end
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

Tested on android@6.3.0

@thevolcanomanishere
Copy link

Below is my entire build.gradle. Also has a useful bit at the end for changing the compile sdk for all projects

buildscript {
    repositories {
        jcenter()
        google()
        mavenLocal()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        configurations.all {
            resolutionStrategy.eachDependency { DependencyResolveDetails details ->
                def requested = details.requested
                if (requested.group == 'com.google.android.gms') {
                    details.useVersion '12.0.1'
                }
            }
        }
        mavenLocal()
        jcenter()
        maven {
            url "https://jitpack.io"
        }
        maven {
            url 'https://maven.google.com'
        }
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 26
                buildToolsVersion '26.0.2'
            }
        }
    }
}

@soumak77
Copy link
Contributor

this appears to be fixed by installing cordova-android-play-services-gradle-release

@dvsingh9
Copy link

@soumak77 that works thanks

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

10 participants