-3

Since I updated my android studio to the latest version before that my application was working fine but now I cannot Sign in my application. after giving username and password login screen only being processed but not logging in.

See Image

What could be the problem, please help?

This is the medthod for uploading data .

 public void uploadGroupData() {
    CommonMethod.writeToFile(new Gson().toJson(groupSyncUpData));

    RequestParams params = new RequestParams();

    params.put("group_data", new Gson().toJson(groupSyncUpData));

    Log.e("ParamsJason : ", "" + params);

    PhpConnectivity.getClient().post(CommonConst.GROUP_TEST_URL, params, 
                                 new 
            AsyncHttpResponseHandler() {
        @Override
        public void onStart() {
            super.onStart();
            progressDialog.setTitle("Group Sync Up");
            progressDialog.setMessage("Group  Data Uploading...");
            progressDialog.setCancelable(false);
            progressDialog.show();
        }

        @Override
        public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
            String response = new String(responseBody);
            if (response.trim().equalsIgnoreCase(RESPONSE_SUCCESS)) {
                progressDialog.dismiss();
                CommonMethod.alert(SyncUpActivity.this
                        , "Group Sync Up:", "Success");
                dbHandler.updateGroupSync(groupSyncUpData.getGroup().getGroupId(), 1);
                recAdapter.getItemList().remove(groupSyncUpData.getGroup());
                recAdapter.notifyDataSetChanged();
                groupSyncUpData = null;
            } else {
                Log.e(TAG, "onFailure: " + response);
                progressDialog.dismiss();
                CommonMethod.alert(SyncUpActivity.this
                        , "Group Sync Up Failure:", "Response: " + response);
            }

        }

        @Override
        public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
            if (responseBody == null) {
                CommonMethod.alert(SyncUpActivity.this
                        , "Connectivity Error:", "Try Again!");
                progressDialog.dismiss();
                return;
            }
            String response = new String(responseBody);
            Log.e(TAG, "onFailure: " + response);
            progressDialog.dismiss();
            CommonMethod.alert(SyncUpActivity.this
                    , "Group Sync Up Failure:", "Response: " + response);

        }
    });
}

method for logging in inside login activity

 @Override
public void onClick(View view) {
    final Login login = new Login();
    if (view == loginBtn) {
        progressDialog = new ProgressDialog(LoginActivity.this);
        progressDialog.setMessage("logging in...");
        progressDialog.show();
        progressDialog.setCancelable(false);

        username = UsernameEdt.getText().toString();
        password = PasswordEdt.getText().toString();
        Log.e(TAG, "onClick: --" + username + "---" + password);

        if (CommonMethod.isNetworkAvailable2(this)) {
            OkHttpClient okHttpClient = new OkHttpClient().newBuilder()
                    .connectTimeout(45000, TimeUnit.SECONDS)
                    .readTimeout(45000, TimeUnit.SECONDS)
                    .writeTimeout(45000, TimeUnit.SECONDS)
                    .build();
            AndroidNetworking.post(CommonConst.LOGIN_URL_TEST)
                    .addBodyParameter("Username", username)
                    .addBodyParameter("Password", password)
                    .setTag("login")
                    .setPriority(Priority.MEDIUM)
                    .setOkHttpClient(okHttpClient) // passing a custom 
                    okHttpClient
                    .build()
                    .getAsJSONObject(new JSONObjectRequestListener() {
                        @Override
                        public void onResponse(JSONObject response) {

                            Log.e(TAG, "onResponse: " + response);

                            try {
                                JSONObject jsonObject = new 
                    JSONObject(String.valueOf(response));
                   String EmployeeId = jsonObject.getString("EmployeeId");
                   String Firstname = jsonObject.getString("FirstName");
                   String Lastname = jsonObject.getString("LastName");
                   String Cnic = jsonObject.getString("NICNumber");
                   String Username = jsonObject.getString("UserName");
                   String Password = jsonObject.getString("Password");
                   String empTypeId = 
                     jsonObject.getString("EmployeeTypeId");
                                String empTypeName = jsonObject.getString("EmployeeTypeName");

                                Log.e("typeId : ", empTypeId);
                                Log.e("typeName : ", empTypeName);


                                String md5Pass = MD5.encrypt(password);
                                login.setEmployee_Id(EmployeeId);
                                login.setEmployee_F_Name(Firstname);
                                login.setEmployee_L_Name(Lastname);
                                login.setEmployee_NIC(Cnic);
                                login.setEmployee_Username(Username);
                                login.setEmployee_Password(md5Pass);
                                login.setEmployeeTypeId(empTypeId);
                                login.setEmployeeTypeName(empTypeName);

                            int loginId = Integer.parseInt(EmployeeId);

                         int checking = dbHandler.checkingLogin(EmployeeId);
                                if (checking == 1) {
                                   // showRepaymentFPDialog2(EmployeeId);
                                    preferences.setIsLoggedIn(true);
                                    preferences.setFirstName(username);
                                    preferences.setEmployeeId(loginId);
                                    preferences.setEmployeeTypeName(empTypeName);

                                    Intent goAct = new Intent(LoginActivity.this,MainActivity.class);
                                    startActivity(goAct);
                                    finish();
                                    progressDialog.dismiss();
                                } else {
                                    long res = dbHandler.insertLoginData(login);
                                                                            if (res != -1) {
                                        preferences.setIsLoggedIn(true);
                                        preferences.setFirstName(username);
                                        preferences.setEmployeeId(loginId);
                                        preferences.setEmployeeTypeName(empTypeName);

                                        Intent goAct = new Intent(LoginActivity.this,MainActivity.class);
                                        startActivity(goAct);
                                        finish();
                                        Toast.makeText(getApplicationContext(), "Login Successful!", Toast.LENGTH_SHORT).show();
                                        progressDialog.dismiss();

                                    } else {
                                        progressDialog.dismiss();
                                        Toast.makeText(getApplicationContext(), "Login Failed!", Toast.LENGTH_SHORT).show();

                                    }
                                }
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }

                        }

                        @Override
                        public void onError(ANError error) {
                            UsernameEdt.setError("Invalid");
                            PasswordEdt.setError("Invalid");
                            progressDialog.dismiss();
                            Toast.makeText(getApplicationContext(), "Invalid Username or Password" , Toast.LENGTH_LONG).show();

                        }
                    });

        } else {
            progressDialog.dismiss();
            String EncryptedPass = password;
            String md5Pass = MD5.encrypt(EncryptedPass);
            int logged = dbHandler.LoginInFromDB(username,md5Pass);

            Log.e(TAG, "onClick0: "+logged +":"+md5Pass+":"+EmpId);
            if(logged ==1){
                preferences.setFirstName(username);
                preferences.setEmployeeId(preferences.getEmployeeId());
                EmpId = String.valueOf(preferences.getEmployeeId());

                preferences.setIsLoggedIn(true);

                Intent goAct = new Intent(LoginActivity.this,MainActivity.class);
                startActivity(goAct);
                finish();
                progressDialog.dismiss();

            }else {
                progressDialog.dismiss();
                UsernameEdt.setError("Invalid");
                PasswordEdt.setError("Invalid");
                Toast.makeText(getApplicationContext(), "Login Failed!", Toast.LENGTH_LONG).show();

            }
        }
    }

}

I am getting these Warning after updating android studio .

enter image description here

can anybody help with that?

here is Gradle file

buildscript {
repositories {
    maven { url 'https://maven.fabric.io/public' }
}
dependencies {
    classpath 'io.fabric.tools:gradle:1.+'
}}
  apply plugin: 'com.android.application'
  apply plugin: 'io.fabric'

repositories {
maven { url 'https://maven.fabric.io/public' }
}

android { compileSdkVersion 27 buildToolsVersion '28.0.3' useLibrary 'org.apache.http.legacy' repositories { maven { url "https://jitpack.io" } } defaultConfig { applicationId "com.shery.safco" minSdkVersion 19 targetSdkVersion 27 versionCode 1 versionName "1.094" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" multiDexEnabled true

    ndk {
        abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
    }
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 
  'proguard-rules.pro'
    }
    debug {
        resValue("string", "PORT_NUMBER", "8083")
    }
  }}
 dependencies {
    implementation 'com.android.support.constraint:constraint- 
   layout:1.0.2'
   implementation 'com.android.support:support-v4:27.1.0'
   androidTestImplementation('com.android.support.test.espresso:espresso- 
    core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
debugImplementation 'com.amitshekhar.android:debug-db:1.0.3'
implementation 'com.android.support:design:27.1.0'
implementation 'io.nlopez.smartlocation:library:3.3.1'
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation 'com.android.support:appcompat-v7:27.1.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:cardview-v7:27.1.0'
implementation 'com.github.vajro:MaterialDesignLibrary:1.6'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'uk.co.chrisjenx:calligraphy:2.2.0'
implementation 'com.droidninja:filepicker:1.0.7'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'id.zelory:compressor:1.0.2'
implementation 'com.amitshekhar.android:android-networking:1.0.1'
implementation 'com.amitshekhar.android:jackson-android-networking:1.0.1'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation files('libs/FDxSDKProAndroid.jar')
//    implementation 'com.jakewharton:butterknife-gradle-plugin:8.8.1'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
    transitive = true;
}
implementation files('libs/MD5Simply.jar')

}

Rashid Kalhoro
  • 340
  • 4
  • 14

1 Answers1

-1

In New Android Studio version you need to check security. And for that please refer this link Security-config. And this type of issue occur in android 8 and 9.

Also You need to use secure URL like https://. if you are using http:// then this type of issue occur.

replace below code in related match

buildscript {

repositories {
    google()
    jcenter()
    maven { url 'https://maven.fabric.io/public' }
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
    classpath 'io.fabric.tools:gradle:1.+'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

ankur bhut
  • 125
  • 1
  • 11
  • then check the above link Security-Config. – ankur bhut Jan 21 '19 at 06:58
  • i updated my android studio now getting warnings , please have look at my question and see android studio SS @ankur – Rashid Kalhoro Jan 21 '19 at 07:00
  • 1
    okay for this currently no solution available So for that the temporary solution you can downgrade your gradle version in class-path. i think you are using 3.3.0. then downgrade this version to 3.2.1. It may help you for temporary. – ankur bhut Jan 21 '19 at 07:55
  • It's probably coming from the Crashlytics plugin. We need to wait for an update from the Fabric (now Google) people. In the meantime it's just a warning - albeit a very distracting and annoying one - so you can (try to) ignore it. – ankur bhut Jan 21 '19 at 07:57
  • yes i am using 3.3 . and how can i downgrade? updated my Question plese check my gradle file . @ankur – Rashid Kalhoro Jan 21 '19 at 08:22
  • i did change my gradle with the code u provided . Still getting the same warnings . @ankur – Rashid Kalhoro Jan 21 '19 at 09:49
  • Still same issue . – Rashid Kalhoro Jan 21 '19 at 09:54
  • If you are not using the NDK then remove this code from gradle. ndk { abiFilters "armeabi", "armeabi-v7a", "x86", "mips" } – ankur bhut Jan 21 '19 at 10:34
  • still not working , installed previous version of android studio but still got same issue . – Rashid Kalhoro Jan 21 '19 at 11:43
  • There's a default trust anchor in Android that's used if you don't set one up explicitly. So this wiill not be his problem. – Gabe Sechan Jan 21 '19 at 14:18