Android studio "Invalid API Key error" keeps showing up when I run my project/

Viewed 174

I have a file with an API key inside of it yet I keep getting this error. I can't think of any reason why I would get an invalid API key error when I know everything is named correctly and I have an API key. This is the code inside of my mainactivity.java file. I think there might be an issue with the way that I set up the image button but I'm not exactly sure and am very confused. Any help would be greatly appreciated.

This is the actual error I keep getting when I click a button on the emulator running the app.

public class MainActivity extends AppCompatActivity {
    private RequestContext requestContext;

    ImageButton loginButton;

    @Override
    protected void onResume() {
        super.onResume();
        requestContext.onResume();
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        /* Previous onCreate declarations omitted */

        // Find the button with the login_with_amazon ID
        // and set up a click handler
        //loginButton = findViewById(R.id.login_with_amazon);
        loginButton = (ImageButton) findViewById(R.id.login_with_amazon);
        loginButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //Toast.makeText(MainActivity.this, "it works", Toast.LENGTH_LONG).show();

                AuthorizationManager.authorize(new AuthorizeRequest
                        .Builder(requestContext)
                        .addScopes(ProfileScope.profile(), ProfileScope.postalCode())
                        .build());

            }
        });


        requestContext = RequestContext.create(this);
        requestContext.registerListener(new AuthorizeListener() {


            /* Authorization was completed successfully. */
            @Override
            public void onSuccess(AuthorizeResult result) {
                /* Your app is now authorized for the requested scopes */
            }

            /* There was an error during the attempt to authorize the
            application. */
            @Override
            public void onError(AuthError ae) {
                /* Inform the user of the error */
            }

            /* Authorization was cancelled before it could be completed. */
            @Override
            public void onCancel(AuthCancellation cancellation) {
                /* Reset the UI to a ready-to-login state */
            }

        });
    }
}
0 Answers
Related