28 Sept 2015

Error:failed to find Build Tools revision 23.0.0 rc2


Going crazy with this error from about a couple of hours.

The error is:

failed to find Build Tools revision 23.0.0 rc1
But I think to have all update



I could fix it by changing it to

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.0"
}
in build.gradle file

Open the SDK Manager and find the version of the Android SDK Build-tools which is installed and that you want to use. Then go to Gradle Scripts > build.gradle (Module: app). Set the buildToolsVersion to your version.
There is an easier solution. "Right click on the project > Open Module Settings. Choose the Complie Sdk Version and Build Tools Version you want to use".
Read More !

25 Sept 2015

Cannot locate factory for objects of type DefaultGradleConnector, as ConnectorServiceRegistry has been closed.

I get this error when trying to run my App on Android Studio.


Gradle 'MyApp' refresh failed.
Error:Cannot locate factory for objects of type DefaultGradleConnector, as ConnectorServiceRegistry has been closed.

Just Restarting Android Studio usually fixes this error for me.

Read More !

23 Sept 2015

Pan Card Validation in Android EditText

Sample code for PAN card number validation.
PAN card number is a unique national number issued in India for tax related purposes.

 PAN structure is as follows: AAAAA9999A: First five characters are letters, next 4 numerals, last character letter.

To validate PAN card, call this line of code :-

mEdtPanNumber.addTextChangedListener(new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                // TODO Auto-generated method stub
            }

            @Override
            public void afterTextChanged(Editable editable) {
                if (editable.length() == 10) {
                    String s = editable.toString(); // get your editext value here
                    Pattern pattern = Pattern.compile("[a-z]{5}[0-9]{4}[a-z]{1}");
                    Matcher matcher = pattern.matcher(s);
                    // Check if pattern matches
                    if (matcher.matches()) {
                    panNumber = editable.toString();
                } else {
                    Toast.makeText(DetailsActivity.this, getString(R.string.plz_enter_your_correct_pan_num), Toast.LENGTH_LONG).show();
                }
                }
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count,
                                          int after) {
                // TODO Auto-generated method stub
            }
        });

Read More !