I am a newbie in Android development
Logcat:
com.example.androuber E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.androuber, PID: 19270
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.androuber/com.example.androuber.Welcome}: android.view.InflateException: Binary XML file line #25: Binary XML file line #25: Error inflating class com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3430)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3614)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:86)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2199)
at android.os.Handler.dispatchMessage(Handler.java:112)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7625)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
Caused by: android.view.InflateException: Binary XML file line #25: Binary XML file line #25: Error inflating class com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch
Caused by: android.view.InflateException: Binary XML file line #25: Error inflating class com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at android.view.LayoutInflater.createView(LayoutInflater.java:658)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:801)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:874)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:877)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:877)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:835)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:498)
at com.android.internal.policy.HwPhoneWindow.setContentView(HwPhoneWindow.java:342)
at android.app.Activity.setContentView(Activity.java:2941)
at com.example.androuber.Welcome.onCreate(Welcome.java:78)
at android.app.Activity.performCreate(Activity.java:7458)
at android.app.Activity.performCreate(Activity.java:7448)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1286)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3409)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3614)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:86)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2199)
at android.os.Handler.dispatchMessage(Handler.java:112)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7625)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
This the Welcome.java.78:
setContentView(R.layout.activity_welcome);
activity_welcome:
<?xml version="1.0" encoding="utf-8"?>
<fragment 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:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Welcome"
class="com.google.android.gms.maps.SupportMapFragment">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:weightSum="10"
android:padding="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch
android:id="@+id/location_switch"
android:layout_width="0dp"
android:layout_weight="3"
android:layout_height="wrap_content"
app:icon_release="@drawable/ic_location_off"
app:icon_press="@drawable/ic_location_on"
app:base_release_color="@color/baseReleaseColor"
app:base_press_color="@color/basePressColor"
app:ball_release_color="@color/ballReleaseColor"
app:ball_press_color="@android:color/white"
/>
</LinearLayout>
</RelativeLayout>
</fragment>
OnCreate
of Welcome.java
where are occurring:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
//init view
location_switch = (MaterialAnimatedSwitch) findViewById(R.id.location_switch);
location_switch.setOnCheckedChangeListener(new MaterialAnimatedSwitch.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(boolean isOnline) {
if (isOnline){
startLocationUpdate();
displayLocation();
Snackbar.make(mapFragment.getView(),"You Are Online",Snackbar.LENGTH_SHORT)
.show();
}
else {
stopLocationUpdates();
mCurrent.remove();
Snackbar.make(mapFragment.getView(),"You Are Offline",Snackbar.LENGTH_SHORT)
.show();
}
}
});
drivers = FirebaseDatabase.getInstance().getReference("Drivers");
geoFire = new GeoFire(drivers);
setUpLocation();
}
mainactivity Login block
private void showLoginDialog() {
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle("SIGN IN");
dialog.setMessage("Please Use Email To sign in");
LayoutInflater inflater = LayoutInflater.from(this);
View login_layout = inflater.inflate(R.layout.layout_login,null);
final MaterialEditText edtEmail = (MaterialEditText) login_layout.findViewById(R.id.edtEmail);
final MaterialEditText edtPassword = (MaterialEditText) login_layout.findViewById(R.id.edtPassword);
dialog.setView(login_layout);
// set Button
dialog.setPositiveButton("SIGN IN", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
//set disable button sign in if in processing
btnSignUP.setEnabled(false);
//check validation
if (TextUtils.isEmpty(edtEmail.getText().toString())) {
Snackbar.make(rootLayout, "Please Enter Email Address", Snackbar.LENGTH_SHORT)
.show();
return;
}
if (TextUtils.isEmpty(edtPassword.getText().toString())) {
Snackbar.make(rootLayout, "Please Enter Password", Snackbar.LENGTH_SHORT)
.show();
return;
}
if (edtPassword.getText().toString().length() < 6) {
Snackbar.make(rootLayout, "Password too short!!!", Snackbar.LENGTH_SHORT)
.show();
return;
}
final android.app.AlertDialog waitingDialog = new SpotsDialog.Builder().setContext(MainActivity.this).build();
waitingDialog.show();
//login
auth.signInWithEmailAndPassword(edtEmail.getText().toString(),edtPassword.getText().toString())
.addOnSuccessListener(new OnSuccessListener<AuthResult>() {
@Override
public void onSuccess(AuthResult authResult) {
waitingDialog.dismiss();
startActivity(new Intent(MainActivity.this,Welcome.class));
finish();
}
}) .addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
waitingDialog.dismiss();
Snackbar.make(rootLayout,"Failed "+e.getMessage(),Snackbar.LENGTH_SHORT)
.show();
//Activate Sign up Button
btnSignUP.setEnabled(true);
}
});
}
});
dialog.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
dialog.show();
}
<com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch
android:id="@+id/location_switch"
android:layout_width="0dp"
android:layout_weight="3"
android:layout_height="wrap_content"
app:icon_release="@drawable/ic_location_off"
app:icon_press="@drawable/ic_location_on"
app:base_release_color="@color/baseReleaseColor"
app:base_press_color="@color/basePressColor"
app:ball_release_color="@color/ballReleaseColor"
app:ball_press_color="@android:color/white"
/>
I think you have used some attribute which is not provided by this library, remove all the custom attributes and check if it working or not, then you can apply your attribute one by one.