如何解决运行时错误“访问被拒绝找到属性”?

时间:2019-01-22 05:25:35

标签: java android runtime-error

我正在处理一个简单的计数器项目,您按一个按钮,显示的数字将为+1或-1。我收到run time error指示:

  

E / libc:访问被拒绝找到属性“ vendor.debug.egl.profiler”

此错误来自何处?并可以做些什么来解决它?

package com.example.mtglifecounter;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

Button counter1Up, counter1Down, counter2Up, counter2Down;
TextView lifeCount1, lifeCount2;


int life1 = 20;
int life2 = 20;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    setUI();

    counter1Up.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            life1 = life1+ 1;
            lifeCount1.setText(life1);
        }
    });

    counter1Down.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            life1 = life1 -1;
            lifeCount1.setText(life1);
        }
    });

    counter2Up.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            life2 = life2 + 1;
            lifeCount2.setText(life2);
        }
    });

    counter2Down.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            life2 = life2 - 1;
            lifeCount2.setText(life2);
        }
    });
}

public void setUI(){
    counter1Up = findViewById(R.id.counter1UpBTN);
    counter1Down = findViewById(R.id.counter1DownBTN);
    counter2Up = findViewById(R.id.counter2UpBTN);
    counter2Down = findViewById(R.id.counter2DownBTN);

    lifeCount1 = findViewById(R.id.counter1TV);
    lifeCount2 = findViewById(R.id.counter2TV);

    lifeCount1.setText("20");
    lifeCount2.setText("20");
}
}

这就是Logcat中出现的所有内容:

2019-01-21 21:12:49.524 22001-22049/com.example.mtglifecounter E/libc: Access denied finding property "vendor.debug.egl.profiler"

1 个答案:

答案 0 :(得分:0)

此错误来自何处?

Android SELinux(规则/配置,由OEM完成)

该如何解决? 参考:

需要使用audit2allow和其他工具,也许最终可以修复它。

更详细的解释可以参考another post