Danu
Danu

Reputation: 1

Google Analytics API 4 Java client running from command com.google.analyticsreporting.v4 package does not exist

I'm running the API 3 with Java from Windows command using javac and java to compile, no problem. I'm trying the API 4 but can't make even the basic example to run. I understand my problem must be in the classpath but can't pinpoint on the problem. Can't see the com.google packages

I downloaded the API 4 Java Client, copied all .jar in libs to a folder libs in my project. Also copied google-api-services-analyticsreporting-v4-rev110-1.22.0.jar to the libs I'm testing the service account example as in https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/service-java

I setup the compiler as (I know the path exists) javac -classpath ".;C:\Java\GAnalytics\libs\*" HelloAnalytics4.java I also tried adding the subdirectories in the client

Error Package does not exit:

import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.gson.GsonFactory;
import com.google.analyticsreporting.v4.AnalyticsreportingScopes;
import com.google.analyticsreporting.v4.Analyticsreporting;
import com.google.analyticsreporting.v4.model.ColumnHeader;
import com.google.analyticsreporting.v4.model.DateRange;
import com.google.analyticsreporting.v4.model.DateRangeValues;
import com.google.analyticsreporting.v4.model.Dimension;
import com.google.analyticsreporting.v4.model.GetReportsRequest;
import com.google.analyticsreporting.v4.model.GetReportsResponse;
import com.google.analyticsreporting.v4.model.Metric;
import com.google.analyticsreporting.v4.model.MetricHeaderEntry;
import com.google.analyticsreporting.v4.model.Report;
import com.google.analyticsreporting.v4.model.ReportRequest;
import com.google.analyticsreporting.v4.model.ReportRow;

What am I missing?

Upvotes: 0

Views: 528

Answers (1)

Mattia Fantoni
Mattia Fantoni

Reputation: 955

Same problem for me, I solved by substituting all

"com.google.analyticsreporting.v4" ---> "com.google.api.services.analyticsreporting.v4"

and also:

Analyticsreporting --> AnalyticsReporting

Here the screen of the google-api-services-analyticsreporting-v4-rev111-1.22.0.jar unzipped

See highlighted path

Upvotes: 2

Related Questions