Hello. My application is crashed when I navigate through 2 views. I am just opening subscriber controller from tasklist.js and than closing it. On the fifth or six attempt applications crashes. the erroor is : exception on thread: main msg:java.lang.NullPointerException. can you help me please?
1.It is my console log from starting app till it crashes:
[INFO] : Installing app on device: MediaPad 7 Youth [INFO] : App successfully installed [INFO] : Starting app: com.energo/.EnergoproActivity [INFO] : Application pid: 9681 [INFO] : Project built successfully in 48s 859ms -- Start application log ----------------------------------------------------- [INFO] : TiApplication: (main) [0,0] checkpoint, app created. [INFO] : TiApplication: (main) [119,119] Titanium 3.2.3 (2014/04/22 10:17 b958a70) [INFO] : TiApplication: (main) [217,336] Titanium Javascript runtime: v8 [INFO] : TiRootActivity: (main) [0,0] checkpoint, on root activity create, savedInstanceState: null [WARN] : V8Object: Runtime disposed, cannot set property 'userAgent' [ERROR] : dalvikvm: GC_FOR_ALLOC freed 966K, 16% free 7100K/8391K, paused 2ms+2ms, total 15ms [INFO] : tasklist.js opened [ERROR] : dalvikvm: GC_FOR_ALLOC freed 1488K, 20% free 7364K/9159K, paused 2ms+3ms, total 21ms [INFO] : I/dalvikvm-heap: Grow heap (frag case) to 8.065MB for 614416-byte allocation [ERROR] : dalvikvm: GC_FOR_ALLOC freed 11K, 19% free 7952K/9799K, paused 2ms+2ms, total 19ms [INFO] : TiRootActivity: (main) [0,0] checkpoint, on root activity resume. activity = com.energo.EnergoproActivity@41a93b60 [ERROR] : dalvikvm: GC_CONCURRENT freed 1237K, 16% free 8671K/10247K, paused 12ms+6ms, total 46ms [INFO] : Choreographer: Skipped 111 frames! The application may be doing too much work on its main thread. [INFO] : TiAnalyticsSvc: (Thread-723) [30216,30216] Analytics Service Started [ERROR] : dalvikvm: GC_CONCURRENT freed 1372K, 16% free 9301K/11015K, paused 15ms+7ms, total 60ms [INFO] : TiAnalyticsSvc: (Thread-723) [15127,45343] Stopping Analytics Service [INFO] : subscriber.js opened [ERROR] : dalvikvm: GC_CONCURRENT freed 1323K, 15% free 9989K/11655K, paused 12ms+8ms, total 64ms [INFO] : subscriber.js opened [ERROR] : dalvikvm: GC_CONCURRENT freed 1891K, 18% free 10135K/12359K, paused 12ms+22ms, total 81ms [INFO] : subscriber.js opened [ERROR] : dalvikvm: GC_CONCURRENT freed 1796K, 17% free 10324K/12423K, paused 13ms+11ms, total 81ms [ERROR] : dalvikvm: GC_CONCURRENT freed 2056K, 19% free 10260K/12615K, paused 12ms+23ms, total 109ms [WARN] : dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x412df2a0) [ERROR] : TiApplication: (main) [335503,380846] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 3.2.3,2014/04/22 10:17,b958a70 [ERROR] : TiApplication: java.lang.NullPointerException [ERROR] : TiApplication: at android.view.ViewConfiguration.get(ViewConfiguration.java:332) [ERROR] : TiApplication: at android.view.View.<init>(View.java:3250) [ERROR] : TiApplication: at android.view.ViewGroup.<init>(ViewGroup.java:416) [ERROR] : TiApplication: at android.widget.FrameLayout.<init>(FrameLayout.java:93) [ERROR] : TiApplication: at ti.modules.titanium.ui.widget.tableview.TiTableView.<init>(TiTableView.java:266) [ERROR] : TiApplication: at ti.modules.titanium.ui.widget.TiUITableView.processProperties(TiUITableView.java:106) [ERROR] : TiApplication: at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:1185) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:480) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:471) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:449) [ERROR] : TiApplication: at ti.modules.titanium.ui.TableViewProxy.getTableView(TableViewProxy.java:147) [ERROR] : TiApplication: at ti.modules.titanium.ui.TableViewProxy.handleSetData(TableViewProxy.java:692) [ERROR] : TiApplication: at ti.modules.titanium.ui.TableViewProxy.handleMessage(TableViewProxy.java:869) [ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:95) [ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:137) [ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:4830) [ERROR] : TiApplication: at java.lang.reflect.Method.invokeNative(Native Method) [ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Method.java:511) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556) [ERROR] : TiApplication: at dalvik.system.NativeStart.main(Native Method)2.index.js:
var taskList = new Alloy.createController("taskList").getView(); taskList.open();3.taskList.js:
var tasks = Alloy.Collections.taskList; tasks.fetch(); Ti.API.info('tasklist.js opened'); function fillRouteList(){ //fill tasks var file = Ti.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory, 'TaskList.txt'); var data = file.read().text; var response = JSON.parse(data); var tasks = Alloy.Collections.taskList; if(tasks.length==0) { for(var i =0;i<response.count;i++){ var task = Alloy.createModel("taskList", response.tasks[i]); tasks.add(task); task.save(task); } }else{ alert("??? ???? ?????????????"); } tasks.fetch(); // fill subrscribers var subscribers = Alloy.Collections.subscriber; subscribers.fetch(); var file = Ti.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory, 'Subscribes.txt'); var data = file.read().text; var response = JSON.parse(data); var subs = Alloy.Collections.subscriber; if(subs.length==0) { for(var i =0;i<response.count;i++){ var sub = Alloy.createModel("subscriber", response.sub[i]); subs.add(sub); sub.save(sub); } }else{ alert("??? ???? ?????????????2"); } subs.fetch(); } function removeAll(){ var tasks = Alloy.Collections.taskList; while(tasks.length) { tasks.at(0).destroy(); } var subscribers = Alloy.Collections.subscriber; while (subscribers.length > 0) { var model = subscribers.at(0); subscribers.remove(model); // this is how I can delete whole model. clear model model.destroy(); } } function filterByTypeAgdgena(e){ tasks.fetch({ query: 'SELECT * FROM taskList where taskType = "???????"' }); } function filterByTypeChachra(e){ tasks.fetch({ query: 'SELECT * FROM taskList where taskType = "?????"' }); } function filterByTypeBoth(e){ tasks.fetch({ query: 'SELECT * FROM taskList where taskType = "?????/???????"' }); } function ClearFilterByType(e){ tasks.fetch({ query: 'SELECT * FROM taskList' }); } $.taskListTable.addEventListener("click", function(e) { var sections = $.taskListTable.data; var section = sections[0]; var theRow = section.rows[e.index]; var rowContainer = theRow.getChildren()[0]; //This is "rowContainer" var taskListRowTitleIdContainer = rowContainer.getChildren()[0]; // this is taskListRowTitleIdContainer var selectedId = taskListRowTitleIdContainer.getChildren()[0]; var taskListRowTitleNameContainer = rowContainer.getChildren()[1]; // this is taskListRowTitleNameContainer var selectedName = taskListRowTitleNameContainer.getChildren()[0]; var send = tasks.get(e.rowData.model); var subscriber = Alloy.createController("subscriber", { data: selectedId.text, dataName : selectedName.text }); subscriber.getView().open(); }); Alloy.Globals.destroySubscriber = function() { subscriber.destroy(); subscriber.getView().close(); };3.and subscriber.js:
var args = arguments[0] || {}; // alert(args.$model.attributes.id); var subscribers = Alloy.Collections.subscriber; subscribers.fetch(); Ti.API.info('subscriber.js opened'); var search = Alloy.createController("searchview").getView(); $.subscriberListTable.search = search; $.container.addEventListener("open", function() { $.container.activity.onCreateOptionsMenu = function(e) { var menu = e.menu; menu.add({ title:"?????? ?????????????", showAsAction : Ti.Android.SHOW_AS_ACTION_NEVER }); menu.add({ title:"?????? ???????????", showAsAction : Ti.Android.SHOW_AS_ACTION_NEVER }); menu.add({ title: args.dataName, showAsAction : Ti.Android.SHOW_AS_ACTION_ALWAYS }); var backBtn = menu.add({ title:"<-?????????? ???", showAsAction : Ti.Android.SHOW_AS_ACTION_ALWAYS }); var searchBtn = menu.add({ title: "Table Search", icon: (Ti.Android.R.drawable.ic_menu_search ? Ti.Android.R.drawable.ic_menu_search : "my_search.png"), actionView: search, showAsAction : Ti.Android.SHOW_AS_ACTION_ALWAYS }); searchBtn.addEventListener("click", function(e) { // $.searchTextField.setVisible('true'); }); backBtn.addEventListener("click", function(e) { $.container.close(); }); }; $.container.activity.invalidateOptionsMenu(); }); function filterFunction(collection) { var subscribers = Alloy.Collections.subscriber; return subscribers.where({ taskNum : args.data }); } function filterFunctionTransform(model) { var transform = model.toJSON(); return transform; } function openTaskList(){ tasks.fetch(); Alloy.Globals.destroySubscriber(); } function refreshSubscribersList() { subscribers.fetch(); } $.subscriberListTable.addEventListener("click", function(e) { var sections = $.subscriberListTable.data; var section = sections[0]; var theRow = section.rows[e.index]; var rowIndex = e.index; var rowContainer = theRow.getChildren()[0]; //This is "rowContainer" var sbuscriberListRowTitleIdContainer = rowContainer.getChildren()[0]; // this is subscriberListRowTitleIdContainer var selectedId = sbuscriberListRowTitleIdContainer.getChildren()[0]; var subscriber = Alloy.createController("form", { id : selectedId.text, data : args.data }); subscriber.getView().open(); });Can you give any advices?I think it's heap problem, but I dont know why is heap overfilled? if you need to see my views too let me know and I'll copy them too