This question already has answers here:
What does a “Cannot find symbol” or “Cannot resolve symbol” error mean?
                                
                                    (13个回答)
                                
                        
                2年前关闭。
            
        

import org.apache.commons.codec.binary.Base64;
import java.util.Base64;


当我运行代码时,它给我一个错误。

    private void upload() {
    Bitmap bm = BitmapFactory.decodeFile(mCurrentPhotoPath);
    ByteArrayOutputStream bao = new ByteArrayOutputStream();
    bm.compress(Bitmap.CompressFormat.JPEG, 50, bao);
    byte[] ba = bao.toByteArray();
    ba1 = Base64.encodeBytes(ba);

    // Upload image to server
    new uploadToServer().execute();

}


我得到的错误是:

Error:(81, 21) error: cannot find symbol method encodeBytes(byte[])
Error:(43, 25) error: cannot find symbol class Base64

最佳答案

您正在导入Java库。请改为将Android库用于Base64。

import android.util.Base64;

10-08 09:08
查看更多