应用程序在使用android-market-api时崩溃

时间:2017-01-23 10:49:52

标签: android google-play google-apps-marketplace

我正在尝试根据开发者ID列出所有Play商店应用。为此,我使用unofficial google api。根据建议,我使用androidmarketapi-0.6.jarprotobuf-java-2.2.0.jar和以下代码:

    public void doAsync(){

    AsyncTask<Void, Void, String> task = new AsyncTask<Void, Void, String>() {
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            Log.e("AsyncTask", "onPreExecute");

        }
        @Override
        protected String doInBackground(Void... params) {
            Log.v("AsyncTask", "doInBackground");

            String email = "XXXXXXXX@gmail.com";
            String pass = "XXXXX";
            String AndroidId = "dead000beef";

            MarketSession session = new MarketSession();
            session.login(email,pass);
            session.getContext().setAndroidId(AndroidId);


            String query = "maps";
            Market.AppsRequest appsRequest = Market.AppsRequest.newBuilder() .setQuery(query) .setStartIndex(0).setEntriesCount(10) .setWithExtendedInfo(true) .build();

            session.append(appsRequest, new MarketSession.Callback<Market.AppsResponse>() {
                @Override
                public void onResult(Market.ResponseContext context, Market.AppsResponse response) {
                    Log.e("Market API", "Got response");
                    Log.e("response", response + "");

                    msg = response + "";
                }
            });

            return msg;
        }
        @Override
        protected void onPostExecute(String msg) {
            Log.e("AsyncTask", "onPostExecute");
            Log.e("response", msg);

        }
    };
    if(Build.VERSION.SDK_INT >= 11)
        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    else
        task.execute();
}

但是我遇到了以下崩溃:

Logcat响应

AndroidRuntime: FATAL EXCEPTION: AsyncTask #2
                 Process: com.app.XXXXXXXX, PID: 27678
                 java.lang.RuntimeException: An error occured while executing doInBackground()
                 at android.os.AsyncTask$3.done(AsyncTask.java:304)
                 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 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:818)
                 Caused by: com.gc.android.market.api.Tools$HttpException: HTTP Code 404 : https://developers.google.com/accounts/docs/AuthForInstalledApps

任何人都可以帮助我吗?

0 个答案:

没有答案