Buggy code:
public class CameraActivity extends Fragment { public interface CameraPreviewListener { public void onPictureTaken ( String originalPicture ) { } } private CameraActivity . CameraPreviewListener eventListener ; private static final String TAG = "CameraPreview" ; public FrameLayout mainLayout ; public FrameLayout frameContainerLayout ; private Preview mPreview ; private boolean canTakePicture = true ; private View view ; private Parameters cameraParameters ; private Camera mCamera ; private int numberOfCameras ; private int cameraCurrentlyLocked ; private int defaultCameraId ; public String defaultCamera ; public boolean tapToTakePicture ; public boolean dragEnabled ; public int width ; public int height ; public int x ; public int y ; public void setEventListener ( CameraActivity . CameraPreviewListener listener ) { } private String appResourcesPackage ; @ Override public View onCreateView ( LayoutInflater inflater , ViewGroup container , Bundle savedInstanceState ) { } @ Override public void onCreate ( Bundle savedInstanceState ) { } public void setRect ( int x , int y , int width , int height ) { } private void createCameraPreview ( ) { } private void setDefaultCameraId ( ) { } @ Override public void onResume ( ) { } @ Override public void onPause ( ) { } public Camera getCamera ( ) { } public void switchCamera ( ) { } public void setCameraParameters ( Camera . Parameters params ) { } public boolean hasFrontCamera ( ) { } public Bitmap cropBitmap ( Bitmap bitmap , Rect rect ) { } public void takePicture ( final double maxWidth , final double maxHeight ) { } private void processPicture ( Bitmap bitmap ) { } private void generatePictureFromView ( final Bitmap originalPicture , final Bitmap picture ) { <START_BUG> Bitmap image ; <END_BUG> final FrameLayout cameraLoader = ( ( FrameLayout ) ( view . findViewById ( getResources ( ) . getIdentifier ( "camera_loader" , "id" , appResourcesPackage ) ) ) ) ; cameraLoader . setVisibility ( VISIBLE ) ; final ImageView pictureView = ( ( ImageView ) ( view . findViewById ( getResources ( ) . getIdentifier ( "picture_view" , "id" , appResourcesPackage ) ) ) ) ; new Thread ( ) { public void run ( ) { try { final File picFile = storeImage ( picture , "_preview" ) ; final File originalPictureFile = storeImage ( originalPicture , "_original" ) ; image = BitmapFactory . decodeFile ( originalPictureFile . getAbsolutePath ( ) ) ; processPicture ( image ) ; getActivity ( ) . runOnUiThread ( new Runnable ( ) { @ Override public void run ( ) { cameraLoader . setVisibility ( INVISIBLE ) ; pictureView . setImageBitmap ( null ) ; } } ) ; } catch ( Exception e ) { getActivity ( ) . runOnUiThread ( new Runnable ( ) { @ Override public void run ( ) { cameraLoader . setVisibility ( INVISIBLE ) ; pictureView . setImageBitmap ( null ) ; } } ) ; } } } . start ( ) ; } private File getOutputMediaFile ( String suffix ) { } private File storeImage ( Bitmap image , String suffix ) { } public int calculateInSampleSize ( BitmapFactory . Options options , int reqWidth , int reqHeight ) { } private Bitmap loadBitmapFromView ( View v ) { } @ Override public void onDestroy ( ) { } public void printPreviewSize ( String from ) { } }

Fix:
final Bitmap image ;