我必须加密一个字符串,但应用程序没有达到加密方法,它在加载时崩溃。
我正在使用Apache Commons Codec库。Android - decodeBase64崩溃应用程序
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);
由于某种原因,应用程序在第三行崩溃。
我的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)
任何线索?
更新
我改变了代码如下:
public static String key = "1234";
public static byte[] key_Array = decodeBase64(key);
但现在我有其他错误
java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.decodeBase64
? 你必须导入库,并简单地使用“decodeBase64(key);”。 – Wildcopper 2014-12-03 16:24:22
我改变了它。但问题依然存在。我认为问题在于静态方法。检查logcat:“无法解析静态方法8974” – Cristiano 2014-12-03 16:37:40