Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

"Could not resolve org.checkerframework:checker-qual:3.12.0" When Using YouTube API in Gradle Project

$
0
0

Using VS Code and the Gradle for Java extension, I made a new Gradle project. I needed to use the YouTube API for a project, so I followed their tutorial, but I got an error saying that the "compile" method did not exist (or something along those lines), so I changed the compiles to "implementation". I then copy-and-pasted their code sample for listing search results, and I got no compile errors (other than the JacksonFactory import. I had to change that to GsonFactory because JacksonFactory was deprecated).

However, when I used gradle -q run, I got an error saying the following:

Execution failed for task ':app:compileJava'.> Could not resolve all files for configuration ':app:compileClasspath'.> Could not resolve org.checkerframework:checker-qual:3.12.0.     Required by:         project :app         project :app > com.google.api-client:google-api-client:2.2.0 > com.google.guava:guava:31.1-jre> No matching variant of org.checkerframework:checker-qual:3.12.0 was found. The consumer was configured to find a library for use during compile-time, compatible with Java 7, preferably in the form of class files, preferably optimized for standard JVMs, and its dependencies declared externally but:          - Variant 'apiElements' capability org.checkerframework:checker-qual:3.12.0 declares a library for use during compile-time, packaged as a jar, and its dependencies declared externally:              - Incompatible because this component declares a component, compatible with Java 8 and the consumer needed a component, compatible with Java 7              - Other compatible attribute:                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)          - Variant 'javadocElements' capability org.checkerframework:checker-qual:3.12.0 declares a component for use during runtime, and its dependencies declared externally:              - Incompatible because this component declares documentation and the consumer needed a library              - Other compatible attributes:                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)                  - Doesn't say anything about its target Java version (required compatibility with Java 7)                  - Doesn't say anything about its elements (required them preferably in the form of class files)          - Variant 'runtimeElements' capability org.checkerframework:checker-qual:3.12.0 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally:              - Incompatible because this component declares a component, compatible with Java 8 and the consumer needed a component, compatible with Java 7              - Other compatible attribute:                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)          - Variant 'sourcesElements' capability org.checkerframework:checker-qual:3.12.0 declares a component for use during runtime, and its dependencies declared externally:              - Incompatible because this component declares documentation and the consumer needed a library              - Other compatible attributes:                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)                  - Doesn't say anything about its target Java version (required compatibility with Java 7)                  - Doesn't say anything about its elements (required them preferably in the form of class files)

From what I could understand, org.checkerframework:checker-qual:3.12.0 was a required dependency that did not exist.

So, I tried adding implementation 'org.checkerframework:checker-qual:3.12.0' to the build.gradle dependencies, but I still got the same error. I then tried searching up org.checkerframework:checker-qual:3.12.0 and found the maven repository website and copy-and-pasted the import for gradle, but I still got the same error.

Here is what my build.gradle file looks like currently:

apply plugin: 'java'apply plugin: 'application'mainClassName = 'App'sourceCompatibility = 1.7targetCompatibility = 1.7version = '1.0'repositories {    mavenCentral()}dependencies {    // https://mvnrepository.com/artifact/org.checkerframework/checker-qual    implementation group: 'org.checkerframework', name: 'checker-qual', version: '3.12.0'    implementation 'com.google.api-client:google-api-client:1.23.0'    implementation 'com.google.oauth-client:google-oauth-client-jetty:1.23.0'    implementation 'com.google.apis:google-api-services-youtube:v3-rev20231011-2.0.0'}

And my App class:

package com.avinash.youtube_data_collection;import com.google.api.client.auth.oauth2.Credential;import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp;import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver;import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow;import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets;import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;import com.google.api.client.googleapis.json.GoogleJsonResponseException;import com.google.api.client.http.javanet.NetHttpTransport;import com.google.api.client.json.JsonFactory;import com.google.api.client.json.gson.GsonFactory;import com.google.api.services.youtube.YouTube;import com.google.api.services.youtube.model.SearchListResponse;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;import java.security.GeneralSecurityException;import java.util.Arrays;import java.util.Collection;public class App {    private static final String CLIENT_SECRETS= "client_secret.json";    private static final Collection<String> SCOPES =        Arrays.asList("https://www.googleapis.com/auth/youtube.force-ssl");    private static final String APPLICATION_NAME = "API code samples";    private static final JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance();    /**     * Create an authorized Credential object.     *     * @return an authorized Credential object.     * @throws IOException     */    public static Credential authorize(final NetHttpTransport httpTransport) throws IOException {        // Load client secrets.        InputStream in = App.class.getResourceAsStream(CLIENT_SECRETS);        GoogleClientSecrets clientSecrets =          GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));        // Build flow and trigger user authorization request.        GoogleAuthorizationCodeFlow flow =            new GoogleAuthorizationCodeFlow.Builder(httpTransport, JSON_FACTORY, clientSecrets, SCOPES)            .build();        Credential credential =            new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");        return credential;    }    /**     * Build and return an authorized API client service.     *     * @return an authorized API client service     * @throws GeneralSecurityException, IOException     */    public static YouTube getService() throws GeneralSecurityException, IOException {        final NetHttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();        Credential credential = authorize(httpTransport);        return new YouTube.Builder(httpTransport, JSON_FACTORY, credential)            .setApplicationName(APPLICATION_NAME)            .build();    }    /**     * Call function to create API service object. Define and     * execute API request. Print API response.     *     * @throws GeneralSecurityException, IOException, GoogleJsonResponseException     */    public static void main(String[] args)        throws GeneralSecurityException, IOException, GoogleJsonResponseException {        YouTube youtubeService = getService();        // Define and execute the API request        YouTube.Search.List request = youtubeService.search()            .list(Arrays.asList("snippet"));        SearchListResponse response = request.setQ("dogs")            .setType(Arrays.asList("videos"))            .execute();        System.out.println(response);    }}

Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>