1

我想导出我的 Android 项目以便在 Google Play 上发布。成功导出了。

看看这些代码行:

GsonSyncPathResolverModel gsonSyncPathResolverModel = new GsonSyncPathResolverModel(new GsonBuilder());
            String TAG = "SyncPathReslover";

            HttpResponse licenceManagementResponse = Client.get(REST_URL.GETSynchURLResolver(customerID));
            int responseCode = licenceManagementResponse.getStatusLine().getStatusCode();
            String responseString = EntityUtils.toString(licenceManagementResponse.getEntity());
            Log.e(TAG, "response " + responseString);
            System.out.println(responseString);
            responseString=responseString.replace("{\"GetOrganizationInformationByOrganizationNumberResult\":\"[{","{");
            responseString=responseString.replace("}]\"}","}");
            responseString=responseString.replace('\\', Character.MIN_VALUE);
            responseString=responseString.replaceAll(""+Character.MIN_VALUE,"");

            System.out.println("#zzz "+responseString);

            if (responseCode == 200) {
                // syncPathResolver
                licenceManagementResponse.getEntity().consumeContent();
                SyncPathResolverModel syncPathResolverModel = gsonSyncPathResolverModel.parseJSON(responseString);

                Log.e(TAG, "Response from Server:  Organization ID:" + syncPathResolverModel.getObjectEntry_ID());
                Log.e(TAG, "Response from Server:  Sync Path:" + syncPathResolverModel.getSyncServiceURL());

当我直接从 Eclipse 运行项目时,最后一行代码工作正常,并打印出正确的值。

但是当我使用导出的 .apk 文件时,

Log.e(TAG, "Response from Server:  Organization ID:" + syncPathResolverModel.getObjectEntry_ID());
Log.e(TAG, "Response from Server:  Sync Path:" + syncPathResolverModel.getSyncServiceURL());

这两行打印出来null

你能帮我导出 .apk 文件有什么问题吗?

当我签署 .apk 文件时,gson.jar 库似乎不起作用

4

2 回答 2

1

导出 .apk 文件后 json.jar 文件无法正常工作的原因与启用ProGuard有关。因此,如果我禁用它或正确配置它,.jar 文件也将正常工作。

于 2013-02-13T21:04:31.073 回答
0

在 Eclipse 中打开项目属性。选择 Java Build Path,单击 Order and Export 选项卡。确保检查 gson.jar 以进行导出。

于 2013-02-13T00:26:15.617 回答