在appuard混淆之后Android应用程序崩溃(谷歌加人搜索)

时间:2014-09-13 12:55:41

标签: android google-plus proguard google-search-api

我在我的应用中添加了一些代码来搜索Google Plus上的人。这段代码在没有Proguard的情况下运行良好。在运行proguard来混淆代码后,我的应用程序在搜索google plus上的人时崩溃。

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 个答案:

答案 0 :(得分:1)

你可以尝试:

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

您还可以通过查看the proguard output files.来查看被删除的内容 编辑 - 您的问题可能类似于:

这些适用于Drive,但NPE的位置相似,它们提供了一个可以开始的工作程序配置。