自从我将android studio更新到最新版本之前,我的应用程序就可以正常运行,但是现在我无法登录我的应用程序。 提供用户名和密码后,登录屏幕只会被处理,而无法登录。
可能是什么问题,请帮忙?
这是上传数据的方法。
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);
}
});
}
用于登录内部登录活动的方法
@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();
}
}
}
}
更新android studio后,我收到这些警告。
有人可以帮忙吗?
这是Gradle文件
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' 储存库{ 专家{url“ https://jitpack.io”} } defaultConfig { applicationId“ com.shery.safco” minSdkVersion 19 targetSdkVersion 27 版本代码1 versionName“ 1.094” testInstrumentationRunner “ android.support.test.runner.AndroidJUnitRunner” multiDexEnabled是
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')
}
答案 0 :(得分:-1)
在新的Android Studio版本中,您需要检查安全性。为此,请参考此链接Security-config。而这种类型的问题发生在android 8和9中。
此外,您需要使用安全网址,例如https://。如果您使用的是http://,则会出现这种类型的问题。
在相关匹配项中的代码下方替换
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
}
}