我正在用firebase-auth构建我的第一个应用程序。
我有Google服务10.0.84安装在我的设备23上。
我最初禁用了Google服务的权限,并允许它们根据请求进行操作。
当我添加firebase-auth依赖项并尝试创建一个用户时,我将得到一个
E/GoogleApiAvailability:意外错误代码19
我收到通知请求,允许Google服务访问日历、照相机、联系人、麦克风、电话、身体传感器、SMS和存储。
我想知道为什么会请求所有这些权限。
我读过CommonsWare的https://commonsware.com/blog/2015/06/25/hey-where-did-these-permissions-come-from.html帖子,正如他提到的,我是一个小品牌,不想吓跑潜在的用户。
在我的简单测试用例活动中,除了
firebase:firebase-auth:10.0.1
我知道游戏-服务-基础,游戏-服务-地下室,火灾基础-分析,火基-普通和火基-iid都是添加。
我唯一明确请求的权限是"android.permission.INTERNET“,我从合并的声明中了解到,还添加了以下内容:
这三件事看上去很公平。
但是,firebase-auth是否需要来自Google服务的所有其他权限?(短信、身体传感器、麦克风等)如果是的话,为什么?如果不是,为什么Google Play Services会要求他们呢?
我的依赖关系:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.1'
compile "com.google.firebase:firebase-auth:10.0.1"
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'我的顶级构建文件:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}还有我简单的测试活动。
public class MainActivity extends AppCompatActivity {
private FirebaseAuth mAuth;
private FirebaseAuth.AuthStateListener mAuthListener;
private static final String TAG = MainActivity.class.getName();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mAuth = FirebaseAuth.getInstance();
mAuth.createUserWithEmailAndPassword("example@example.ie", "1234567")
.addOnCompleteListener(MainActivity.this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Toast.makeText(MainActivity.this, "createUserWithEmail:onComplete:" + task.isSuccessful(), Toast.LENGTH_SHORT).show();
// If sign in fails, display a message to the user. If sign in succeeds
// the auth state listener will be notified and logic to handle the
// signed in user can be handled in the listener.
if (!task.isSuccessful()) {
Toast.makeText(MainActivity.this, "Authentication failed." + task.getException(),
Toast.LENGTH_LONG).show();
} else {
startActivity(new Intent(MainActivity.this, MainActivity.class));
finish();
}
}
});
mAuthListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
// User is signed in
Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid());
} else {
// User is signed out
Log.d(TAG, "onAuthStateChanged:signed_out");
}
// ...
}
};
}
@Override
public void onStart() {
super.onStart();
mAuth.addAuthStateListener(mAuthListener);
}
@Override
public void onStop() {
super.onStop();
if (mAuthListener != null) {
mAuth.removeAuthStateListener(mAuthListener);
}
}
}发布于 2017-02-09 15:01:03
我不认为这应该归咎于炮火。如果你说的是真的
com.google.firebase:firebase-auth:10.0.1是罪魁祸首--那么,当我运行使用firebase-auth的Firebase Android codelab时,我就会遇到这种情况,但我没有。
使用权限是安卓保护“用户隐私或设备正常运行”的方式。如果您的应用程序使用相机、麦克风和联系人等功能,您将被要求编写这些权限。根据targetSdkVersion,在运行时或安装时询问权限。
一个基本的Android应用程序在默认情况下没有与它相关的权限,这意味着它不能做任何会对用户体验或设备上的任何数据产生负面影响的事情。若要利用设备的受保护功能,必须在应用程序清单中包含一个或多个标记。 如果应用程序在其清单中列出了正常权限(即不会对用户隐私或设备操作造成多大风险的权限),系统将自动授予这些权限。如果应用程序在其清单中列出了危险的权限(即可能影响用户隐私或设备正常操作的权限),系统将要求用户显式授予这些权限。
对请求权限指南中的权限有更深入的解释,这有望说明为什么需要这些权限。
https://stackoverflow.com/questions/42121399
复制相似问题