I'm trying to set icon of a Marker in Google Maps v2. I'm downloading some images over network and change their background in code. After that I'm setting them as icons to markers. At first creation of the map it works fine but after rotation there is an exception.
Android version I run this on: 4.3
My code is as follows:
UrlImageViewHelper.loadUrlDrawable(TuvaletlerMapActivity.this,
iconUrl, new UrlImageViewCallback() {
@Override
public void onLoaded(ImageView iv, Bitmap bm,
String arg2, boolean arg3) {
Bitmap bitmap = VenuesHelper.iconizeBitmap(bm);
marker.setIcon(BitmapDescriptorFactory
.fromBitmap(bitmap));
}
});
and VenuesHelper.iconizeBitmap()
is as follows:
public static Bitmap iconizeBitmap(Bitmap bm) {
Bitmap bitmap = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(),
bm.getConfig());
Canvas canvas = new Canvas(bitmap);
canvas.drawColor(Color.parseColor("#33B5E5"));
canvas.drawBitmap(bm, 0, 0, null);
return bitmap;
}
Stack trace is as follows:
08-07 10:16:50.684: E/AndroidRuntime(19001): FATAL EXCEPTION: main
08-07 10:16:50.684: E/AndroidRuntime(19001): java.lang.IllegalArgumentException: Released unknown bitmap reference
08-07 10:16:50.684: E/AndroidRuntime(19001): at maps.as.i.a(Unknown Source)
08-07 10:16:50.684: E/AndroidRuntime(19001): at maps.ah.o.b(Unknown Source)
08-07 10:16:50.684: E/AndroidRuntime(19001): at maps.ah.bn.a(Unknown Source)
08-07 10:16:50.684: E/AndroidRuntime(19001): at bix.onTransact(SourceFile:204)
08-07 10:16:50.684: E/AndroidRuntime(19001): at android.os.Binder.transact(Binder.java:347)
08-07 10:16:50.684: E/AndroidRuntime(19001): at com.google.android.gms.internal.dm$a$a.f(Unknown Source)
08-07 10:16:50.684: E/AndroidRuntime(19001): at com.google.android.gms.maps.model.Marker.setIcon(Unknown Source)
08-07 10:16:50.684: E/AndroidRuntime(19001): at com.behlul.tuvaletbul.TuvaletlerMapActivity$TuvaletliYukleCallbacks$1.onLoaded(TuvaletlerMapActivity.java:250)
08-07 10:16:50.684: E/AndroidRuntime(19001): at com.koushikdutta.urlimageviewhelper.UrlImageViewHelper$2.run(UrlImageViewHelper.java:615)
08-07 10:16:50.684: E/AndroidRuntime(19001): at com.koushikdutta.urlimageviewhelper.UrlImageViewHelper$3.onPostExecute(UrlImageViewHelper.java:653)
08-07 10:16:50.684: E/AndroidRuntime(19001): at com.koushikdutta.urlimageviewhelper.UrlImageViewHelper$3.onPostExecute(UrlImageViewHelper.java:1)
08-07 10:16:50.684: E/AndroidRuntime(19001): at android.os.AsyncTask.finish(AsyncTask.java:631)
08-07 10:16:50.684: E/AndroidRuntime(19001): at android.os.AsyncTask.access$600(AsyncTask.java:177)
08-07 10:16:50.684: E/AndroidRuntime(19001): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
08-07 10:16:50.684: E/AndroidRuntime(19001): at android.os.Handler.dispatchMessage(Handler.java:99)
08-07 10:16:50.684: E/AndroidRuntime(19001): at android.os.Looper.loop(Looper.java:137)
08-07 10:16:50.684: E/AndroidRuntime(19001): at android.app.ActivityThread.main(ActivityThread.java:5103)
08-07 10:16:50.684: E/AndroidRuntime(19001): at java.lang.reflect.Method.invokeNative(Native Method)
08-07 10:16:50.684: E/AndroidRuntime(19001): at java.lang.reflect.Method.invoke(Method.java:525)
08-07 10:16:50.684: E/AndroidRuntime(19001): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-07 10:16:50.684: E/AndroidRuntime(19001): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-07 10:16:50.684: E/AndroidRuntime(19001): at dalvik.system.NativeStart.main(Native Method)