Skip to content

Commit e107718

Browse files
committed
* fix java.lang.NoClassDefFoundError for non-java8 runtimes (e.g. Android 7.1.1) (thanks to https://github.com/ChristopherGittner)
1 parent 0142ceb commit e107718

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

changelog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
[SNAPSHOT]
2+
* fix java.lang.NoClassDefFoundError for non-java8 runtimes (e.g. Android 7.1.1)
3+
(thanks to https://github.com/ChristopherGittner)
4+
15
[8.3.0]
26
* add Instagram (https://www.instagram.com/) API (thanks to https://github.com/faent)
37
* add getErrorMessage method to FacebookAccessTokenErrorResponse. Should be used instead of general getMessage method

scribejava-core/src/main/java/com/github/scribejava/core/base64/CommonsCodecBase64.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@
22

33
public class CommonsCodecBase64 extends Base64 {
44

5-
private static final org.apache.commons.codec.binary.Base64 BASE64_ENCODER
6-
= new org.apache.commons.codec.binary.Base64();
7-
private static final org.apache.commons.codec.binary.Base64 BASE64_URL_ENCODER_WITHOUT_PADDING
8-
= new org.apache.commons.codec.binary.Base64(0, null, true);
5+
private static final org.apache.commons.codec.binary.Base64 BASE64_ENCODER;
6+
private static final org.apache.commons.codec.binary.Base64 BASE64_URL_ENCODER_WITHOUT_PADDING;
7+
8+
static {
9+
if (isAvailable()) {
10+
BASE64_ENCODER = new org.apache.commons.codec.binary.Base64();
11+
BASE64_URL_ENCODER_WITHOUT_PADDING = new org.apache.commons.codec.binary.Base64(0, null, true);
12+
} else {
13+
BASE64_ENCODER = null;
14+
BASE64_URL_ENCODER_WITHOUT_PADDING = null;
15+
}
16+
}
917

1018
@Override
1119
protected String internalEncode(byte[] bytes) {

scribejava-core/src/main/java/com/github/scribejava/core/base64/Java8Base64.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
public class Java8Base64 extends Base64 {
44

55
private static final com.github.scribejava.java8.base64.Java8Base64 JAVA8_BASE64
6-
= new com.github.scribejava.java8.base64.Java8Base64();
6+
= isAvailable() ? new com.github.scribejava.java8.base64.Java8Base64() : null;
77

88
@Override
99
protected String internalEncode(byte[] bytes) {

0 commit comments

Comments
 (0)