2013-05-31 46 views
2

我正在開發Android應用程序,並且遇到了一些問題。我創建了一個連接Android應用的應用引擎。後端部署完畢後,我將身份驗證添加到端點。代碼編譯時沒有任何錯誤,並在我的設備上啓動,但當按下按鈕進行註冊時,強制關閉。我檢查logcat的,它說:Android部隊關閉:無法找到新的選擇帳戶目標

找不到方法 com.Google.api.client.googleapis.extensions.android.GMs.auth.GoogleAccountCredential.newChooseAccountIntent, 通過RegistrationActivity.chooseAccount

引用

我能做些什麼來解決這個問題?

PromoterRegistrationActivity

package com.theincrowd; 


import java.io.IOException; 

import com.google.api.client.extensions.android.http.AndroidHttp; 
import com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential; 
import com.google.api.client.json.gson.GsonFactory; 
import com.theincrowd.promoterendpoint.Promoterendpoint; 
import com.theincrowd.promoterendpoint.model.Promoter; 

import android.os.AsyncTask; 
import android.os.Bundle; 
import android.accounts.AccountManager; 
import android.app.Activity; 
import android.content.Intent; 
import android.content.SharedPreferences; 
import android.view.Menu; 
import android.view.View; 
import android.widget.Button; 
import android.widget.EditText; 

public class PromoterRegistrationActivity extends Activity { 

static final String PREF_ACCOUNT_NAME = "accountName"; 
static final int REQUEST_ACCOUNT_PICKER = 1; 
static final String PREF_AUTH_TOKEN = "authToken"; 

//credentials 
GoogleAccountCredential credential; 

//Shared Preferences and preferred user 
SharedPreferences settings; 
String accountName; 

boolean signedIn = false; 

Promoterendpoint service; 

//text fields and button stuff 
EditText fn = (EditText) findViewById(R.id.firstName); 
EditText ln = (EditText) findViewById(R.id.lastName); 
EditText org = (EditText) findViewById(R.id.editText1); 
EditText email = (EditText) findViewById(R.id.editText2); 
Button regBut = (Button) findViewById(R.id.regButton); 

private String firstName = fn.getText().toString(); 
private String lastName = ln.getText().toString(); 
private String organization = org.getText().toString(); 
private String emailAddress = email.getText().toString(); 



//this method gets data from the text fields and populates an instance of the Promoter model 
protected void CreateNewPromoter(){ 
    Promoter nuPromoter = new Promoter(); 
    nuPromoter.setFirstName(firstName); 
    nuPromoter.setLastName(lastName); 
    nuPromoter.setOrganization(organization); 
    nuPromoter.setEmail(emailAddress); 
    new CreateNewPromoterTask().execute(nuPromoter); 

} 

//class writes new promoters to the datastore 
private class CreateNewPromoterTask extends AsyncTask<Promoter, Void, Void>{ 
    // 
    protected Void doInBackground(Promoter... nuPromoters){ 
     try{ 
      service.insertPromoter(nuPromoters[0]).execute(); 
     }catch (IOException e){ 
      e.printStackTrace(); 
     } 
     return null; 
    } 

} 

//Include methods for setSelectedAccountName and the account picker 
public void signedIn(View v){ 
    if(!this.signedIn){ 
     chooseAccount(); 
    }else { 
     forgetAccount(); 
    } 
} 
//account picker. here lies my problem... 
private void chooseAccount() { 
    startActivityForResult(credential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER); 
} 

private void setAccountName(String accountName) { 
    SharedPreferences.Editor editor = settings.edit(); 
    editor.putString(PREF_ACCOUNT_NAME, accountName); 
    editor.commit(); 
    credential.setSelectedAccountName(accountName); 
    this.accountName = accountName; 
    } 

private void onSignedIn() { 
    // TODO Auto-generated method stub 
    this.signedIn = true; 

} 

private void forgetAccount() { 
    this.signedIn = false; 
    SharedPreferences.Editor editor2 = settings.edit(); 
    editor2.remove(PREF_AUTH_TOKEN); 
    editor2.commit(); 
    } 
//end of account selection stuff 

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

    credential = GoogleAccountCredential.usingAudience(this, "server:client_id:694163602530-ims6avatrar9aagbhg6gu7ke0p7458pa.apps.googleusercontent.com"); 
    setAccountName(settings.getString(PREF_ACCOUNT_NAME, null)); 

    Promoterendpoint.Builder builder = new Promoterendpoint.Builder(AndroidHttp.newCompatibleTransport(), new GsonFactory(), credential); 
    service = builder.build(); 

    if (credential.getSelectedAccountName() != null){ 
     onSignedIn(); 
    } 

    //Place button here 


    regBut.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View regBut) { 
      // TODO Auto-generated method stub 
      CreateNewPromoter(); 

     } 

    }); 



} 
@Override 
protected void onActivityResult(int requestCode, int resultCode, Intent data){ 
    super.onActivityResult(requestCode, resultCode, data); 
    switch (requestCode) { 
    case REQUEST_ACCOUNT_PICKER: 
     if (data != null && data.getExtras() != null) { 
      String accountName =   data.getExtras().getString(AccountManager.KEY_ACCOUNT_NAME); 
      if (accountName != null) { 
       setAccountName(accountName); 
       SharedPreferences.Editor editor = settings.edit(); 
       editor.putString(PREF_ACCOUNT_NAME, accountName); 
       editor.commit(); 
       onSignedIn(); 
      } 
     } 
    } 
} 


} 

的logcat:

05-31 13:28:20.860: D/dalvikvm(12545): GC_FOR_ALLOC freed 69K, 2% free 8886K/8984K, paused 45ms, total 51ms 
05-31 13:28:20.883: I/dalvikvm-heap(12545): Grow heap (frag case) to 12.217MB for 3686416-byte allocation 
05-31 13:28:20.915: D/dalvikvm(12545): GC_FOR_ALLOC freed <1K, 1% free 12485K/12588K, paused 32ms, total 32ms 
05-31 13:28:20.954: D/dalvikvm(12545): GC_CONCURRENT freed <1K, 1% free 12485K/12588K, paused 12ms+1ms, total 41ms 
05-31 13:28:21.821: D/libEGL(12545): loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so 
05-31 13:28:22.094: D/libEGL(12545): loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so 
05-31 13:28:22.118: D/libEGL(12545): loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so 
05-31 13:28:22.250: D/OpenGLRenderer(12545): Enabling debug mode 0 
05-31 13:28:27.688: I/dalvikvm(12545): Could not find method com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.newChooseAccountIntent, referenced from method com.theincrowd.PromoterRegistrationActivity.chooseAccount 
05-31 13:28:27.696: W/dalvikvm(12545): VFY: unable to resolve virtual method 47: Lcom/google/api/client/googleapis/extensions/android/gms/auth/GoogleAccountCredential;.newChooseAccountIntent()Landroid/content/Intent; 
05-31 13:28:27.696: D/dalvikvm(12545): VFY: replacing opcode 0x6e at 0x0002 
05-31 13:28:27.696: I/dalvikvm(12545): Could not find method com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.setSelectedAccountName, referenced from method com.theincrowd.PromoterRegistrationActivity.setAccountName 
05-31 13:28:27.696: W/dalvikvm(12545): VFY: unable to resolve virtual method 48: Lcom/google/api/client/googleapis/extensions/android/gms/auth/GoogleAccountCredential;.setSelectedAccountName (Ljava/lang/String;)Lcom/google/api/client/googleapis/extensions/android/gms/auth/GoogleAccountCredential; 
05-31 13:28:27.696: D/dalvikvm(12545): VFY: replacing opcode 0x6e at 0x0010 
05-31 13:28:27.696: W/dalvikvm(12545): Unable to resolve superclass of Lcom/theincrowd/promoterendpoint/model/Promoter; (53) 
05-31 13:28:27.696: W/dalvikvm(12545): Link of class 'Lcom/theincrowd/promoterendpoint/model/Promoter;' failed 
05-31 13:28:27.696: E/dalvikvm(12545): Could not find class 'com.theincrowd.promoterendpoint.model.Promoter', referenced from method com.theincrowd.PromoterRegistrationActivity.CreateNewPromoter 
05-31 13:28:27.696: W/dalvikvm(12545): VFY: unable to resolve new-instance 189 (Lcom/theincrowd/promoterendpoint/model/Promoter;) in Lcom/theincrowd/PromoterRegistrationActivity; 
05-31 13:28:27.696: D/dalvikvm(12545): VFY: replacing opcode 0x22 at 0x0000 
05-31 13:28:27.696: I/dalvikvm(12545): Could not find method com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.usingAudience, referenced from method com.theincrowd.PromoterRegistrationActivity.onCreate 
05-31 13:28:27.696: W/dalvikvm(12545): VFY: unable to resolve static method 49: Lcom/google/api/client/googleapis/extensions/android/gms/auth/GoogleAccountCredential;.usingAudience (Landroid/content/Context;Ljava/lang/String;)Lcom/google/api/client/googleapis/extensions/android/gms/auth/GoogleAccountCredential; 
05-31 13:28:27.696: D/dalvikvm(12545): VFY: replacing opcode 0x71 at 0x000b 
05-31 13:28:27.696: W/dalvikvm(12545): Unable to resolve superclass of Lcom/theincrowd/promoterendpoint/model/Promoter; (53) 
05-31 13:28:27.696: W/dalvikvm(12545): Link of class 'Lcom/theincrowd/promoterendpoint/model/Promoter;' failed 
05-31 13:28:27.696: D/dalvikvm(12545): DexOpt: unable to opt direct call 0x0695 at 0x02 in Lcom/theincrowd/PromoterRegistrationActivity;.CreateNewPromoter 
05-31 13:28:27.696: D/dalvikvm(12545): DexOpt: unable to opt direct call 0x004e at 0x25 in Lcom/theincrowd/PromoterRegistrationActivity;.onCreate 
05-31 13:28:27.696: W/dalvikvm(12545): Unable to resolve superclass of Lcom/theincrowd/promoterendpoint/Promoterendpoint$Builder; (44) 
05-31 13:28:27.696: W/dalvikvm(12545): Link of class 'Lcom/theincrowd/promoterendpoint/Promoterendpoint$Builder;' failed 
05-31 13:28:27.704: D/dalvikvm(12545): DexOpt: unable to opt direct call 0x0599 at 0x2a in Lcom/theincrowd/PromoterRegistrationActivity;.onCreate 
05-31 13:28:27.704: D/AndroidRuntime(12545): Shutting down VM 
05-31 13:28:27.704: W/dalvikvm(12545): threadid=1: thread exiting with uncaught exception (group=0x416bd930) 
05-31 13:28:27.766: E/AndroidRuntime(12545): FATAL EXCEPTION: main 
05-31 13:28:27.766: E/AndroidRuntime(12545): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.theincrowd/com.theincrowd.PromoterRegistrationActivity}: java.lang.NullPointerException 
05-31 13:28:27.766: E/AndroidRuntime(12545): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106) 
05-31 13:28:27.766: E/AndroidRuntime(12545): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 
05-31 13:28:27.766: E/AndroidRuntime(12545): at android.app.ActivityThread.access$600(ActivityThread.java:141) 
05-31 13:28:27.766: E/AndroidRuntime(12545): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 
05-31 13:28:27.766: E/AndroidRuntime(12545): at android.os.Handler.dispatchMessage(Handler.java:99) 
05-31 13:28:27.766: E/AndroidRuntime(12545): at android.os.Looper.loop(Looper.java:137) 
05-31 13:28:27.766: E/AndroidRuntime(12545): at android.app.ActivityThread.main(ActivityThread.java:5039) 
05-31 13:28:27.766: E/AndroidRuntime(12545): at java.lang.reflect.Method.invokeNative(Native Method) 
05-31 13:28:27.766: E/AndroidRuntime(12545): at java.lang.reflect.Method.invoke(Method.java:511) 
05-31 13:28:27.766: E/AndroidRuntime(12545): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
05-31 13:28:27.766: E/AndroidRuntime(12545): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
05-31 13:28:27.766: E/AndroidRuntime(12545): at dalvik.system.NativeStart.main(Native Method) 
05-31 13:28:27.766: E/AndroidRuntime(12545): Caused by: java.lang.NullPointerException 
05-31 13:28:27.766: E/AndroidRuntime(12545): at android.app.Activity.findViewById(Activity.java:1839) 
05-31 13:28:27.766: E/AndroidRuntime(12545): at com.theincrowd.PromoterRegistrationActivity.<init>(PromoterRegistrationActivity.java:41) 
05-31 13:28:27.766: E/AndroidRuntime(12545): at java.lang.Class.newInstanceImpl(Native Method) 
05-31 13:28:27.766: E/AndroidRuntime(12545): at java.lang.Class.newInstance(Class.java:1319) 
05-31 13:28:27.766: E/AndroidRuntime(12545): at android.app.Instrumentation.newActivity(Instrumentation.java:1054) 
05-31 13:28:27.766: E/AndroidRuntime(12545): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097) 
05-31 13:28:27.766: E/AndroidRuntime(12545): ... 11 more 
05-31 13:36:11.032: I/dalvikvm(13422): Could not find method com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.newChooseAccountIntent, referenced from method com.theincrowd.PromoterRegistrationActivity.chooseAccount 
05-31 13:36:11.032: W/dalvikvm(13422): VFY: unable to resolve virtual method 47: Lcom/google/api/client/googleapis/extensions/android/gms/auth/GoogleAccountCredential;.newChooseAccountIntent()Landroid/content/Intent; 
05-31 13:36:11.032: D/dalvikvm(13422): VFY: replacing opcode 0x6e at 0x0002 
05-31 13:36:11.032: I/dalvikvm(13422): Could not find method com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.setSelectedAccountName, referenced from method com.theincrowd.PromoterRegistrationActivity.setAccountName 
05-31 13:36:11.032: W/dalvikvm(13422): VFY: unable to resolve virtual method 48: Lcom/google/api/client/googleapis/extensions/android/gms/auth/GoogleAccountCredential;.setSelectedAccountName (Ljava/lang/String;)Lcom/google/api/client/googleapis/extensions/android/gms/auth/GoogleAccountCredential; 
05-31 13:36:11.032: D/dalvikvm(13422): VFY: replacing opcode 0x6e at 0x0010 
05-31 13:36:11.040: W/dalvikvm(13422): Unable to resolve superclass of Lcom/theincrowd/promoterendpoint/model/Promoter; (53) 
05-31 13:36:11.040: W/dalvikvm(13422): Link of class 'Lcom/theincrowd/promoterendpoint/model/Promoter;' failed 
05-31 13:36:11.040: E/dalvikvm(13422): Could not find class 'com.theincrowd.promoterendpoint.model.Promoter', referenced from method com.theincrowd.PromoterRegistrationActivity.CreateNewPromoter 
05-31 13:36:11.040: W/dalvikvm(13422): VFY: unable to resolve new-instance 189 (Lcom/theincrowd/promoterendpoint/model/Promoter;) in Lcom/theincrowd/PromoterRegistrationActivity; 
05-31 13:36:11.040: D/dalvikvm(13422): VFY: replacing opcode 0x22 at 0x0000 
05-31 13:36:11.040: I/dalvikvm(13422): Could not find method com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.usingAudience, referenced from method com.theincrowd.PromoterRegistrationActivity.onCreate 
05-31 13:36:11.040: W/dalvikvm(13422): VFY: unable to resolve static method 49: Lcom/google/api/client/googleapis/extensions/android/gms/auth/GoogleAccountCredential;.usingAudience (Landroid/content/Context;Ljava/lang/String;)Lcom/google/api/client/googleapis/extensions/android/gms/auth/GoogleAccountCredential; 
05-31 13:36:11.040: D/dalvikvm(13422): VFY: replacing opcode 0x71 at 0x000b 
05-31 13:36:11.040: W/dalvikvm(13422): Unable to resolve superclass of Lcom/theincrowd/promoterendpoint/model/Promoter; (53) 
05-31 13:36:11.040: W/dalvikvm(13422): Link of class 'Lcom/theincrowd/promoterendpoint/model/Promoter;' failed 
05-31 13:36:11.040: D/dalvikvm(13422): DexOpt: unable to opt direct call 0x0695 at 0x02 in Lcom/theincrowd/PromoterRegistrationActivity;.CreateNewPromoter 
05-31 13:36:11.047: D/dalvikvm(13422): DexOpt: unable to opt direct call 0x004e at 0x25 in Lcom/theincrowd/PromoterRegistrationActivity;.onCreate 
05-31 13:36:11.047: W/dalvikvm(13422): Unable to resolve superclass of Lcom/theincrowd/promoterendpoint/Promoterendpoint$Builder; (44) 
05-31 13:36:11.047: W/dalvikvm(13422): Link of class 'Lcom/theincrowd/promoterendpoint/Promoterendpoint$Builder;' failed 
05-31 13:36:11.047: D/dalvikvm(13422): DexOpt: unable to opt direct call 0x0599 at 0x2a in Lcom/theincrowd/PromoterRegistrationActivity;.onCreate 
05-31 13:36:11.047: D/AndroidRuntime(13422): Shutting down VM 
05-31 13:36:11.047: W/dalvikvm(13422): threadid=1: thread exiting with uncaught exception (group=0x416bd930) 
05-31 13:36:11.063: E/AndroidRuntime(13422): FATAL EXCEPTION: main 
05-31 13:36:11.063: E/AndroidRuntime(13422): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.theincrowd/com.theincrowd.PromoterRegistrationActivity}: java.lang.NullPointerException 
05-31 13:36:11.063: E/AndroidRuntime(13422): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106) 
05-31 13:36:11.063: E/AndroidRuntime(13422): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 
05-31 13:36:11.063: E/AndroidRuntime(13422): at android.app.ActivityThread.access$600(ActivityThread.java:141) 
05-31 13:36:11.063: E/AndroidRuntime(13422): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 
05-31 13:36:11.063: E/AndroidRuntime(13422): at android.os.Handler.dispatchMessage(Handler.java:99) 
05-31 13:36:11.063: E/AndroidRuntime(13422): at android.os.Looper.loop(Looper.java:137) 
05-31 13:36:11.063: E/AndroidRuntime(13422): at android.app.ActivityThread.main(ActivityThread.java:5039) 
05-31 13:36:11.063: E/AndroidRuntime(13422): at java.lang.reflect.Method.invokeNative(Native Method) 
05-31 13:36:11.063: E/AndroidRuntime(13422): at java.lang.reflect.Method.invoke(Method.java:511) 
05-31 13:36:11.063: E/AndroidRuntime(13422): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
05-31 13:36:11.063: E/AndroidRuntime(13422): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
05-31 13:36:11.063: E/AndroidRuntime(13422): at dalvik.system.NativeStart.main(Native Method) 
05-31 13:36:11.063: E/AndroidRuntime(13422): Caused by: java.lang.NullPointerException 
05-31 13:36:11.063: E/AndroidRuntime(13422): at android.app.Activity.findViewById(Activity.java:1839) 
05-31 13:36:11.063: E/AndroidRuntime(13422): at com.theincrowd.PromoterRegistrationActivity.<init>(PromoterRegistrationActivity.java:41) 
05-31 13:36:11.063: E/AndroidRuntime(13422): at java.lang.Class.newInstanceImpl(Native Method) 
05-31 13:36:11.063: E/AndroidRuntime(13422): at java.lang.Class.newInstance(Class.java:1319) 
05-31 13:36:11.063: E/AndroidRuntime(13422): at android.app.Instrumentation.newActivity(Instrumentation.java:1054) 
05-31 13:36:11.063: E/AndroidRuntime(13422): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097) 
05-31 13:36:11.063: E/AndroidRuntime(13422): ... 11 more 
05-31 13:36:13.407: I/Process(13422): Sending signal. PID: 13422 SIG: 9 

我希望這有助於...

編輯:添加清單文件。

<uses-sdk 
    android:minSdkVersion="11" 
    android:targetSdkVersion="17" /> 

    <permission 
    android:name="com.theincrowd.permission.C2D_MESSAGE" 
    android:protectionLevel="signature" /> 

    <uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="com.theincrowd.permission.C2D_MESSAGE" /> 
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> 
<uses-permission android:name="android.permission.WAKE_LOCK" /> 
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> 
<uses-permission android:name="android.permission.USE_CREDENTIALS" /> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.GET_ACCOUNTS"/> 
<uses-permission android:name="android.permission.USE_CREDENTIALS"/> 

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@android:style/Theme.WithActionBar" > 
    <activity 
     android:name="com.theincrowd.MainActivity" 
     android:label="@string/app_name" 
     android:theme="@android:style/Theme.NoTitleBar" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 

    <service android:name="com.theincrowd.GCMIntentService" /> 

    <receiver 
     android:name="com.google.android.gcm.GCMBroadcastReceiver" 
     android:permission="com.google.android.c2dm.permission.SEND" > 
     <intent-filter> 
      <action android:name="com.google.android.c2dm.intent.RECEIVE" /> 

      <category android:name="com.theincrowd" /> 
     </intent-filter> 
     <intent-filter> 
      <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> 

      <category android:name="com.theincrowd" /> 
     </intent-filter> 
    </receiver> 

    <activity 
     android:name="com.theincrowd.RegisterActivity" 
     android:launchMode="singleTop" /> 
    <activity 
     android:name="com.theincrowd.PromoForkActivity" 
     android:label="@string/title_activity_promo_fork" > 
    </activity> 
    <activity 
     android:name="com.theincrowd.PromoterRegistrationActivity" 
     android:label="@string/title_activity_promoter_registration" > 
    </activity> 
    <activity 
     android:name="com.theincrowd.PartyGoerDashActivity" 
     android:label="@string/title_activity_party_goer_dash" > 
    </activity> 
    <activity 
     android:name="com.theincrowd.PartyListTabs" 
     android:label="@string/title_activity_party_list_tabs" > 
    </activity> 
</application> 

+0

你會分享你的活動代碼和你的logcat嗎? –

+0

你的問題是'NullPointerException'。請參閱'無法實例化活動ComponentInfo'行。也包括你的'AndroidManifest.xml'。 對於您提到的問題,我認爲您應該使用'import com.google.android.gms.common.AccountPicker;'並確保您已將Google Play服務導入到您的項目中。 –

+0

感謝您的幫助。我添加了AccountPicker導入,並且我已經將google play服務項目導入到項目樹中並對其進行了引用。我是否需要將其導入到活動中? – kreshendo

回答

0

所有這些線路必須在onCreate方法:

提示有人已經告訴你在哪裏把按鈕。請參閱代碼中的//Place button here

protected void onCreate(Bundle savedInstanceState) { 

    ... 

    //text fields and button stuff [FROM HERE] 
    EditText fn = (EditText) findViewById(R.id.firstName); 
    EditText ln = (EditText) findViewById(R.id.lastName); 
    EditText org = (EditText) findViewById(R.id.editText1); 
    EditText email = (EditText) findViewById(R.id.editText2); 
    Button regBut = (Button) findViewById(R.id.regButton); 

對於下面的線,你可能只是離開的聲明是這樣的:

private String firstName; 
private String lastName; 
private String organization; 
private String emailAddress; 

隨後又在onCreate,你投你的意見EditText後,你可以閱讀他們的價值觀是這樣的:

firstName = fn.getText().toString(); 
lastName = ln.getText().toString(); 
organization = org.getText().toString(); 
emailAddress = email.getText().toString(); 
+0

我已經移動了代碼並進行了您所建議的更改。不過,我仍然在接近力量。 – kreshendo

+0

@kreshendo,刪除'gen'文件夾。清理你的項目並重新構建。檢查logcat,看看你是否得到相同的錯誤。 –

+0

是的,它是同樣的錯誤。我認爲它與在onCreate()中調用的setAccountName()方法有關。我對NullPointerException做了一些研究,但從查看代碼,我無法確定在運行時哪個值爲空。 – kreshendo