I have a little problem.
I'm trying to BindView
with the id ongoing_call_layout
.
I have that id, it exists and its a ConstraintLayout
object in xml.
When running the program it acts like the id "ongoing_call_layout" doesn't exist.
I've tried cleaning and rebuilding the project and also using findViewById
instead of BindView
but still, it says that the id doesn't exist.
In the code itself its bolded (AndroidStudio do know where the id is).
Below is the related code
Here is my OngoingCallActivity.java
(where the error comes from):
@BindView(R.id.ongoing_call_layout) ConstraintLayout mOngoingCallLayout;
.
.
.
ButterKnife.bind(this);
.
.
The error:
Unable to start activity ComponentInfo{com.chooloo.www.callmanager/com.chooloo.www.callmanager.ui.activity.OngoingCallActivity}: java.lang.IllegalStateException: Required view 'ongoing_call_layout' with ID 2131362055 for field 'mOngoingCallLayout' was not found. If this view is optional add '@Nullable' (fields) or '@Optional' (methods) annotation.
Here is my on_going_call.xml
(where the id comes from):
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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/ongoing_call_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layoutDirection="ltr"
tools:context=".ui.activity.OngoingCallActivity">
<!-- Call Timer -->
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guide_status_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_begin="24dp" />
<TextView
android:id="@+id/text_stopwatch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guide_status_bar"
tools:text="00:00" />
<!-- Caller Number (Temporary) -->
<!-- Caller Pic -->
<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="129dp"
android:layout_height="135dp"
app:layout_constraintBottom_toTopOf="@+id/text_caller"
app:layout_constraintEnd_toEndOf="@+id/text_caller"
app:layout_constraintStart_toStartOf="@+id/text_caller"
app:layout_constraintTop_toBottomOf="@+id/text_stopwatch">
<ImageView
android:id="@+id/image_placeholder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tint="@color/selector_button_icon"
app:srcCompat="@drawable/ic_account_circle_black_24dp" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/image_photo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
app:civ_border_width="0dp" />
</FrameLayout>
<!-- Caller Name -->
<TextView
android:id="@+id/text_caller"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10sp"
android:paddingRight="10sp"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline4"
android:textColor="?attr/iconColor"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/text_status"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
tools:text="Jesus" />
<!-- Call Status -->
<TextView
android:id="@+id/text_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
android:textColor="?attr/colorAccent"
app:layout_constraintBottom_toTopOf="@+id/guide_eye_level"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="@+id/text_caller"
tools:text="@string/status_call_incoming" />
<!-- Hold Button -->
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guide_eye_level"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.44" />
<ImageView
android:id="@+id/button_hold"
android:layout_width="@dimen/flat_button_size"
android:layout_height="62dp"
android:layout_marginStart="16dp"
android:layout_marginTop="120dp"
android:layout_marginEnd="16dp"
android:layout_weight="1"
android:background="@drawable/ripple_oval"
android:clickable="true"
android:focusable="true"
android:padding="@dimen/flat_button_padding"
android:tint="@color/selector_button_icon"
android:visibility="invisible"
app:layout_constraintBottom_toTopOf="@+id/button_add_call"
app:layout_constraintEnd_toStartOf="@+id/button_speaker"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/button_mute"
app:layout_constraintTop_toTopOf="@+id/guide_eye_level"
app:layout_constraintVertical_bias="0.32999998"
app:layout_constraintVertical_chainStyle="packed"
app:srcCompat="@drawable/ic_pause_black_24dp"
tools:visibility="visible" />
<!-- Mute Button -->
<ImageView
android:id="@+id/button_mute"
android:layout_width="@dimen/flat_button_size"
android:layout_height="@dimen/flat_button_size"
android:layout_marginEnd="16dp"
android:layout_weight="1"
android:background="@drawable/ripple_oval"
android:clickable="true"
android:focusable="true"
android:padding="@dimen/flat_button_padding"
android:tint="@color/selector_button_icon"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@+id/button_hold"
app:layout_constraintEnd_toStartOf="@+id/button_hold"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/button_hold"
app:srcCompat="@drawable/ic_mic_off_black_24dp"
tools:visibility="visible" />
<!-- Speaker Button -->
<ImageView
android:id="@+id/button_speaker"
android:layout_width="@dimen/flat_button_size"
android:layout_height="@dimen/flat_button_size"
android:layout_marginStart="16dp"
android:layout_weight="1"
android:background="@drawable/ripple_oval"
android:clickable="true"
android:focusable="true"
android:padding="@dimen/flat_button_padding"
android:tint="@color/selector_button_icon"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@+id/button_hold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/button_hold"
app:layout_constraintTop_toTopOf="@+id/button_hold"
app:srcCompat="@drawable/ic_volume_up_black_24dp"
tools:visibility="visible" />
<!-- Keypad Button -->
<ImageView
android:id="@+id/button_keypad"
android:layout_width="@dimen/flat_button_size"
android:layout_height="@dimen/flat_button_size"
android:layout_marginEnd="16dp"
android:layout_weight="1"
android:background="@drawable/ripple_oval"
android:clickable="true"
android:focusable="true"
android:padding="@dimen/flat_button_padding"
android:tint="@color/selector_button_icon"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@+id/button_add_call"
app:layout_constraintEnd_toStartOf="@+id/button_add_call"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/button_add_call"
app:srcCompat="@drawable/ic_dialpad_black_24dp"
tools:visibility="visible" />
<!-- Add Call Button -->
<ImageView
android:id="@+id/button_add_call"
android:layout_width="65dp"
android:layout_height="67dp"
android:layout_marginStart="16dp"
android:layout_marginTop="32dp"
android:background="@drawable/ripple_oval"
android:clickable="true"
android:focusable="true"
android:padding="@dimen/flat_button_padding"
android:tint="@color/selector_button_icon"
android:visibility="invisible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/button_keypad"
app:layout_constraintTop_toBottomOf="@+id/button_hold"
app:srcCompat="@drawable/ic_add_black_24dp"
tools:visibility="visible" />
<!-- Answer Button -->
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/answer_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginBottom="32dp"
android:scaleType="center"
android:src="@drawable/ic_call_black_24dp"
android:tint="@color/green_phone"
app:backgroundTint="@color/white"
app:fabCustomSize="72dp"
app:fabSize="normal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:maxImageSize="36dp" />
<!-- Reject Button -->
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/reject_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="32dp"
android:layout_marginBottom="32dp"
android:scaleType="center"
android:src="@drawable/ic_call_end_black_24dp"
android:tint="@color/red_phone"
app:backgroundTint="@color/white"
app:fabCustomSize="72dp"
app:fabSize="normal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:maxImageSize="36dp" />
<!-- Guidelines -->
</androidx.constraintlayout.widget.ConstraintLayout>
I cant make the declaration of mOngoingCallLayout Nullable
because its necessary.
By the way, that bug only started happening out of no where after i merged some code from server but all the code that's related to this is still the same.
Thank you for your help
You can try several things
You can also try ButterKnife Plugin = Settings -> Plugins -> Android ButterKnife Zelezny;
To access plugin menu, place your keyboard cursor on the activity name in setContentView(R.layout.your_activity)
and press ALT + INSERT
it will be last or second last option Generate ButterKnife Injections
Hope this will help