不幸的是,包安装程序已停止

时间:2016-08-06 21:35:40

标签: android rx-java rxpermissions

背景:我尝试使用 RxPermissions 进行简单的操作..我使用下面的代码/设置创建了一个新项目,但是当我启动应用程序时我收到了一条消息"对不起包装安装程序已经停止"

gradle.build

dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'])
  testCompile 'junit:junit:4.12'
  compile 'com.android.support:appcompat-v7:24.1.1'
  compile 'com.tbruyelle.rxpermissions:rxpermissions:0.7.0@aar'


  compile 'io.reactivex:rxandroid:1.2.1'
  // Because RxAndroid releases are few and far between, it is recommended you also
  // explicitly depend on RxJava's latest version for bug fixes and new features.
  compile 'io.reactivex:rxjava:1.1.6'

}

MainActivity.java

public class MainActivity extends Activity {

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

    // Must be done during an initialization phase like onCreate
    ((Button) findViewById(R.id.button)).setOnClickListener(new View.OnClickListener() {
      @Override public void onClick(View view) {
        RxPermissions.getInstance(MainActivity.this)
            .request(Manifest.permission.CAMERA)
            .subscribe(new Action1<Boolean>() {
              @Override public void call(Boolean aBoolean) {

              }
            });
      }
    });


  }
}

1 个答案:

答案 0 :(得分:1)

我忘了在清单中声明权限Manifest.permission.CAMERA