I built an Android application with a service account on it to upload files on Google Drive, which works perfectly on the emulator and Android Nougat. Now, I tried it on a Samsung Galaxy Tab A with Android 8.1 and before implementing the service account everything worked fine. Now, when I try to save a file on google Drive from it, I get the error:
java.lang.NoSuchMethodError: No static method decodeBase64(Ljava/lang/String;)[B in class Lorg/apache/commons/codec/binary/Base64; or its super classes (declaration of 'org.apache.commons.codec.binary.Base64' appears in /system/framework/org.apache.http.legacy.boot.jar)
The problematic code is where I log in, in particular in the fromStream
method:
private Credential authorize () throws IOException {
InputStream in = getAssets().open("credentials.json");
return GoogleCredential.fromStream(in)
.createScoped(Collections.singleton(DriveScopes.DRIVE_FILE));
}
These are the new libraries implemented, I add commons-codec:commons-codec:1.15 since I read that it can be caused by it but it still doesn't work:
//API Google Drive
implementation 'com.google.android.gms:play-services-auth:19.0.0'
implementation('com.google.api-client:google-api-client-android:1.26.0') {
exclude group: 'org.apache.httpcomponents'
exclude module: 'guava-jdk5'
}
// https://mvnrepository.com/artifact/com.google.apis/google-api-services-drive
implementation('com.google.apis:google-api-services-drive:v3-rev136-1.25.0') {
exclude group: 'org.apache.httpcomponents'
exclude module: 'guava-jdk5'
}
implementation 'com.google.http-client:google-http-client-gson:1.26.0'
implementation 'commons-codec:commons-codec:1.15'
How can I solve it?
Edit: these are the only apaches' libraries that I used in the whole project, but they have been used to write the .xlsx file in local and never gave me any kind of problem on the Galaxt Tab A before implementing the service credentials:
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
from No static method decodeBase64 - Google Credential
No comments:
Post a Comment