经过Proguard混淆后,Android App崩溃(Google加人员搜索) [英] Android App crashes after proguard obfuscation (Google plus people search)

查看:237
本文介绍了经过Proguard混淆后,Android App崩溃(Google加人员搜索)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用中添加了一些代码,以搜索Google Plus上的人.如果没有Proguard,此代码将运行良好.运行proguard混淆代码后,在google plus上搜索人员时我的应用程序崩溃了.

I added some code to my app to search people on Google Plus. This code works well without Proguard. After running proguard to obfuscate the code, my app crashes when searching for people on 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的配置文件中,但这是行不通的.

I have tried to keep the classes in the proguard config-file which are related to the google.api.sevices.plus, but this doesn't work.

-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()"时发生错误.

It seems that the error occurs at the following execute "src[0].execute()" in the code below.

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()".

The last lines of my Log-file below show the error occurs at "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}

我不确定上面的信息是否足够,请在需要其他信息时告诉我.

Im not sure this information above is sufficient enough, so please let me know when additional information is required.

推荐答案

可以尝试:

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

您还可以通过查看 proguard输出文件来检查要删除的内容.
编辑-您的问题可能与以下类似:

You can also check what gets taken away by looking at the proguard output files.
EDIT - Your problem might be similar to these:

  • http://softwyer.wordpress.com/2012/10/20/android-google-drive-sdk-and-proguard/
  • Google Drive API doesn't play well with ProGuard (NPE)

这些是针对Drive的,但是NPE的位置相似,并且它们提供了可以使用的proguard配置.

These are for Drive, but the location of the NPE is similar, and they provide a working proguard config you can start with.

这篇关于经过Proguard混淆后,Android App崩溃(Google加人员搜索)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆