2014-09-13 268 views
0

我在我的應用程序中添加了一些代碼來搜索Google Plus上的用戶。沒有Proguard,這個代碼運行良好。運行proguard以混淆代碼後,我的應用在搜索google plus上的用戶時崩潰。Android應用程序在proguard混淆後崩潰(Google plus people search)

09-14 10:21:51.346: E/AndroidRuntime(12527): FATAL EXCEPTION: AsyncTask #4 
09-14 10:21:51.346: E/AndroidRuntime(12527): Process: com.mapegames.sudokukings, PID: 12527 
java.lang.RuntimeException: An error occured while executing doInBackground() 
    at android.os.AsyncTask$3.done(AsyncTask.java:300) 
    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) 
    at java.util.concurrent.FutureTask.setException(FutureTask.java:222) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:242) 
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
    at java.lang.Thread.run(Thread.java:864) 
Caused by: java.lang.NullPointerException 
    at com.google.api.client.util.Types.getActualParameterAtPosition(SourceFile:327) 
    at com.google.api.client.util.Types.getIterableParameter(SourceFile:307) 
    at com.google.api.client.http.HttpHeaders.parseHeader(SourceFile:1158) 
    at com.google.api.client.http.HttpHeaders.fromHttpResponse(SourceFile:989) 
    at com.google.api.client.http.HttpResponse.<init>(SourceFile:148) 
    at com.google.api.client.http.HttpRequest.execute(SourceFile:969) 
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(SourceFile:410) 
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(SourceFile:343) 
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(SourceFile:460) 
    at com.mapegames.sudokukings.PlayersActivity$getPeople.doInBackground(SourceFile:904) 
    at com.mapegames.sudokukings.PlayersActivity$getPeople.doInBackground(SourceFile:1) 
at android.os.AsyncTask$2.call(AsyncTask.java:288) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:237) 

... 4 more 

我試圖保持的類,在其中都涉及到google.api.sevices.plus ProGuard的配置文件,但這不起作用。

-keep class com.mapegames.sudokukings.** { *; } 
-keep class com.google.api.client.** { *; } 
-keep class com.google.api.services.plus.** { *; } 
-keep class com.google.api.services.plus.model.** { *; } 
-keep class java.lang.** { *; } 
-keep class android.os.** { *; } 

看起來錯誤發生在下面的代碼中的以下執行「src [0] .execute()」。

import com.google.api.services.plus.Plus; 
import com.google.api.services.plus.model.PeopleFeed; 

private Plus.People.Search searchPeople; 

private void searchPeople(String name) throws IOException { 
    searchPeople = plusSvc.people().search(name); 
    searchPeople.setMaxResults(5L); 
    status.setText(getString(R.string.searching) + " 10%"); 
    Log.i(TAG, "searchPeople: " + searchPeople); 

    new getPeople().execute(searchPeople); 
} 

private class getPeople extends AsyncTask<Plus.People.Search, Void, PeopleFeed> { 

    public PeopleFeed doInBackground(Plus.People.Search... src) { 
     Log.i(TAG, "Start PeopleSearch"); 
     try { 
      Log.i(TAG, "Try PeopleSearch: " + src[0]); 
      return src[0].execute(); 
     } catch (IOException e) { 
      Log.i(TAG, "Catch PeopleSearch"); 
      e.printStackTrace(); 
      return null; 
     } 
    } 

    protected void onPostExecute(PeopleFeed feed) { 
     Log.i(TAG, "Set PeopleSearch"); 
     setPeople(feed); 
    } 
} 

我的日誌文件的最後幾行顯示錯誤發生在「src [0] .execute()」。上述

09-13 13:17:14.170: I/PL(2881): searchPeople: {b=yhb, f=5, key=AIzaSyAfaXmYlCopeZuV-Rk5rdwGOBP3Pdkp24o} 
09-13 13:17:14.170: I/PL(2881): Start PeopleSearch 
09-13 13:17:14.170: I/PL(2881): Try PeopleSearch: {b=yhb, f=5, key=AIzaSyAfaXmYlCopeZuV-Rk5rdwGOBP3Pdkp24o} 

林不知道這個信息是足夠足夠了,所以請讓當需要更多的信息我知道。

回答

1

你可以嘗試:

-keep class com.google.api.services.plus.** { *; } 

您還可以檢查什麼得到通過看the proguard output files.
編輯帶走 - 你的問題可能是類似以下:

這些適用於Drive,但是NPE的位置相似,並且它們提供了可以從頭開始的工作proguard配置。

+0

謝謝你的回答,但不幸的是它沒有奏效。我確實看過proguard輸出,但我不確定在哪裏尋找。我在seeds.txt中注意到com.google.api.services.plus類未被混淆。你能告訴我我要去哪裏找嗎? – Mape 2014-09-13 17:29:11

+0

那麼,如果谷歌加包沒有被混淆,你現在應該有一個更清晰的堆棧跟蹤 - 你可以發佈? – sfThomas 2014-09-13 17:31:05

+0

是的,我改變了上面的堆棧跟蹤。我在proguard配置文件中添加了一些類。 – Mape 2014-09-14 08:38:08

相關問題