Hi, I had written code which encode image in Base64 format. It
requires Base64OutputStream class, as I know it is present in API
level 8, but I want to develop application for G1(API level- 4). I had
download source code for BAse64OuputStream class from 
http://commons.apache.org/codec/
this URL and save in src folder of android application . The program
compiles and when I installed and run application on G1 it gives me
error as
java.lang.VerifyError .

And Logcat gives following error as

08-27 14:11:35.285: ERROR/AndroidRuntime(371): Uncaught handler:
thread main exiting due to uncaught exception
08-27 14:11:35.405: ERROR/AndroidRuntime(371): java.lang.VerifyError:
org.apache.commons.codec.binary.Base64OutputStream
08-27 14:11:35.405: ERROR/AndroidRuntime(371):     at
com.micro.encodeImage.EncodeImage.encodeImage(EncodeImage.java:46)
08-27 14:11:35.405: ERROR/AndroidRuntime(371):     at
com.micro.encodeImage.EncodeImage.onCreate(EncodeImage.java:35)
08-27 14:11:35.405: ERROR/AndroidRuntime(371):     at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1123)
08-27 14:11:35.405: ERROR/AndroidRuntime(371):     at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2364)
08-27 14:11:35.405: ERROR/AndroidRuntime(371):     at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2417)
08-27 14:11:35.405: ERROR/AndroidRuntime(371):     at
android.app.ActivityThread.access$2100(ActivityThread.java:116)
08-27 14:11:35.405: ERROR/AndroidRuntime(371):     at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
08-27 14:11:35.405: ERROR/AndroidRuntime(371):     at
android.os.Handler.dispatchMessage(Handler.java:99)
08-27 14:11:35.405: ERROR/AndroidRuntime(371):     at
android.os.Looper.loop(Looper.java:123)
08-27 14:11:35.405: ERROR/AndroidRuntime(371):     at
android.app.ActivityThread.main(ActivityThread.java:4203)
08-27 14:11:35.405: ERROR/AndroidRuntime(371):     at
java.lang.reflect.Method.invokeNative(Native Method)
08-27 14:11:35.405: ERROR/AndroidRuntime(371):     at
java.lang.reflect.Method.invoke(Method.java:521)
08-27 14:11:35.405: ERROR/AndroidRuntime(371):     at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:791)
08-27 14:11:35.405: ERROR/AndroidRuntime(371):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
08-27 14:11:35.405: ERROR/AndroidRuntime(371):     at
dalvik.system.NativeStart.main(Native Method)

I know it is because of Java source that was compiled against
the one of the other versions . But how to write code for G1 which
encode image? So I had tried using InputStream class as

public void encodeImage()
        {
                try
                {
                        out = new PrintWriter("c:/program1/zzz.txt");
                        InputStream inputStream =  new FileInputStream 
("c:/program1/
tt.jpg");
                        OutputStream outputStream = new 
FileOutputStream("c:/program1/
zzz.txt");

                        byte[] b = new byte[1024];

                        while((read= inputStream.read(b))>0)
                        {
                                System.out.println ("Inside while");
                                inputStream.mark(b.length);
                                String encoded = Base64.encode(b);
                                //System.out.println (encoded);
                                out.print(encoded);
                                out.flush();

                                //bas.write(b);
                        }


                        out.close();


                }

                catch (Exception e)
                {
                        System.out.println (e);
                }


        }

But this code produce encoded string but when I decode it , at
http://www.opinionatedgeek.com/dotnet/tools/base64decode/ this site
then it gives me error as The input is not a valid Base-64 string as
it contains a non-base 64 character, more than two padding characters,
or a non-white space character among the padding characters.


Please help me how to encode image?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to