0

I am working on a simple project to automate an android applications' nightly build. I have prepared all the configurations(like bash script, gradle, android-sdk etc.) to start the build. The thing is, the application builds successfully and work fine on the phone when i build it on my local computer. But when i build it on my company's build server, it gives the runtime error below, even though it build successfully;

01-08 05:46:46.688 14675 14721 E AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
01-08 05:46:46.688 14675 14721 E AndroidRuntime: Process: com.vestel.camera, PID: 14675
01-08 05:46:46.688 14675 14721 E AndroidRuntime: java.lang.RuntimeException: An error occurred while executing doInBackground()
01-08 05:46:46.688 14675 14721 E AndroidRuntime:    at android.os.AsyncTask$3.done(AsyncTask.java:309)
01-08 05:46:46.688 14675 14721 E AndroidRuntime:    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
01-08 05:46:46.688 14675 14721 E AndroidRuntime:    at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
01-08 05:46:46.688 14675 14721 E AndroidRuntime:    at java.util.concurrent.FutureTask.run(FutureTask.java:242)
01-08 05:46:46.688 14675 14721 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
01-08 05:46:46.688 14675 14721 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
01-08 05:46:46.688 14675 14721 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:818)
01-08 05:46:46.688 14675 14721 E AndroidRuntime: Caused by: java.lang.ClassCastException: java.lang.Object[] cannot be cast to java.lang.Void[]
01-08 05:46:46.688 14675 14721 E AndroidRuntime:    at com.android.camera.CameraActivity$UpdateThumbnailTask.doInBackground(CameraActivity.java:826)
01-08 05:46:46.688 14675 14721 E AndroidRuntime:    at android.os.AsyncTask$2.call(AsyncTask.java:295)
01-08 05:46:46.688 14675 14721 E AndroidRuntime:    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
01-08 05:46:46.688 14675 14721 E AndroidRuntime:    ... 3 more

What might be the reason for such an error? I am using the exact copies of sdk and gradle in both machines, but when i build it on the server it gives this error. By the way, i also tried the same process on a third computer, and it also worked just fine.

This is the doInBackground method of UpdateThumbnailTask class;

private class UpdateThumbnailTask extends AsyncTask<Void, Void, Bitmap> {
        private final byte[] mJpegData;
        private final boolean mCheckOrientation;

        public UpdateThumbnailTask(final byte[] jpegData, boolean checkOrientation) {
            mJpegData = jpegData;
            mCheckOrientation = checkOrientation;
        }

        @Override
        protected Bitmap doInBackground(Void... params) {
            if (mJpegData != null)
                return decodeImageCenter(null);

            LocalDataAdapter adapter = getDataAdapter();
            ImageData img = adapter.getImageData(1);
            if (img == null) {
                return null;
            }
            Uri uri = img.getContentUri();
            String path = getPathFromUri(uri);
            if (path == null) {
                return null;
            }
            else {
                if (img.isPhoto()) {
                    return decodeImageCenter(path);
                } else {
                    return ThumbnailUtils
                            .createVideoThumbnail(path, MediaStore.Video.Thumbnails.MINI_KIND);
                }
            }
        }
    .
    .
    .

the object of UpdateThumbnailTask is created a few times;

if(ImageStorage.getInstance().getImageList().size() == 0) {
            Log.w(TAG,"onActivityResult imagelist 0");
            Utils.execute(new UpdateThumbnailTask(null, true));
}

.

public void updateThumbnail(final byte[] jpegData) {
    Utils.execute(new UpdateThumbnailTask(jpegData, false));
}

.

public void updateThumbnail(boolean videoOnly) {
    // Only handle OnDataInserted if it's video.
    // Photo and Panorama have their own way of updating thumbnail.
    if (!videoOnly || (mCurrentModule instanceof VideoModule)) {
        Utils.execute(new UpdateThumbnailTask(null, true));
    }
}

Thanks in advance.

caneru
  • 391
  • 1
  • 2
  • 15
  • Where is the code that causes this? – Tim Jan 13 '17 at 11:25
  • I have edited the question. – caneru Jan 13 '17 at 11:28
  • How do you call your AsyncTask? Can you add this code? – Christopher Jan 13 '17 at 11:32
  • the object of extender class UpdateThumbnailTask is created a few times. I have edited the question. – caneru Jan 13 '17 at 11:48
  • Utils.execute()-method would also be helpful. Have you considered this one: http://stackoverflow.com/questions/34399979/asynctask-classcastexception-java-lang-object-cannot-be-cast-to-java-lang-st – Christopher Jan 13 '17 at 11:50
  • Do you use a different java version on your machine then on your CI server? – Christopher Jan 13 '17 at 11:51
  • Which is the line 826 ? – Gabriele Mariotti Jan 13 '17 at 11:51
  • 826 is the class header. @Christopher yeah, i have seen that post, but i did not consider changing the code too much because, i am not the developer/maintainer of the application. I am supposed to create the build environment. The java version was also the first thing that i can think of, but i am building the same AOSP(The app is a part of AOSP) source on my local machine, that is also builded on the server. So, if java versions would be different, it would be an issue before, i guess – caneru Jan 13 '17 at 11:59

0 Answers0