Home > Enterprise >  java.lang.NoClassDefFoundError: com/google/api/client/http/HttpRequestInitializer
java.lang.NoClassDefFoundError: com/google/api/client/http/HttpRequestInitializer

Time:08-24

Im trying to append some things to a google sheet from a Custom GUI in Minecraft. When i try the same code, isolatet, from IntelliJ instead of ingame it workes. Ingame it throws this error:

 java.lang.NoClassDefFoundError: com/google/api/client/http/HttpRequestInitializer

Its thrown at the "<---" in the code below:

public AppendValuesResponse execute(String APPLICATION_NAME) throws GeneralSecurityException, IOException, MissingEntryException {
        Sheets sheetsService = SheetsAPI.getSheetsService(APPLICATION_NAME);
        if(SHEET_ID == null || RANGE == null ||INPUT == null)
            throw new MissingEntryException("One or more Values are null: SHEET_ID: '" SHEET_ID "', RANGE: '" RANGE "', SHEET_ID: '"   INPUT.toString()   "'");

        ValueRange appendBody = new ValueRange().setValues(Arrays.asList(Arrays.asList(INPUT)));

        Sheets.Spreadsheets.Values.Append append = sheetsService.spreadsheets().values()
                .append(SHEET_ID, RANGE, appendBody)
                .setValueInputOption("USER_ENTERED")
                .setInsertDataOption("OVERWRITE")
                .setIncludeValuesInResponse(true);

        return append.execute(); <---
    }

Anyone know how to fix this?

Using Gradle, load the Dependency like this:

implementation 'com.google.http-client:google-http-client:1.42.2'

CodePudding user response:

You miss the dependency google-http-clientin your class path. If you use maven you can add:

<!-- https://mvnrepository.com/artifact/com.google.http-client/google-http-client -->
<dependency>
    <groupId>com.google.http-client</groupId>
    <artifactId>google-http-client</artifactId>
    <version>${version.google.http.client}</version>
</dependency>

where version.google.http.client is the version of the library which is compatible to the library that requires the class.

  • Related