Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Google Play服务登录错误_Android_Google Play Services - Fatal编程技术网

Android Google Play服务登录错误

Android Google Play服务登录错误,android,google-play-services,Android,Google Play Services,我正在尝试使用Google Play服务。为了尝试这项服务,我创建了一个应用程序,其中只有一个活动具有登录代码。我在Google Play控制台上添加了库并创建了我的应用程序。获取我的Id并将其添加到我的清单中 但当我尝试测试我的应用程序时,我在logcat上得到了以下信息: 09-11 16:55:30.500 2387-5329/? E/DatabaseUtils﹕ Writing exception to parcel java.lang.SecurityException:

我正在尝试使用Google Play服务。为了尝试这项服务,我创建了一个应用程序,其中只有一个活动具有登录代码。我在Google Play控制台上添加了库并创建了我的应用程序。获取我的Id并将其添加到我的清单中

但当我尝试测试我的应用程序时,我在logcat上得到了以下信息:

09-11 16:55:30.500    2387-5329/? E/DatabaseUtils﹕ Writing exception to parcel
    java.lang.SecurityException: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
            at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:13140)
            at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:2038)
            at com.android.providers.settings.SettingsProvider.callFromPackage(SettingsProvider.java:607)
            at android.content.ContentProvider$Transport.call(ContentProvider.java:279)
            at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:273)
            at android.os.Binder.execTransact(Binder.java:388)
            at dalvik.system.NativeStart.run(Native Method)
我所做的事情:

舱单:

 <meta-data android:name="com.google.android.gms.games.APP_ID"
        android:value="@string/app_id"/>
 <meta-data android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
注意:我使用的是4.4.52版,因为我的设备上没有更新最新版本,它给出了“除非更新google play服务,否则此应用程序将无法工作”之类的信息。所以我在sdk中降级了我的库

类别:

public class MyActivity extends BaseGameActivity implements View.OnClickListener {

    Button signOutBut;
    View signInBut;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_my);

        signOutBut = (Button) findViewById(R.id.sign_out_button);
        setContentView(R.layout.activity_my);

        signOutBut.setOnClickListener(this);
        findViewById(R.id.sign_in_button).setOnClickListener(this);

        checkIfOk();
    }

    private boolean checkIfOk() {
        int checkGooglePlayServices = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
        if (checkGooglePlayServices != ConnectionResult.SUCCESS) {
            GooglePlayServicesUtil.getErrorDialog(checkGooglePlayServices, this, 1122).show();
            return false;
        } else {
            return true;
        }
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.my, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public void onClick(View v) {
        if(v.getId() == R.id.sign_in_button){
            beginUserInitiatedSignIn();

        }else {
            signOut();
            signOutBut.setVisibility(View.GONE);
            findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
        }  
    }

    @Override
    public void onSignInFailed() {
        Toast.makeText(getApplicationContext(), "ss", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onSignInSucceeded() {
        signOutBut.setVisibility(View.VISIBLE);
        findViewById(R.id.sign_in_button).setVisibility(View.GONE);

    }
}

这个错误的原因可能是什么?

也许这个答案会有帮助:我想它可能会谢谢你,我会试试看(:
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:20.0.0'
    compile 'com.google.android.gms:play-services:4.4.52'
    compile project(':libraries:BaseGameUtils')
}
public class MyActivity extends BaseGameActivity implements View.OnClickListener {

    Button signOutBut;
    View signInBut;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_my);

        signOutBut = (Button) findViewById(R.id.sign_out_button);
        setContentView(R.layout.activity_my);

        signOutBut.setOnClickListener(this);
        findViewById(R.id.sign_in_button).setOnClickListener(this);

        checkIfOk();
    }

    private boolean checkIfOk() {
        int checkGooglePlayServices = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
        if (checkGooglePlayServices != ConnectionResult.SUCCESS) {
            GooglePlayServicesUtil.getErrorDialog(checkGooglePlayServices, this, 1122).show();
            return false;
        } else {
            return true;
        }
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.my, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public void onClick(View v) {
        if(v.getId() == R.id.sign_in_button){
            beginUserInitiatedSignIn();

        }else {
            signOut();
            signOutBut.setVisibility(View.GONE);
            findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
        }  
    }

    @Override
    public void onSignInFailed() {
        Toast.makeText(getApplicationContext(), "ss", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onSignInSucceeded() {
        signOutBut.setVisibility(View.VISIBLE);
        findViewById(R.id.sign_in_button).setVisibility(View.GONE);

    }
}