OOM error in volley diskbased cache - android

I have below OOM error on android i have used volley library for network image loading in android.
10-15 11:48:01.690: E/AndroidRuntime(22735): java.lang.OutOfMemoryError
10-15 11:48:01.690: E/AndroidRuntime(22735): at com.android.volley.toolbox.DiskBasedCache.streamToBytes(DiskBasedCache.java:322)
10-15 11:48:01.690: E/AndroidRuntime(22735): at com.android.volley.toolbox.DiskBasedCache.readString(DiskBasedCache.java:532)
10-15 11:48:01.690: E/AndroidRuntime(22735): at com.android.volley.toolbox.DiskBasedCache.readStringStringMap(DiskBasedCache.java:554)
10-15 11:48:01.690: E/AndroidRuntime(22735): at com.android.volley.toolbox.DiskBasedCache$CacheHeader.readHeader(DiskBasedCache.java:398)
10-15 11:48:01.690: E/AndroidRuntime(22735): at com.android.volley.toolbox.DiskBasedCache.initialize(DiskBasedCache.java:156)
10-15 11:48:01.690: E/AndroidRuntime(22735): at com.android.volley.CacheDispatcher.run(CacheDispatcher.java:84)

Related

Crashed app after change the package name

I try to change the package name.First, I rename package that is src folder, then select rename package name in android tools menu.Now when run the app: crashed the app.
Logcat errors :
10-15 15:35:19.747: E/AndroidRuntime(1272): FATAL EXCEPTION: main
10-15 15:35:19.747: E/AndroidRuntime(1272): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nabproduct.nabege/com.nabproduct.nabege.Collection_List_Activity}: java.lang.NullPointerException
10-15 15:35:19.747: E/AndroidRuntime(1272): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
10-15 15:35:19.747: E/AndroidRuntime(1272): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
10-15 15:35:19.747: E/AndroidRuntime(1272): at android.app.ActivityThread.access$600(ActivityThread.java:130)
10-15 15:35:19.747: E/AndroidRuntime(1272): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
10-15 15:35:19.747: E/AndroidRuntime(1272): at android.os.Handler.dispatchMessage(Handler.java:99)
10-15 15:35:19.747: E/AndroidRuntime(1272): at android.os.Looper.loop(Looper.java:137)
10-15 15:35:19.747: E/AndroidRuntime(1272): at android.app.ActivityThread.main(ActivityThread.java:4745)
10-15 15:35:19.747: E/AndroidRuntime(1272): at java.lang.reflect.Method.invokeNative(Native Method)
10-15 15:35:19.747: E/AndroidRuntime(1272): at java.lang.reflect.Method.invoke(Method.java:511)
10-15 15:35:19.747: E/AndroidRuntime(1272): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
10-15 15:35:19.747: E/AndroidRuntime(1272): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-15 15:35:19.747: E/AndroidRuntime(1272): at dalvik.system.NativeStart.main(Native Method)
10-15 15:35:19.747: E/AndroidRuntime(1272): Caused by: java.lang.NullPointerException
10-15 15:35:19.747: E/AndroidRuntime(1272): at com.nabproduct.nabege.DB_Nabege_helper.count_collection(DB_Nabege_helper.java:156)
10-15 15:35:19.747: E/AndroidRuntime(1272): at com.nabproduct.nabege.Collection_List_Activity.fill_listView(Collection_List_Activity.java:361)
10-15 15:35:19.747: E/AndroidRuntime(1272): at com.nabproduct.nabege.Collection_List_Activity.onCreate(Collection_List_Activity.java:199)
10-15 15:35:19.747: E/AndroidRuntime(1272): at android.app.Activity.performCreate(Activity.java:5008)
10-15 15:35:19.747: E/AndroidRuntime(1272): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
10-15 15:35:19.747: E/AndroidRuntime(1272): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
there is a lot of thing you should change. have you changed the application ID in the gradle file??? it doesn't change automatically. have you updated the android manifest file?
try considering there...
I set the database path with a string like this: "/data/data/com.example. nabege/databases/". I changed it and solved the problem.Thank you for answering

Android React Native Module already registered

I am trying to develop custom native toast component for android using below document. after deploying build i am getting following exception. Please help me to resolve this.
java.lang.AssertionError: Module ToastAndroid was already registered!
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at com.facebook.infer.annotation.Assertions.assertCondition(Assertions.java:65)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at com.facebook.react.bridge.NativeModuleRegistry$Builder.add(NativeModuleRegistry.java:162)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:447)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:416)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at com.facebook.react.ReactInstanceManager.recreateReactContext(ReactInstanceManager.java:345)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at com.facebook.react.ReactInstanceManager.onJSBundleLoadedFromServer(ReactInstanceManager.java:310)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at com.facebook.react.ReactInstanceManager.access$100(ReactInstanceManager.java:70)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at com.facebook.react.ReactInstanceManager$1.onJSBundleLoadedFromServer(ReactInstanceManager.java:97)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at com.facebook.react.devsupport.DevSupportManager$13$1.run(DevSupportManager.java:530)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:739)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at android.os.Looper.loop(Looper.java:135)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5257)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
your module could not name ‘ ToastAndroid’ ,cause the core package already have a module with that name .
see 'com.facebook.react.modules.toast.ToastModule'.
so change your module's name will fix it.

Where get database path in database open helper?

I try to get the database path in the constructor of database helper class like this:
public DB_Nabege_helper(Context context) {
super(context, DBname, null, 1);
Nabege_context = context;
DBpath=Nabege_context.getDatabasePath(DBname).getPath();
}
When run app : crashed app
10-15 16:41:37.164: E/AndroidRuntime(1420): FATAL EXCEPTION: main
10-15 16:41:37.164: E/AndroidRuntime(1420): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.nabproduct.nabege/com.nabproduct.nabege.Collection_List_Activity}: java.lang.NullPointerException
10-15 16:41:37.164: E/AndroidRuntime(1420): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
10-15 16:41:37.164: E/AndroidRuntime(1420): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
10-15 16:41:37.164: E/AndroidRuntime(1420): at android.app.ActivityThread.access$600(ActivityThread.java:130)
10-15 16:41:37.164: E/AndroidRuntime(1420): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
10-15 16:41:37.164: E/AndroidRuntime(1420): at android.os.Handler.dispatchMessage(Handler.java:99)
10-15 16:41:37.164: E/AndroidRuntime(1420): at android.os.Looper.loop(Looper.java:137)
10-15 16:41:37.164: E/AndroidRuntime(1420): at android.app.ActivityThread.main(ActivityThread.java:4745)
10-15 16:41:37.164: E/AndroidRuntime(1420): at java.lang.reflect.Method.invokeNative(Native Method)
10-15 16:41:37.164: E/AndroidRuntime(1420): at java.lang.reflect.Method.invoke(Method.java:511)
10-15 16:41:37.164: E/AndroidRuntime(1420): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
10-15 16:41:37.164: E/AndroidRuntime(1420): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-15 16:41:37.164: E/AndroidRuntime(1420): at dalvik.system.NativeStart.main(Native Method)
10-15 16:41:37.164: E/AndroidRuntime(1420): Caused by: java.lang.NullPointerException
10-15 16:41:37.164: E/AndroidRuntime(1420): at android.content.ContextWrapper.getDatabasePath(ContextWrapper.java:231)
10-15 16:41:37.164: E/AndroidRuntime(1420): at com.nabproduct.nabege.DB_Nabege_helper.<init>(DB_Nabege_helper.java:44)
10-15 16:41:37.164: E/AndroidRuntime(1420): at com.nabproduct.nabege.Collection_List_Activity.<init>(Collection_List_Activity.java:165)
10-15 16:41:37.164: E/AndroidRuntime(1420): at java.lang.Class.newInstanceImpl(Native Method)
10-15 16:41:37.164: E/AndroidRuntime(1420): at java.lang.Class.newInstance(Class.java:1319)
10-15 16:41:37.164: E/AndroidRuntime(1420): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
10-15 16:41:37.164: E/AndroidRuntime(1420): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
I add more code as an answer.
I see from the stacktrace that you create DB helper in the activity constructor or field initializer possibly. In both cases activity isn't initialized yet (moreover you don't need to override activity constructor in the most cases). Move DB helper assignment inside the activity onCreate() method.

Android Facebook SkImageDecoder::Factory returned null

I'm new to the Facebook API, try to load Facebook profile image to load in imageview but I got error SkImageDecoder::Factory returned null.
My code:
URL image_value = new URL("http://graph.facebook.com/"+ id + "/picture?type=large");
Bitmap bmp = BitmapFactory.decodeStream(image_value.openConnection().getInputStream());
iv1.setImageBitmap(bmp);
This is log I have:
10-15 14:05:46.782: D/skia(25501): --- SkImageDecoder::Factory returned null
10-15 14:05:46.782: W/System.err(25501): android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
10-15 14:05:46.782: W/System.err(25501): at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:6669)
10-15 14:05:46.782: W/System.err(25501): at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:972)
10-15 14:05:46.783: W/System.err(25501): at android.view.View.requestLayout(View.java:16757)
10-15 14:05:46.783: W/System.err(25501): at android.view.View.requestLayout(View.java:16757)
10-15 14:05:46.783: W/System.err(25501): at android.view.View.requestLayout(View.java:16757)
10-15 14:05:46.783: W/System.err(25501): at android.view.View.requestLayout(View.java:16757)
10-15 14:05:46.783: W/System.err(25501): at android.widget.RelativeLayout.requestLayout(RelativeLayout.java:369)
10-15 14:05:46.783: W/System.err(25501): at android.view.View.requestLayout(View.java:16757)
10-15 14:05:46.783: W/System.err(25501): at android.widget.ImageView.setImageDrawable(ImageView.java:424)
10-15 14:05:46.783: W/System.err(25501): at android.widget.ImageView.setImageBitmap(ImageView.java:439)
10-15 14:05:46.783: W/System.err(25501): at com.example.intellitick.a1$3.onComplete(a1.java:197)
10-15 14:05:46.783: W/System.err(25501): at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:276)
10-15 14:05:46.783: D/dalvikvm(25501): threadid=12: exiting
Ey I just add the next code Hope it helps

Illegal argument exception with Json

I get this error when running my code, and I don't receive anything back from json
10-15 00:29:22.396: WARN/System.err(562): java.lang.IllegalArgumentException: Illegal character in query at index 68: http://www.hotels-in-london-hotels.com/mytrolly/service.php?request={"mode":"category"}
10-15 00:29:22.425: WARN/System.err(562): at java.net.URI.create(URI.java:970)
10-15 00:29:22.425: WARN/System.err(562): at org.apache.http.client.methods.HttpGet.<init>(HttpGet.java:75)
10-15 00:29:22.436: WARN/System.err(562): at com.sampleapp.MainActivity$iTab.readTwitterFeed(MainActivity.java:128)
10-15 00:29:22.436: WARN/System.err(562): at com.sampleapp.MainActivity$iTab.<init>(MainActivity.java:65)
10-15 00:29:22.436: WARN/System.err(562): at java.lang.reflect.Constructor.constructNative(Native Method)
10-15 00:29:22.446: WARN/System.err(562): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
10-15 00:29:22.446: WARN/System.err(562): at android.view.LayoutInflater.createView(LayoutInflater.java:500)
10-15 00:29:22.456: WARN/System.err(562): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
10-15 00:29:22.456: WARN/System.err(562): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
10-15 00:29:22.466: WARN/System.err(562): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
10-15 00:29:22.466: WARN/System.err(562): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
10-15 00:29:22.466: WARN/System.err(562): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
10-15 00:29:22.476: WARN/System.err(562): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
10-15 00:29:22.476: WARN/System.err(562): at android.app.Activity.setContentView(Activity.java:1647)
10-15 00:29:22.476: WARN/System.err(562): at com.sampleapp.MainActivity.onCreate(MainActivity.java:362)
10-15 00:29:22.486: WARN/System.err(562): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-15 00:29:22.486: WARN/System.err(562): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
10-15 00:29:22.486: WARN/System.err(562): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
10-15 00:29:22.496: WARN/System.err(562): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
10-15 00:29:22.496: WARN/System.err(562): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
10-15 00:29:22.496: WARN/System.err(562): at android.os.Handler.dispatchMessage(Handler.java:99)
10-15 00:29:22.506: WARN/System.err(562): at android.os.Looper.loop(Looper.java:123)
10-15 00:29:22.506: WARN/System.err(562): at android.app.ActivityThread.main(ActivityThread.java:4627)
10-15 00:29:22.506: WARN/System.err(562): at java.lang.reflect.Method.invokeNative(Native Method)
10-15 00:29:22.506: WARN/System.err(562): at java.lang.reflect.Method.invoke(Method.java:521)
10-15 00:29:22.506: WARN/System.err(562): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-15 00:29:22.506: WARN/System.err(562): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-15 00:29:22.506: WARN/System.err(562): at dalvik.system.NativeStart.main(Native Method)
Basically I'm trying to use json, and the problem I'm having is with this line
HttpGet httpGet = new HttpGet(
"http://www.hotels-in-london-hotels.com/mytrolly/service.php?request={\"mode\":\"category\"}");
I've encoded the string, and I still get the exception
try {
url = "http://www.hotels-in-london-hotels.com/mytrolly/service.php?request={\"mode\":\"category\"}";
String encodedurl = URLEncoder.encode(url,"UTF-8");
Log.d("TEST", encodedurl);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
Any solutions?
You probably need to URL encode your parameter string. Try using URLEncoder
Character 68 is =, by the way.
Also, is there a problem beyond this warning (like you don't get desired result)? Note - it's not an error but warning.
The problem is the curly braces. I'd expect URLEncoder to take care of it, but you can also just manually replace them. '{' should be %7B and '}' should be "%7D".
This may helps you
String link="http://example.php?string1="+URLEncoder.encode(string1)+"&string2="+URLEncoder
.encode(string2)+"&string3="+URLEncoder.encode(string3)+"&string4="+URLEncoder.encode(string4)+"";

Categories

Resources