Q:

Android - decodeBase64 crashes App

I have to encrypt a String but the app doesn't reach the encrypt method, it crashes on load. 
I'm using Apache Commons Codec library.
private EditText txtPass = (EditText)findViewById(R.id.txtPass);
public String key = txtPass.getText().toString();
public byte[] key_Array = org.apache.commons.codec.binary.Base64.decodeBase64(key);

For some reason, the app crashes in the third line.
My logcat.
12-03 14:03:31.441  23420-23420/com.example.cristiano.automacao V/ActivityThread﹕ Class path: /data/app/com.example.cristiano.automacao-2.apk, JNI path: /data/data/com.example.cristiano.automacao/lib
12-03 14:03:31.591  23420-23420/com.example.cristiano.automacao W/dalvikvm﹕ VFY: unable to resolve static method 8974: Lorg/apache/commons/codec/binary/Base64;.decodeBase64 (Ljava/lang/String;)[B
12-03 14:03:31.601  23420-23420/com.example.cristiano.automacao W/dalvikvm﹕ VFY: unable to resolve static method 8984: Lorg/apache/commons/codec/binary/Base64;.encodeBase64String ([B)Ljava/lang/String;
12-03 14:03:31.611  23420-23420/com.example.cristiano.automacao W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41c7b438)

Any clue about that?
Updated
I changed the code to this:
public static String key = "1234";
public static byte[] key_Array = decodeBase64(key);

But now I got other error
java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.decodeBase64

A:

Try this:
// decode data from base 64
    private static byte[] decodeBase64(String dataToDecode)
        {
            byte[] dataDecoded = Base64.decode(dataToDecode, Base64.DEFAULT);
            return dataDecoded;
        }

//enconde data in base 64
        private static byte[] encodeBase64(byte[] dataToEncode)
        {
            byte[] dataEncoded = Base64.encode(dataToEncode, Base64.DEFAULT);
            return dataEncoded;
        }

