Forwarded: https://android-review.googlesource.com/c/platform/tools/base/+/852369
--- a/sdklib/src/main/java/com/android/sdklib/internal/build/SignedJarBuilder.java
+++ b/sdklib/src/main/java/com/android/sdklib/internal/build/SignedJarBuilder.java
@@ -19,7 +19,7 @@
 import com.android.SdkConstants;
 import com.android.sdklib.internal.build.SignedJarBuilder.IZipEntryFilter.ZipAbortException;
 
-import sun.misc.BASE64Encoder;
+import java.util.Base64;
 import sun.security.pkcs.ContentInfo;
 import sun.security.pkcs.PKCS7;
 import sun.security.pkcs.SignerInfo;
@@ -104,7 +104,7 @@
     private PrivateKey mKey;
     private X509Certificate mCertificate;
     private Manifest mManifest;
-    private BASE64Encoder mBase64Encoder;
+    private Base64.Encoder mBase64Encoder;
     private MessageDigest mMessageDigest;
 
     private byte[] mBuffer = new byte[4096];
@@ -174,7 +174,7 @@
             main.putValue("Manifest-Version", "1.0");
             main.putValue("Created-By", "1.0 (Android)");
 
-            mBase64Encoder = new BASE64Encoder();
+            mBase64Encoder = Base64.getEncoder();
             mMessageDigest = MessageDigest.getInstance(DIGEST_ALGORITHM);
         }
     }
@@ -327,7 +327,7 @@
                 attr = new Attributes();
                 mManifest.getEntries().put(entry.getName(), attr);
             }
-            attr.putValue(DIGEST_ATTR, mBase64Encoder.encode(mMessageDigest.digest()));
+            attr.putValue(DIGEST_ATTR, mBase64Encoder.encodeToString(mMessageDigest.digest()));
         }
     }
 
@@ -339,7 +339,7 @@
         main.putValue("Signature-Version", "1.0");
         main.putValue("Created-By", "1.0 (Android)");
 
-        BASE64Encoder base64 = new BASE64Encoder();
+        final Base64.Encoder base64 = Base64.getEncoder();
         MessageDigest md = MessageDigest.getInstance(DIGEST_ALGORITHM);
         PrintStream print = new PrintStream(
                 new DigestOutputStream(new ByteArrayOutputStream(), md),
@@ -348,7 +348,7 @@
         // Digest of the entire manifest
         mManifest.write(print);
         print.flush();
-        main.putValue(DIGEST_MANIFEST_ATTR, base64.encode(md.digest()));
+        main.putValue(DIGEST_MANIFEST_ATTR, base64.encodeToString(md.digest()));
 
         Map<String, Attributes> entries = mManifest.getEntries();
         for (Map.Entry<String, Attributes> entry : entries.entrySet()) {
@@ -361,7 +361,7 @@
             print.flush();
 
             Attributes sfAttr = new Attributes();
-            sfAttr.putValue(DIGEST_ATTR, base64.encode(md.digest()));
+            sfAttr.putValue(DIGEST_ATTR, base64.encodeToString(md.digest()));
             sf.getEntries().put(entry.getKey(), sfAttr);
         }
 
