googleads-adsense-examples icon indicating copy to clipboard operation
googleads-adsense-examples copied to clipboard

Adsense Quickstart App crashing on start

Open positivelymade opened this issue 9 years ago • 1 comments

Solved the error that occurred when the app starts. App starts, then onCreate is called, then onNavigationItemSelected(..) is called, then refreshView() is called because at this point publisherAccountId is null, which then calls apiController.loadAccounts() which has an invalid credential name because no account name was ever set.

The app was trying to loadaccounts from null user.

Change in MainActivity:

  • if ((apiController.getAccounts() == null) || (publisherAccountId == null)) {
  •  status = AppStatus.GETTING_ACCOUNT_ID;
    
  •  refreshView();
    
  •  return true;
    

To:

  • if ((apiController.getAccounts() == null) && (publisherAccountId == null)) {
  •    chooseDeviceAccount();
    
  •    return true;
    
  • } else if ((apiController.getAccounts() == null) || (publisherAccountId == null)) {
  •    status = AppStatus.GETTING_ACCOUNT_ID;
    
  •    refreshView();
    
  •    return true;
    
    }

positivelymade avatar Jul 20 '15 10:07 positivelymade