2021-01-09 20:43:41.905 12890-12890/com.example.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
public class MainActivity extends AppCompatActivity {
private EditText mPhoneNumber, mCode;
private Button msend;
private PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallbacks;
String mVerificationId;
@SuppressLint("WrongViewCast")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FirebaseApp.initializeApp(this);
userIsLoggedIn();
mPhoneNumber = findViewById(R.id.phoneNumber);
mCode = findViewById (R.id.code);
msend= findViewById(R.id.send);
msend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mVerificationId!=null)
verifyPhoneNumberWithCode();
else
startPhoneNumberVerification();
}
});
mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks(){
public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential){
signInWithPhoneAuthCredential(phoneAuthCredential);
}
@Override
public void onVerificationFailed(FirebaseException e) {
}
@Override
public void onCodeSent(String verificationeId, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
super.onCodeSent(verificationeId, forceResendingToken);
mVerificationId = verificationeId;
msend.setText("Verify Code");
}
};
}
private void verifyPhoneNumberWithCode(){
PhoneAuthCredential credential= PhoneAuthProvider.getCredential(mVerificationId, mCode.getText().toString());
signInWithPhoneAuthCredential(credential);
}
private void signInWithPhoneAuthCredential(PhoneAuthCredential phoneAuthCredential){
FirebaseAuth .getInstance().signInWithCredential(phoneAuthCredential).addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if(task.isSuccessful())
userIsLoggedIn();
}
});
}
private void userIsLoggedIn() {
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
if (user !=null){
startActivity(new Intent(getApplicationContext(),MainActivity.class));
finish();
return;
}
}
private void startPhoneNumberVerification() {
PhoneAuthProvider.getInstance().verifyPhoneNumber(
mPhoneNumber.getText().toString(),
60,
TimeUnit.SECONDS,
this,
mCallbacks);
}
}
package com.example.myapplication;
public class MainPageActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_page);
Button mlogout = findViewById(R.id.logout);
mlogout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FirebaseAuth.getInstance().signOut();
Intent intent= new Intent(getApplicationContext(), MainActivity.class);
//to clear the activity after logout instant
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
return;
}
});
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="MainActivity"
android:layout_alignParentTop="true"
tools:actionBarNavMode="standard"
android:orientation="vertical">
<TextView
android:id="@+id/phoneNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter Phone Number" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter Code"
android:id="@+id/code"/>
<Button
android:id="@+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send Verification Code" />
</LinearLayout>
您在例外情况中得到了以下内容:
java.lang.ClassCastException: com.google.android.material.textview.MaterialTextView cannot be cast to android.widget.EditText
这意味着您正在尝试将TextView强制转换为EditText。所以我猜这两个中的一个:
private EditText mPhoneNumber, mCode;
是XML布局中的TextView。
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:text="wadwada"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
我已经使用IntelliJ版本14.0.2创建了一个jar,但当我试图运行jar时,我会得到一个错误,因为未能从//ABC. jar加载主类清单
错误: null 环境: opencv contrib python 4.1.2.30 到目前为止,我已经尝试了大约30种方法:
错误:无法解决':app@debug /compileClasspath'的依赖关系:无法解决com.android.support: appcompat-v7:29.显示受影响模块的详细信息:应用 错误:无法解决':app@debugAndroidTest /compileClasspath'的依赖关系:无法解决com.android.support: appcompat-v7:29.显示受影响
null C:\program files\nodejs>npm安装-g polymer-cli@next npm WARN可选跳过可选依赖项:fsevents@1.2.4(Node_modules\polymer-cli\node_modules\fsevents):npm WARN notsup跳过可选依赖项:fsevents@1.2.4:wanted{“OS”:“Darwin”,“arch”
我正在尝试解决数组旋转的程序。我在代码中遇到分段错误。有人能告诉我这个代码中的问题在哪里吗? 这就是问题所在 给定一个大小为N的未排序数组arr[],将其旋转D元素(顺时针)。 输入的第一行包含T表示测试用例的数量。每个测试用例的第一行包含两个空格分隔的元素,N表示数组的大小,整数D表示旋转的数字大小。随后的行将是N个空格分隔的数组元素。 我已经用下面的代码解决了它。
Microsoft Windows[版本10.0.18363.778](c)2019 Microsoft Corporation。保留所有权利。 F:\flutter_projects\i_am_rich>flutter build apk您正在构建一个fat apk,它包含用于android-arm、android-arm64和Android-x64的二进制文件。如果您正在将应用程序部署到Pla