I am developing an android app using cordova framework, In my app I have to add a third party sdk(.aar file). That sdk is working fine on android native apps, but in my app (build with cordova), it is crashing on a null pointer exception, it is saying that textview instance is null where as it is not null.I am still unable to spot the issue. Any help in this regard would be highly appreciated.
Stack trace:
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setVisibility(int)' on a null object reference at com.project.sdk.fragments.CameraImageFragment.onCreateView(CameraImageFragment.java:108) at android.support.v4.app.Fragment.performCreateView(Fragment.java:2439) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460) at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852) at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:802) at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625) at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
CameraImageFragment.java:
private TextView camera_instructions;public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(layout.activity_camera, container, false); this.mContext = this.getActivity(); this.camera_instructions = (TextView)view.findViewById(id.camera_instructions); return view;}private void setInstructionAfterClick(int type) { this.camera_instructions.setVisibility(0); //Rest of the code}
camera_camera.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@color/camera_screen_background"><TextView android:id="@+id/camera_instructions" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/take_photo" app:layout_constraintTop_toBottomOf="@+id/camera_image" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintBottom_toBottomOf="parent" android:layout_marginStart="15dp" android:layout_marginEnd="15dp" android:layout_below="@id/camera_image" android:textColor="@color/charcol_blue" android:textStyle="bold" android:textSize="17dp" android:visibility="gone"/></RelativeLayout>