Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (android)
Viewing all articles
Browse latest Browse all 7655

Android null pointer exception on page change

$
0
0

HI I am trying to run a mobile app on my nexus 5 it works perfectly on the iOS simulator I am using Titanium Studio, build: 3.3.0.201407100905 and the apks are android 2.3 all the way to 4.4.2

The problem seems to to be its getting a null pointer exception when it tries to switch to the new page. or add rows to the table. the function is called if there is no json file available and should allow the user to create a profile.

Here is the code

userData.ProfileSetupPage=function(){
    console.log("profile set up called");
    var profileSetupPages = Titanium.UI.createWindow({  
    title:'ProfileSetup',
    backgroundColor:'#662211',
    //statusBarStyle : Titanium.UI.iPhone.StatusBar.LIGHT_CONTENT,
    orientationModes:[Ti.UI.LANDSCAPE_LEFT,Ti.UI.LANDSCAPE_RIGHT,Ti.UI.PORTRAIT,Ti.UI.UPSIDE_PORTRAIT ]
});
console.log("profile set up called 2");
    var ProfileTable=Ti.UI.createTableView({
        top: 10,
        height : "auto",
 
        //backgroundColor:"none",
 
    });
    console.log("profile set up called 3");
    var nameRow=Ti.UI.createTableViewRow({
        height:"auto"});
 
    var NameTextField=Ti.UI.createTextField({
         borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
        color: '#336699',
        width: "250dp", height: "auto",
        value:"name",
        clearOnEdit:"true",
        backgroundColor: 'white'
    });
 
    nameRow.add(NameTextField);
    console.log("profile set up called 4");
    ProfileTable.add(nameRow);
    var emailRow=Ti.UI.createTableViewRow({
        height:"auto"});
 
    var emailTextField=Ti.UI.createTextField({
         borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
        color: '#336699',
        width: "250dp", height: "auto",
        value:"email",
        clearOnEdit:"true",
        backgroundColor: 'white'
    });
    console.log("profile set up called 5");
    emailRow.add(emailTextField);
    ProfileTable.add(emailRow);
    var saveProfileRow=Ti.UI.createTableViewRow({
        height:"auto"});
    var saveProfileButton= Ti.UI.createButton({
    title:"save",
    width:"auto",
     backgroundGradient : {
        type : 'linear',
        colors : ['#ffffff', '#565656'],
        startPoint : {
            x : 0,
            y : 0
        }
      },
       borderRadius : 5
 
});
console.log("profile set up called 6");
 
saveProfileButton.addEventListener("click",function(e){
    Ti.App.fireEvent("clickSound",{From:"save btn"});
    userData.save({userName: NameTextField.value , email: emailTextField.value,chain:0,points:0,firstSession:0,lastsession:0});
    alert("Profile data saved");
    profileSetupPages.close();
    tabGroup.open();
 
});
saveProfileRow.add(saveProfileButton);
 
console.log("profile set up called 7");
 
ProfileTable.appendRow([nameRow,emailRow,saveProfileRow]);
console.log("profile set up called 7.1");
profileSetupPages.add(ProfileTable);
console.log("profile set up called 7.2");
tabGroup.close();
console.log("profile set up called 7.3");
profileSetupPages.open();
console.log("profile set up called 7.4");
 
console.log("profile set up called 8");
 
};
and here is the logs
[INFO] :   creating userData
[INFO] :   profile set up called
[INFO] :   profile set up called 2
[INFO] :   profile set up called 3
[INFO] :   profile set up called 4
[INFO] :   profile set up called 5
[INFO] :   profile set up called 6
[INFO] :   profile set up called 7
[WARN] :   dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x4162fba8)
[ERROR] :  TiApplication: (main) [1337,1337] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start activity ComponentInfo{com.TurtlebackMedia.ThePracticeAPP/com.TurtlebackMedia.ThePracticeAPP.ThePracticeAppActivity}: java.lang.NullPointerException; Titanium 3.2.3,2014/04/22 10:17,b958a70
[ERROR] :  TiApplication: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.TurtlebackMedia.ThePracticeAPP/com.TurtlebackMedia.ThePracticeAPP.ThePracticeAppActivity}: java.lang.NullPointerException
[ERROR] :  TiApplication:   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
[ERROR] :  TiApplication:   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
[ERROR] :  TiApplication:   at android.app.ActivityThread.access$800(ActivityThread.java:135)
[ERROR] :  TiApplication:   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
[ERROR] :  TiApplication:   at android.os.Handler.dispatchMessage(Handler.java:102)
[ERROR] :  TiApplication:   at android.os.Looper.loop(Looper.java:136)
[ERROR] :  TiApplication:   at android.app.ActivityThread.main(ActivityThread.java:5001)
[ERROR] :  TiApplication:   at java.lang.reflect.Method.invokeNative(Native Method)
[ERROR] :  TiApplication:   at java.lang.reflect.Method.invoke(Method.java:515)
[ERROR] :  TiApplication:   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
[ERROR] :  TiApplication:   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
[ERROR] :  TiApplication:   at dalvik.system.NativeStart.main(Native Method)
[ERROR] :  TiApplication: Caused by: java.lang.NullPointerException
[ERROR] :  TiApplication:   at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:472)
[ERROR] :  TiApplication:   at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:449)
[ERROR] :  TiApplication:   at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:487)
[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.handleAppendRow(TableViewProxy.java:280)
[ERROR] :  TiApplication:   at ti.modules.titanium.ui.TableViewProxy.handleMessage(TableViewProxy.java:889)
[ERROR] :  TiApplication:   at android.os.Handler.dispatchMessage(Handler.java:98)
[ERROR] :  TiApplication:   at org.appcelerator.kroll.common.TiMessenger.dispatchMessage(TiMessenger.java:389)
[ERROR] :  TiApplication:   at org.appcelerator.kroll.common.TiMessenger.dispatchPendingMessages(TiMessenger.java:374)
[ERROR] :  TiApplication:   at org.appcelerator.kroll.common.TiMessenger$2.getResult(TiMessenger.java:252)
[ERROR] :  TiApplication:   at org.appcelerator.kroll.common.TiMessenger.sendBlockingMessage(TiMessenger.java:286)
[ERROR] :  TiApplication:   at org.appcelerator.kroll.common.TiMessenger.sendBlockingRuntimeMessage(TiMessenger.java:202)
[ERROR] :  TiApplication:   at org.appcelerator.kroll.KrollProxy.fireSyncEvent(KrollProxy.java:784)
[ERROR] :  TiApplication:   at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:532)
[ERROR] :  TiApplication:   at org.appcelerator.titanium.TiLaunchActivity.onCreate(TiLaunchActivity.java:144)
[ERROR] :  TiApplication:   at org.appcelerator.titanium.TiRootActivity.onCreate(TiRootActivity.java:97)
[ERROR] :  TiApplication:   at android.app.Activity.performCreate(Activity.java:5231)
[ERROR] :  TiApplication:   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
[ERROR] :  TiApplication:   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
[ERROR] :  TiApplication:   ... 11 more
Any help would be appriciated

Viewing all articles
Browse latest Browse all 7655

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>