I have created a Javafx project with IntelliJ idea and want to integrate it with google firestore/firebase. But I am having problem.
I have tried installing google stacklogging driver and google cloud services, both installed successfully. I have tried with this doc https://cloud.google.com/tools/intellij/docs/client-libraries.
Remember, my project is non maven and non gradle.
But, while importing
import com.google.firebase.FirebaseApp;
import com.google.cloud.firestore.Firestore;
Error occurs, cannot resolve symbol google.
For further reference
If you are using Maven, add this to your pom.xml file
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bom</artifactId>
<version>0.79.0-alpha</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-firestore</artifactId>
<version>0.79.0-beta</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-logging</artifactId>
<version>1.61.0</version>
</dependency>
...
If you are using Gradle, add this to your dependencies
compile 'com.google.cloud:google-cloud-firestore:0.79.0-beta'
compile 'com.google.cloud:google-cloud-logging:1.61.0'
and the full list of services is available here
Related
I am trying to integrate spring-cloud-gcp-pub-sub-stream-binder in my spring boot project to consume events from gcp pub sub topic and getting the below error while running the project.
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
com.google.cloud.spring.stream.binder.pubsub.provisioning.PubSubChannelProvisioner.provisionConsumerDestination(PubSubChannelProvisioner.java:81)
The following method did not exist:
'boolean com.google.pubsub.v1.TopicName.isParsableFrom(java.lang.String)'
The calling method's class, com.google.cloud.spring.stream.binder.pubsub.provisioning.PubSubChannelProvisioner, was loaded from the following location:
jar:file:/Users/pranay.garg/.m2/repository/com/google/cloud/spring-cloud-gcp-pubsub-stream-binder/3.3.0/spring-cloud-gcp-pubsub-stream-binder-3.3.0.jar!/com/google/cloud/spring/stream/binder/pubsub/provisioning/PubSubChannelProvisioner.class
The called method's class, com.google.pubsub.v1.TopicName, is available from the following locations:
jar:file:/Users/pranay.garg/.m2/repository/com/google/api/grpc/proto-google-cloud-pubsub-v1/1.84.0/proto-google-cloud-pubsub-v1-1.84.0.jar!/com/google/pubsub/v1/TopicName.class
The called method's class hierarchy was loaded from the following locations:
com.google.pubsub.v1.TopicName: file:/Users/pranay.garg/.m2/repository/com/google/api/grpc/proto-google-cloud-pubsub-v1/1.84.0/proto-google-cloud-pubsub-v1-1.84.0.jar
Action:
Correct the classpath of your application so that it contains compatible versions of the classes com.google.cloud.spring.stream.binder.pubsub.provisioning.PubSubChannelProvisioner and com.google.pubsub.v1.TopicName
I am using spring boot v2.6.1
and my dependencyManagement
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>3.3.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-dependencies</artifactId>
<version>3.3.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>2021.0.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
and my related dependencies
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream</artifactId>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-pubsub-stream-binder</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-kafka</artifactId>
</dependency
I think it's a version compatibility issue where PubSubChannelProvisioner is trying to call a method in TopicName which is not present but I am not able to figure out the solution for this.
Let me know if you need any other information which might have been missed.
Any help is appreciated, thanks.
I believe GCP Adapter in s-c-function is using proto-google-cloud-pubsub v1.0.0 and in your case you are using 1.84. So perhaps we need to update.
Feel free to raise an issue - https://github.com/spring-cloud/spring-cloud-function/issues
I raised on issue on spring-cloud-gcp github repo and got the issue resolved. Turns out it was due to a version conflict in libraries-bom dependency management version solution
Fair amount of experience with java but have only made console applications without using any dependencies. I am currently trying to make a rest api to handle request for my web application. I am using Apache Maven 3.6.3 and have the dependencies in my pom.xml file.
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
</dependencies>
When I try to compile my project I get the same error for each of my dependencies (listing the error for the http client)
error: package org.apache.http.client.methods does not exist
I think the problem is connected with some dependencies which use an old version of this library. A possible solution is to add in the pom file the dependency in the dependencyManagement, this is a way to override all the possible imports of the library.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
</dependencies>
</dependencyManagement>
In my maven-project there are three dependencies corresponding to RichFaces:
<dependency>
<groupId>org.richfaces.framework</groupId>
<artifactId>richfaces-api</artifactId>
</dependency>
<dependency>
<groupId>org.richfaces.framework</groupId>
<artifactId>richfaces-impl</artifactId>
</dependency>
<dependency>
<groupId>org.richfaces.ui</groupId>
<artifactId>richfaces-ui</artifactId>
</dependency>
And in the root of my eclipse project MavenDependencies branch contains richfaces-api/ui/core -3.3.3. How can I change the pom to upload latest available version? The thing is there is no version defined anywhere in the pom.
There has to be a version defined otherwise it would not work. Eclipse will tell you what version you're using and where to find the definition if you hover over the dependency.
I Think there's a bom dependency somehwere in your pom such as this
<dependency>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-bom</artifactId>
<version>BOM-VERSION</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Update the BOM-VERSION part to something new such as "4.3.7.Final".
I use maven-android-plugin to build my android app which depends on android support library v4 and v7.
Since I didn't find how to download the whole sdk from developer.android.com, I cnnot use maven android deployee tool to set local repository of android sdk.Thus I want to use the support library that includes in the adt-bundle, below is how I write the dependencies in my pom.xml:
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v7</artifactId>
<version>18</version>
<scope>system</scope>
<systemPath>${project.basedir}/appcompat/libs/android-support-v7-appcompat.jar</systemPath>
</dependency>
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v4</artifactId>
<version>18</version>
<scope>system</scope>
<systemPath>${project.basedir}/appcompat/libs/android-support-v4.jar</systemPath>
</dependency>
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility</artifactId>
<version>18</version>
<scope>system</scope>
<systemPath>${project.basedir}/appcompat.apklib</systemPath>
<type>apklib</type>
</dependency>
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility</artifactId>
<version>18</version>
<scope>system</scope>
<systemPath>${project.basedir}/appcompat/bin/appcompat.jar</systemPath>
</dependency>
The first two is what I wrote at beginning, but maven raised an error:
No resource found that matches the given name 'Theme.AppCompat.Light'.
Then I added third one. I zip the v7 project and rename to .apklib.But it still does not work.
At last I add the last one,but it does not work either.So how to write a correct pom to fix this?
My system infomation:
Apache Maven 3.0.4
Java version: 1.7.0_25, vendor: Oracle Corporation
Android Platform Version:4.3
Android Maven Plugin:3.6.0
When I was playing with this I added a <type>jar</type> and a <type>apklib</type>. I don't remember all the details.
I did this: https://stackoverflow.com/a/18796764/1738827
My pom file had this:
<dependency>
<groupId>com.android.support</groupId>
<artifactId>appcompat-v7</artifactId>
<version>18.0.0</version>
<type>apklib</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>appcompat-v7</artifactId>
<version>18.0.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
Try this:
<dependency>
<groupId>com.android.support</groupId>
<artifactId>appcompat-v7</artifactId>
<version>18.0.0</version>
<type>aar</type>
</dependency>
I used this and Theme.Appcompat.Light is visible.
I'm having trouble executing instrumentation tests using the android maven plugin.
I have followed the "libraryprojects" example to the last detail, however,
there is one slight difference in my setup ~ i'm adding the android support jar as
an external dependency.
My setup looks as follows:
APK lib project (greendroid to be specific)
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>r6</version>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
APK project
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>greendroid</groupId>
<artifactId>GreenDroidFragment</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>apklib</type>
</dependency>
APK test project (and here's the problem .... )
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>r6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android-test</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.jayway.android.robotium</groupId>
<artifactId>robotium-solo</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>com.**</groupId>
<artifactId>**</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>apk</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.**</groupId>
<artifactId>**</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
The problem is that delvik is unable to find or link support jar upon running instrumentation tests.
My question is, how do I tell delvik to resolve required files within the test APK against the main application APK ? Theoretically, setting the scope of the required dependency (android-support jar) to provided within the test APK should work, but it does not.
Below are some scenarios that I experimented with:
By packaging the android support jar as part of the APK test project, delvik complains that it's unable to resolve the compiled code. This is because the dex output of the main APK is different from the dex output of the test APK.
W/dalvikvm(328): Class resolved by unexpected DEX:
Lcom/**/android/**/GenerateOtpFragment;(0x44edffb0):0x121de0 ref
[Landroid/support/v4/app/Fragment;] Landroid/support/v4/app/Fragment;(0x44edffb0)
By not packaging the android support as part of the APK test project, delvik is unable to locate the compiled code. This happens when making the scope provided or excluding the dependency completely.
W/ClassPathPackageInfoSource(632): Cannot load class. Make sure it is in your apk.
Class name: 'android.support.v4.os.ParcelableCompatCreatorHoneycombMR2'.
Message: android.support.v4.os.ParcelableCompatCreatorHoneycombMR2
The only thing I can think of is to somehow manually tell the APK test project to resolve the android-support dependency from the main APK project using a delvik linking mechanism.
Any ideas would be much appreciated,
-Michael
I am not sure, but I suspect this might be an explanation:
Instrumentation tests scanning apk...not an issue