2016-08-04 7 views
-1

私は次のようにアカウントピッカーを実装しようとしています:Androidのインポートインポートcom.google.android.gms.common.AccountPickerエラー

Intent intent = AccountPicker.newChooseAccountIntent(null, null, new String[]{"com.google"}, false, null, null, null, null); 

startActivityForResult(intent, 1111); 

が、私は輸入にと のアンドロイド一部でエラーが出ますimport com.google。 android .gms.common.AccountPicker

どうすればこの問題を解決できますか?私は

dependencies { 
compile fileTree(dir: 'libs', include: ['*.jar']) 
testCompile 'junit:junit:4.12' 
compile 'com.android.support:appcompat-v7:23.4.0' 
compile 'com.android.support:design:23.0.1' 

}

を持って、ビルドのGradleで

ここは記事と同じですか?

Exception java.lang.NoClassDefFoundError: com.google.android.gms.common.AccountPicker

答えて

4

あなたのbuild.gradleGooglePlayServiceを追加してsetupステップを逃しました。アプリケーション・モジュールのディレクトリ内のあなたのbuild.gradleファイルで

、プレイサービスの最新バージョンの依存関係の下に新しいビルドルールを追加します。あなただけのAccountPickerが必要な場合

compile 'com.google.android.gms:play-services:9.4.0' 

1 - あなたは行の上置き換えることができます。

compile 'com.google.android.gms:play-services-base:9.4.0' 

だから、完全グラムをコンパイルする必要はありません、あなたはプロ65,536メソッドに直面していません傷み。

2ピッキングアカウントのGoogle Playサービスを追加する必要はありません。 AccountManagerクラスで利用可能なnewChoosAccountIntent()メソッドを使用してください。