-3

I developed an app, all of time I used real device(samsung note 5), sometimes used emulator as test device.Today I upload the app to play store. As explained in caption, when I or my friends download the app and run it, it cannot get data from internet and adview is blank. But all of developing time I didnt face this situation. I dont understand.

First photo, real device connected to computer with cable, I run app by Android Studio, apk is sent Android studio to my real device.Close and run it again, close and run it again. Result is the same. Everything is ok.

https://i.stack.imgur.com/CQgOJ.jpg

Second photo, downloaded from play store and run app. All texts and balls are empty.

https://i.stack.imgur.com/7azlc.png

Manifest.xml

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CLEAR_APP_CACHE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.android.vending.BILLING" />

Spinner Item Selected (No toast mesaage appear in running app)

private AdapterView.OnItemSelectedListener spinnerOnItemSelectedListener = new AdapterView.OnItemSelectedListener() {
    @Override
    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
        mDrawDateSpinnerPosition = position;
        final String drawDate = parent.getItemAtPosition(position).toString();

        if (NetworkUtil.getConnectivityStatus(getContext())) {
            mProgressDialog = ProgressDialog.show(getContext(), getResources().getString(R.string.please_wait), getResources().getString(R.string.loading), true, false);

            new Handler().post(new Runnable() {
                @Override
                public void run() {
                    try {
                        mVolleyUtil.makeRequestForLotto(
                                getContext(),
                                Constants.SAYISAL,
                                DateUtil.formattedDateToNewFormattedDate(drawDate, Constants.DD_MM_YYYY, Constants.YYYY_MM_DD),
                                createSuccessListener(drawDate),
                                createErrorListener(drawDate));
                    } catch (Exception e) {
                        Log.e("spinnerSelectedListener", e.getMessage());
                    }
                    mProgressDialog.dismiss();
                }
            });
        } else {
            ToastUtil.show(getContext(), R.string.no_internet_access, Toast.LENGTH_LONG);
        }
    }

    @Override
    public void onNothingSelected(AdapterView<?> parent) {

    }
};

CreateErrorListener (No toast message appears in running app)

private Response.ErrorListener createErrorListener(final String drawDate) {
    return new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            mVolleyUtil.getVolleyController().cancelPendingRequests(this);
            mResult = null;
            mProgressDialog.dismiss();
            if (!NetworkUtil.getConnectivityStatus(getContext())) {
                ToastUtil.show(getContext(), R.string.no_internet_access, Toast.LENGTH_LONG);
            } else {
                ToastUtil.show(getContext(), "Error occured, try again.", Toast.LENGTH_LONG);
            }
        }
    };
}

VolleyRequest

mVolleyController.getRequestQueue().add(
                    new GsonRequest<>(Request.Method.GET, link + drawDate + ".json",
                            createErrorListener, LottoDTO.class, createSuccessListener));

Please give me an idea. What is happenning?

hebset
  • 13
  • 1
  • 8
  • Have you tried installing the signed APK (the one you are uploading to Google Play) directly on the device? – timbillstrom Jan 16 '17 at 14:03
  • @timbillstrom I tried now when you said that, it is the same result like second photo. All texts and balls are empty, adview is blank. – hebset Jan 16 '17 at 14:08
  • I found the error. Actually not real error. In the GsonRequest, link is like this: h_t_t_p_:_/_/_w_w_w.... (forget about underscore) If signed APK runs on device, this link not send the data, if normal APK runs on device, this link is sending data successfully. Is it a certification problem? – hebset Jan 16 '17 at 15:18

1 Answers1

0

I found solution to my own question. ıf minified is enabled, you must use @serializedname in pojo(model) class. Like this:

public class LottoDTO implements Serializable {
@SerializedName("success")
private boolean success;

public boolean isSuccess() {
    return success;
}

public void setSuccess(boolean success) {
    this.success = success;
}
}

So GSON knows how to match data between pojo and JSON object.

Solution from : https://stackoverflow.com/a/30002203/3605998

Now, everything is OK. Thanks.

Community
  • 1
  • 1
hebset
  • 13
  • 1
  • 8