SnapDrive
SnapDrive

Reputation: 60

class file for com.google.auth.Credentials not found

I can't use GoogleCredentials in Firebaseoptions. I got the following error when I export with Maven:

  class file for com.google.auth.Credentials not found

 FirebaseOptions options = FirebaseOptions.builder()

                    .setCredentials(GoogleCredentials.fromStream(serviceAccount))
                    // Your Database URL can be found in your firebase console -> your project
                    .setDatabaseUrl("https://health-45311.firebaseio.com/")
                    .build();

In Intellij I cant import the package, but when I export with Maven nothing works.

My pom.xml

 <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>15.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>15.0.1</version>
        </dependency>

        <dependency>
            <groupId>com.google.firebase</groupId>
            <artifactId>firebase-admin</artifactId>
            <version>7.1.0</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.google.oauth-client/google-oauth-client -->
        <dependency>
            <groupId>com.google.oauth-client</groupId>
            <artifactId>google-oauth-client</artifactId>
            <version>1.31.2</version>
        </dependency>




    </dependencies>

Upvotes: 0

Views: 1448

Answers (1)

Andres Sacco
Andres Sacco

Reputation: 668

I found that "firebase-admin" dependency have another version of the "google-oauth-client". Try to exclude from the pom

    <dependency>
        <groupId>com.google.firebase</groupId>
        <artifactId>firebase-admin</artifactId>
        <version>7.1.0</version>
        <exclusions>
            <exclusion>
                <groupId>com.google.oauth-client</groupId>
                <artifactId>google-oauth-client</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

A good way to check this kind of things is run mvn dependency:tree -Dverbose in the console.

Edit - post response

I found that there was a question similar in the past. Here is the link

Upvotes: 1

Related Questions