运行时异常Nativescript-Angular

时间:2016-11-16 12:58:42

标签: android nativescript angular2-nativescript

我是nativescript-angular的新手,虽然我因为一些开发的应用程序而表现出对Angular2的熟练程度。

我正在使用此sidedrawer,其中包含home,about和contact组件。

此外,我创建了一个搜索组件,负责接受用户输入并搜索搜索词的特定搜索引擎。

我在Android连接设备(Lollipop)上成功运行了我的nativescript应用程序但是我得到了:

  1. D / AccessibilityManager(17308):at com.tns.Runtime.callJSMethodNative(Native Method)
  2. 当我导航到搜索组件时,搜索组件会停留几秒钟(比如2秒)并自行返回主页组件。
  3. 以下重点介绍我的配置

    Android构建工具:25.0.0 打字稿:2.0.9 最新的nativescript模块 到目前为止我做了什么(删除并重新安装):

    node_modules 挂钩 平台android

    BUILD SUCCESSFUL
    Total time: 6 mins 10.37 secs
    Project successfully built
    Successfully deployed on device with identifier 'I7LVZ97L99999999'.
    D/dxoptimizer.hcq( 1100): Got unexpected exception:
    java.io.WriteAbortedException: Read an exception;                    
    java.io.NotSerializableException: org.json.JSONObject
    D/dxoptimizer.hcq( 1230): Got unexpected exception:      
    java.io.WriteAbortedException: Read an exception; 
    java.io.NotSerializableException: org.json.JSONObject    
    D/AccessibilityManager(17308): at com.tns.Runtime.callJSMethodNative
    (Native Method)
    D/AccessibilityManager(17308): at   
    com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:865)
    D/AccessibilityManager(17308): at 
    com.tns.Runtime.callJSMethodImpl(Runtime.java:730)
    D/AccessibilityManager(17308): at 
    com.tns.Runtime.callJSMethod(Runtime.java:716)
    D/AccessibilityManager(17308): at 
    com.tns.Runtime.callJSMethod(Runtime.java:697)
    D/AccessibilityManager(17308): at 
    com.tns.Runtime.callJSMethod(Runtime.java:687)
    JS: Angular 2 is running in the development mode. 
    Call enableProdMode() to enable the production mode.
    D/dxoptimizer.hcq( 1100): Got unexpected exception:
    java.io.NotSerializableException: org.json.JSONObject
    java.io.WriteAbortedException: Read an exception;
    D/dxoptimizer.hcq( 1230): Got unexpected exception:
    java.io.WriteAbortedException: Read an exception;
    java.io.NotSerializableException: org.json.JSONObject
    JS: result: 0
    D/dxoptimizer.hcq( 1230): Got unexpected exception:
    java.io.WriteAbortedException: Read an exception;
    java.io.NotSerializableException: org.json.JSONObject
    D/dxoptimizer.hcq( 1100): Got unexpected exception:
    java.io.WriteAbortedException: Read an exception; 
    java.io.NotSerializableException: org.json.JSONObject
    D/dxoptimizer.hcq( 1230): Got unexpected exception: 
    java.io.WriteAbortedException: Read an exception;   
    java.io.NotSerializableException: org.json.JSONObject
    D/dxoptimizer.hcq( 1100): Got unexpected exception:
    java.io.WriteAbortedException: Read an exception; 
    java.io.NotSerializableException: org.json.JSONObject      
    D/dxoptimizer.hcq( 1230): Got unexpected exception:
    java.io.WriteAbortedException: Read an exception;  
    java.io.NotSerializableException: org.json.JSONObject
    
    ******SEARCH COMPONENT *********
    
    
    export class SearchComponent implements OnInit {
    
    private text: string = 'Search Page';
    private resultList: Array; //Holds the returned search results
    private metaData: any; //Holds data necessary for paginating search results
    private query: string;
    private isLoading: boolean;
    private database: any;
    private isEditing: boolean;
    
    constructor( private location: Location,private page: Page,private
    routerExtensions: RouterExtensions, private webService: WebService){   
    this.isLoading = false;
    this.query = "";
    this.resultList = [];
    //this.resultList = JSON.parse(ApplicationSettings.getString("resultList","
    []"));
    console.log("result: "+this.resultList.length);
    
    //Called on navigate back because constructor does not get called
    on navigate back
    //this.location.subscribe((path)=>{
    //this.resultList = JSON.parse(ApplicationSettings.getString
    ("resultList"," []"));
    //});
    }
    ngOnInit(){
    
      this.isEditing = true;
    }
    
    navBack(){
    this.hideKeyboard();
    this.routerExtensions.backToPreviousPage();
    }
    
    hideKeyboard(){
    let searchBar = this.page.getViewById("searchBox");
    setTimeout(function(){
    searchBar.dismissSoftInput();
    }, 100);
    }
    search(){
    
    //var textview: TextView = <TextView> args.object;
    //if(isAndroid){
    //textview.android.clearFocus();
    //}
    this.hideKeyboard();
    this.isLoading = true;
    this.text = "searching"; 
    
     permissions.requestPermission("android.Manifest.permission.INTERNET"
     ,"INTERNET PERMISSION NEEDED")
           .then(()=>{
                      this.webService
                          .googleSearch(this.query)
                          .subscribe( (resp:Response) => {
                                          this.resultList = resp.json().items;
    
                                          console.log(this.resultList);
    
                                          this.metaData = resp.json().queries;
    
                                          console.log(this.metaData);
                                          this.text = "Finished Searching!!!";
                                          this.isLoading = false;
                                          this.isEditing = false;
                                         },
                                err => {
                                        console.log(err);
                                        alert(JSON.stringify(err));
                                 }
                             );
           })
           .catch(()=>{
             this.text = "No Permissions";
           })
    }
    
    onCancel(){
    this.query = "";
    this.navBack();
    }
    
    onItemTap(){
    
    ApplicationSettings.setString("resultList",JSON.stringify(this.resultList));
    //Navigate to details view
    }
    }
    

0 个答案:

没有答案
相关问题