2017-09-14 6 views
0

어제 전날이 문제를 해결하기 위해 노력했습니다. 내 앱이 GooglePlay에 연결해야 리더 보드에 액세스 할 수 있지만 GoogleApiClient.connect() 메서드를 실행하자마자 앱이 다운됩니다 (.enableAutoManage과 동일한 문제). 클라이언트가 새로운 스레드를 실행하는 것 때문에 오류를 잡을조차 수 없습니다.Google에 연결하려고하면 앱이 작동을 멈 춥니 다

GoogleApiClient gaClient; 
gaClient = new GoogleApiClient.Builder(this) 
     .addOnConnectionFailedListener(this) 
     .addApi(Games.API).addScope(Games.SCOPE_GAMES) 
     .build(); 

을 최대한 빨리 앱이 내가 주위에 try-catch 문을 넣어 경우에도 충돌 gaClient.connect()을 실행으로 다음과 같이

은 내가 GoogleApiClient를 초기화합니다. onConnectionFailed 청취자가 활성화되지 않습니다. 나는 또한 버전 시도

dependencies { 
compile fileTree(include: ['*.jar'], dir: 'libs') 
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
    exclude group: 'com.android.support', module: 'support-annotations' 
}) 
compile 'com.android.support:appcompat-v7:26.+' 
compile 'com.android.support:design:26.+' 
compile 'com.google.android.gms:play-services-games:11.0.2' 
compile 'com.google.android.gms:play-services-auth:11.0.2' 
compile 'com.google.android.gms:play-services-ads:11.0.2' 
compile 'com.android.support.constraint:constraint-layout:1.0.2' 
testCompile 'junit:junit:4.12' } 

프로젝트에 다음과 같은 종속성을 하바 : 11.0.4

스택 트레이스는 다음과 같습니다를 :

java.lang.NullPointerException: Attempt to invoke virtual method 'int com.huawei.lcagent.client.LogCollectManager.getUserType()' on a null object reference 
at com.android.server.util.ReportTools.getUserType(ReportTools.java:86) 
at com.android.server.util.ReportTools.isBetaUser(ReportTools.java:73) 
at com.android.server.util.ReportTools.report(ReportTools.java:58) 
at com.android.server.util.HwUserBehaviourRecord.appExitRecord(HwUserBehaviourRecord.java:65) 
at com.android.server.am.ActivityManagerService$UiHandler.handleMessage(ActivityManagerService.java:1523) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:150) 
at android.os.HandlerThread.run(HandlerThread.java:61) 
at com.android.server.ServiceThread.run(ServiceThread.java:46) 

스택 트레이스의 나는 그것을 가지고 있다고 생각하기 때문에 내 전화기와 관련이 있지만, 불행히도 다른 사람이나 에뮬레이터에 대한 액세스 권한이 없습니다. 이 문제를 해결할 수없는 경우 해결 방법이 있습니까?

사용자가 선택할 계정을 선택하도록하는 기능이 누락되어 이미 connect() 메서드에 통합되어 있습니까?

나는 이미 비슷한 질문이 있다는 것을 알고 있지만 그 답 중 어느 것도 나를 위해 일하지 못했습니다.

미리 감사드립니다.

답변

0

GoogleApiClient을 빌드 할 때 ConnectionCallback도 추가해야합니다.

초기화에 추가하십시오.

GoogleApiClient gaClient; 
gaClient = new GoogleApiClient.Builder(this) 
    .addOnConnectionFailedListener(this) 
    .addConnectionCallbacks(this) // with this you will have to implement another method onConnected and then .connect method will work fine. 
    .addApi(Games.API).addScope(Games.SCOPE_GAMES) 
    .build(); 
+0

감사하지만 (나는 forgott 그 언급, 나는이 한 번 구현 한 생각) 방법 중 어느 것도 호출되지 않으며, 하나가 작동하지 않습니다 – Regedit

+0

나는 스택 트레이스를보고 그 오류가'라인에 관찰 LogCollectManager.getUserType()'이 코드를 게시 해주세요 .. –

+0

문제는, 내가 그 메소드를 호출하거나'LogCollectManager'를 사용하지 않는다는 것입니다.이 라인은'connect()'메소드를 실행 한 후 GoogleApiClient에 의해 호출됩니다. – Regedit