There's some error when android loading layout,but have no effective on running

后端 未结 2 1938
一生所求
一生所求 2021-02-05 16:33

So,that\'s the logcat information I get.The app still can run,but I want to know the reason why I get this error. I don\'t understand why i get this so i even don\'t know how to

相关标签:
2条回答
  • 2021-02-05 16:45

    I was getting the same error. I found out that it is due to the attribute android:sharedUserId="com.something" that I was using in the manifest files.

    Suppose version 1 of your application has android:sharedUserId in the manifest and initialises a ContentProvider.

    Now, suppose in version 2, you remove the android:sharedUserId from the manifest and try to access the ContentProvider created in version 1.

    In this case, the recent version will not be able to access the ContentProvider created in version 1.

    0 讨论(0)
  • 2021-02-05 17:08

    Sorry to answer this old question,but i solved this exception in my project.

    I think what leads to the exception is we are using the context of our activity when it is creating.

    My code is something like:

    @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            regToWx();
    }
    
    
    private void regToWx(){
        IWXAPI  api;
        api = WXAPIFactory.createWXAPI(this, Constants.WX_APP_ID, true);
        api.registerApp(Constants.WX_APP_ID);
        String text = "123";
        WXTextObject textObj = new WXTextObject();
        textObj.text = text;
    
        WXMediaMessage msg = new WXMediaMessage();
        msg.mediaObject = textObj;
        msg.description = text;
    
        SendMessageToWX.Req req = new SendMessageToWX.Req();
        req.scene = SendMessageToWX.Req.WXSceneSession;
        req.transaction = String.valueOf(System.currentTimeMillis());
        req.message = msg;
    
        api.sendReq(req);
    }
    

    As the regToWx method need to create something by this which is the context,but i think the context can not be used(in some ways) inside onCreate method. So I just put it in a thread and then the problem is solved.

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            new Thread(new Runnable() {
            @Override
            public void run() {
    
                regToWx();
            }
        }).start();
    
    }
    

    So try to find out what you have done with your context in onCreate method, put these code out of the it or just make the code asynchronous.

    0 讨论(0)
提交回复
热议问题