No fragment showing on ViewPager - java

My ViewPager does not show any fragments even though it load the fragment for my "Review section". I used the same code with my "rating section" and it work, even tried redo the ViewPager and adapter but still no progress. By the way i'm doing this within a fragment.
I put a log in the adapter to show whether the fragment is working and also change my Viewpager's background color to check if it's visible or not. Even though the ViewPager is visible but the fragment still does not show.
UPDATE: I found out that the problem caused by the activity i use to replace with the fragments.
Here the code snippet (in my activity which hold both "Rating Section" and "review Section".
SubSectionFragment_Rating subSectionFragment_rating = new SubSectionFragment_Rating();
manager = getSupportFragmentManager();
manager.beginTransaction().replace(R.id.ratingSection,subSectionFragment_rating, subSectionFragment_rating.getTag()).commit();
SubSectionFragment_ReviewAndInstructions subSectionFragment = new SubSectionFragment_ReviewAndInstructions();
manager = getSupportFragmentManager();
manager.beginTransaction().replace(R.id.subTab,subSectionFragment, subSectionFragment.getTag()).commit();
ViewPager is visible
Should display this fragment in ViewPager
Review.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.hybridelements.openchef.fragment_activities.fragment_subs.SubSectionFragment_ReviewAndInstructions">
<RelativeLayout
android:id="#+id/main_layout"
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.support.design.widget.TabLayout
android:id="#+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/tab_layout"
android:background="#android:color/holo_green_dark"/>
</RelativeLayout>
Review.java (part of the code)
viewPager = (ViewPager) rootView.findViewById(R.id.pager);
final SubPagerAdapter_ReviewAndInstructions adapter = new SubPagerAdapter_ReviewAndInstructions(getActivity().getSupportFragmentManager(), tabLayout.getTabCount());
viewPager.setAdapter(adapter);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
SubPagerAdapter_ReviewAndInstructions.java
public SubPagerAdapter_ReviewAndInstructions(FragmentManager fm, int NumOfTabs){
super(fm);
this.mNumOfTabs = NumOfTabs;
}
#Override
public Fragment getItem(int position) {
switch (position){
case 0:
ReviewsFragment subTab1 = new ReviewsFragment();
Log.d("ReviewAndInstruction","ReviewsFragment loaded");
return subTab1;
default:
return null;
}
}
#Override
public int getCount() {
return mNumOfTabs;
}

Problem solved thanks to #Yupi for the suggestion to change from getActivity().getSupportFragmentManager() to getChildFragment(). during the problem occurred, when change to getChildFragment() got an error
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.util.SparseArray.get(int)' on a null object reference
To fix this error, i need to change my activity that start the fragment transaction, so here's the solution to the problem for nested fragments.
ViewItem.Java (BEFORE)
FragmentManager manager;
manager = getSupportFragmentManager();
ViewItem.Java (AFTER)
FragmentTransaction manager;
manager = getSupportFragmentManager().beginTransaction();
SubPagerFragment_ReviewAndInstructions.java (BEFORE)
final SubPagerAdapter_ReviewAndInstructions adapter = new SubPagerAdapter_ReviewAndInstructions(getActivity().getSupportFragmentManager(), tabLayout.getTabCount());
SubPagerFragment_ReviewAndInstructions.java (AFTER)
final SubPagerAdapter_ReviewAndInstructions adapter = new SubPagerAdapter_ReviewAndInstructions(getChildFragmentManager(), tabLayout.getTabCount());
Result
Fragment correctly displayed

In my case, the childFragmentManager and addToBackStack still not fixed my issue, this solution might work instead. With combination from #burning-violet solution.
childFragmentManager used to construct the ViewPager
Using FragmentStatePageAdapter
override restoreState()
Without using addToBackStack(null) // this optional, if you don't want to add to backstack
The restoreState() try catch will only silence the error (NPE), it must be fixed accordingly.

Related

Can't call Fragment method in parent Activity

I simply want to call a method from a fragment in my MainActivity(parent).
But as soon as I try to call the method I get an NullPointerException.
Attempt to invoke virtual method 'void
com.example.fragmenttest.TestFragment.testMethod()' on a null object
reference
Here is what I do in the onCreate of the MainActivity:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.containerView, new TestFragment()).commit();
TestFragment fragment = (TestFragment) fragmentManager.findFragmentById(R.id.testfragment);
fragment.testMethod();
}
and here is the fragment:
#Nullable
#Override
public View onCreateView(#NonNull LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
View rootView=inflater.inflate(R.layout.activity_fragment,container,false);
return rootView;
}
public void testMethod(){
Toast.makeText(getContext(), "Test", Toast.LENGTH_LONG).show();
}
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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">
<FrameLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/containerView">
</FrameLayout>
</RelativeLayout>
and activity_fragment.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.fragmenttest.MainActivity"
android:id="#+id/testfragment">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textSize="50dp"
android:text="Fragment" />
</RelativeLayout>
Of course this is not my real project, I just created a new one to simplify my issue.
In my real project I want to call a method from my fragment as soon as the onRewardedVideoCompleted method gets called, which is in my MainActivity.
How do I call the method from my fragment without getting a null pointer exception and without using an interface? (Using an interface for this small problem seems unnecessary)
Thanks
commit() is asynchronous. This is why your project is crashing upon launch. Instead of using commit(), use commitNow(). Also, instead of using new TestFragment(), create a variable so you can call its methods.
TestFragment testFragment= new TestFragment();
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.containerView, testFragment).commitNow();
testFragment.testMethod();
Fragment transactions are asynchronous (unless you use executePendingTransactions()). Your transaction has likely not completed yet. You use runOnCommit on FragmentTransaction (in the support library) to execute code after it is done.
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
TestFragment yourFragment = newe TestFragment();
fragmentTransaction.replace(R.id.containerView, yourFragment).commit();
yourFragment.testMethod();
First of all, You must pass yourFragment to fragmentTransaction, then you can call any methods you want.

Viewpager2 and Fragments

ViewPager2 does not support direct child views
I'm trying to transition between fragments using the following code but I get the above error when using viewpager2.
Call in fragment 1 to transition to fragment 2:
getFragmentManager().beginTransaction().replace(R.id.viewPager2, new q2_fragment()).addToBackStack(null).commit();
Viewpager2 XML in Main Layout:
<androidx.viewpager2.widget.ViewPager2
android:id="#+id/viewPager2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="10"
android:orientation="horizontal"
android:scaleType="fitXY" />
Instantiation in Main:
final ViewPager2 viewPager2 = findViewById(R.id.viewPager2);
viewPager2.setAdapter(new QuestionsActivity.ScreenSlidePagerAdapter(this));
viewPager2.setUserInputEnabled(false);
How do I avoid this error with viewpager2?
I got the same error when I put the TabLayout before ViewPager 's closing tag
That is:
<androidx.viewpager2.widget.ViewPager2
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.tabs.TabLayout
android:id="#+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</androidx.viewpager2.widget.ViewPager2>
Which is not Allowed!
Just Removing the ending tag and separating TabLayout will work
<androidx.viewpager2.widget.ViewPager2
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<com.google.android.material.tabs.TabLayout
android:id="#+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
Would be happy to help, please elaborate on your requirement. What exactly you want to do.
If you want to go to fragment 2 from fragment 1, at a particular point then you should use interface between fragment and activity, to tell the activity to move the viewpager to the item which has fragment 2.
Interface Pattern for Fragment to Activity
Interface
public interface FragmentCallback{
public void goTo(int pos);
}
Activity
public class MyActivity extends AppCompatActivity implements MyStringListener{
#Override
public void goTo(int pos){
yourviewpagerAdapter.setCurrentItem(pos);
}
}
public class Fragment1 {
private FragmentCallback callBack;
#Override
public void onAttach(Context context) {
super.onAttach(context);
try {
callBack = (FragmentCallback) context;
} catch (ClassCastException castException) {
/** The activity does not implement the listener. */
}
}
public void someEvent() {
if(callBack!=null) {
callBack.goTo(1);
}
}
}
As the statement says
ViewPager2 does not support direct child views
So never try to add the fragment to viewPager2 directly
i.e the following lines of code will not work with viewPager2.
getFragmentManager().beginTransaction().replace(R.id.viewPager2, new q2_fragment()).addToBackStack(null).commit();
The exception is produced if you try to add fragment directly to viewPager2 with the help of fragmentManager.
So simply remove the above lines of code to get rid of this exception.
Lets Say From Fragment_1 to Fragment_2:
In side the button click in Fragment_1
Bundle result = new Bundle(); result.putString("bundleKey", "result"); getParentFragmentManager().setFragmentResult("requestKey", result);
In side the Fragment_2 onCreate(Bundle savedInstanceState) method
getParentFragmentManager().setFragmentResultListener("requestKey", this, new FragmentResultListener() {
#Override public void onFragmentResult(#NonNull String requestKey, #NonNull Bundle bundle)
{
supported String result = bundle.getString("bundleKey"); System.out.println("----------------------------"+result);
}
});
https://developer.android.com/guide/fragments/communicate#pass-between-fragments
Use mPager.setNestedScrollingEnabled(true);

How to start a fragment from an activity

I am trying to run a class extending a fragment from a class extending AppCompactActivity, I have tried everything I have saw in Stackover flow and I cant get any to fix my problem. LineDetails is extending the Fragment
Progress1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Fragment fr = new LineDetails();
android.app.FragmentManager fm = getFragmentManager();
android.app.FragmentTransaction fragmentTransaction = fm.beginTransaction();
fragmentTransaction.replace(R.id.fragment_place, fr);
fragmentTransaction.commit();
}
});
XML
<fragment android:name="com.almac.tracker.LineDetails"
android:id="#+id/fragment_place"
android:layout_width="match_parent"
android:layout_height="match_parent" />
PART OF XML FOR ACTIVITY CLASS
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:overScrollMode="never"
android:scrollbars="none"
tools:context=".Dashboard">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/fragment_place">
</FrameLayout>
</RelativeLayout >
If your activity extends AppCompatActivity, then you cannot use getFragmentManager().
In fact you should get rid of classes in the package android.app such as android.app.FragmentManager. You should use the support classes from the package android.support.v4.app such as android.support.v4.app.FragmentManager
Use getSupportFragmentManager() instead of getFragmentManager()
The stack trace reports that you don't have any Layout with id R.id.fragment_place inside your activity. Check the xml of your activity and correct the id of fragment holder.
You're replacing instead of adding without a refresh, just do an add. I also simplified one of your useless variables and just went straight to ft instead of having an intermediate fm.
Progress1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Fragment fr = new LineDetails();
android.app.FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.add(R.id.fragment_place, fr);
ft.commit();
}
});
getSupportFragmentManager() should be used if activity extends AppcompatActivity
EDIT :
As per the Errors ! There is no View named fragment_place in the activity's layout that is #+id/fragment_place must exist in activity_main (If this is the layout attached to activity)
Double check your layout xml, It should have a FrameLayout with attribute #+id/fragment_place act as a placeholder for your LineDetails fragment.
If you already place <fragment /> in your layout, you don't need to replace() it programmatically.

Android Java - have button change tab

I recently started coding and have been following tutorials. I'm trying to learn how to use a tab activity right now and followed a tutorial to do it by swiping pages. Here's what I've come up with
public class MainActivity extends FragmentActivity {
ViewPager pager;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn1 = (Button) findViewById(R.id.btn1);
Button btn2 = (Button) findViewById(R.id.btn2);
pager = (ViewPager) findViewById(R.id.viewPager);
pager.setAdapter(new MyPagerAdapter(getSupportFragmentManager()));
}
public void onClickBtn1(View v) {
//when clicked, take to Main2Activity.java
}
public void onClickBtn2(View v) {
//when clicked, take to Main3Activity.java
}
private class MyPagerAdapter extends FragmentPagerAdapter {
public MyPagerAdapter(FragmentManager fm) {
super(fm);
}
#Override
public Fragment getItem(int pos) {
switch(pos) {
case 0: return Main2Activity.newInstance("FirstFragment, Instance 1");
case 1: return Main3Activity.newInstance("SecondFragment, Instance 1");
case 2: return Main4Activity.newInstance("ThirdFragment, Instance 1");
default: return Main4Activity.newInstance("ThirdFragment, Default");
}
}
#Override
public int getCount() {
return 3;
}
}
}
Can someone please explain to me what's going on in the MyPageAdapter class please?
Also, is it possible that instead of swiping pages that I use a button? For instance, onClickBtn1 will take me to Main2Activity and onClickBtn2 will take me to Main3Activity. I'd like to continue using the tabs instead of creating a new intent.
Thanks in advance!
Your MyPageAdapter will have as many childs as of your tabs.
For example if you select 1st tab ie position will be 0.
Now in below code new instance of fragment is created for pos 0(First Fragment).
public Fragment getItem(int pos) {
switch(pos) {
case 0: return Main2Activity.newInstance("FirstFragment, Instance 1");
case 1: return Main3Activity.newInstance("SecondFragment, Instance 1");
case 2: return Main4Activity.newInstance("ThirdFragment, Instance 1");
default: return Main4Activity.newInstance("ThirdFragment, Default");
}
}
Switching the tabs on button click is not a cool idea as per user experience.You are using view pager which will help swiping the tabs easily.Execute the code & you will get to know more about the functionality of the code.
if you want to use tabs, you could use 4 fragments in an activity and manage them with ViewPager, by this you can go from one to another by clicking on the tabs and swipe left and right
private void initPager() {
ViewPager pager = (ViewPager) findViewById(R.id.pager);
mAdapter = new MyPagerAdapter(getSupportFragmentManager());
mAdapter.addFragment(firstFragment.newInstance(), getString(R.string.first_fragment_Title));
mAdapter.addFragment(secondFragment.newInstance(), getString(R.string.second_fragment_title));
pager.setAdapter(mAdapter);
TabLayout tabs = (TabLayout) findViewById(R.id.tabs);
tabs.setupWithViewPager(pager);
TextView firstFragmentTabTitle = (TextView) getLayoutInflater().inflate(R.layout.tab_indicator, null);
firstFragmentTabTitle.setText(mAdapter.getPageTitle(0).toString());
TextView secondFragmentTabTitle = (TextView) getLayoutInflater().inflate(R.layout.tab_indicator, null);
secondFragmentTabTitle.setText(mAdapter.getPageTitle(1).toString());
tabs.getTabAt(0).setCustomView(firstFragmentTabTitle);
tabs.getTabAt(1).setCustomView(secondFragmentTabTitle);
pager.setCurrentItem(mAdapter.getCount());
}
and the main activity XML add view pager and tab layout like this :
<?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"
android:gravity="center"
android:orientation="vertical"
tools:context=".fragments.BankCounterFragment">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutDirection="ltr"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:contentInsetEnd="16dp"
app:popupTheme="#style/AppTheme.PopupOverlay">
<TextView
android:id="#+id/toolbar_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:gravity="center|start"
android:text="#string/app_name"
android:textAppearance="#style/TextAppearance.AppCompat.Title"/>
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:layoutDirection="ltr"
app:tabGravity="fill"
app:tabIndicatorColor="#android:color/white"
app:tabIndicatorHeight="3dp"
app:tabMode="fixed"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

Android application crashes after startup without any errors

I have a problem with my android application. It worked fine before, but it started crashing immediately after start without any errors and I can't figure out why. I have commented (//) a lot of code in my classes and left there only things important for working, but still the same problem. I have a mainActivity and 2 fragments.
When I created fragments it automatically created folder layout and put java classes there.
Fragment java classes (List, Set):
public class List extends Fragment {
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_list, container, false);
}
}
Main activity class:
public class MainActivity extends AppCompatActivity {
/**
* The {#link android.support.v4.view.PagerAdapter} that will provide
* fragments for each of the sections. We use a
* {#link FragmentPagerAdapter} derivative, which will keep every
* loaded fragment in memory. If this becomes too memory intensive, it
* may be best to switch to a
* {#link android.support.v4.app.FragmentStatePagerAdapter}.
*/
private SectionsPagerAdapter mSectionsPagerAdapter;
/**
* The {#link ViewPager} that will host the section contents.
*/
private ViewPager mViewPager;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.container);
mViewPager.setAdapter(mSectionsPagerAdapter);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(mViewPager);
FloatingActionButton addButton = (FloatingActionButton) findViewById(R.id.add);
addButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
}
/**
* A {#link FragmentPagerAdapter} that returns a fragment corresponding to
* one of the sections/tabs/pages.
*/
public class SectionsPagerAdapter extends FragmentPagerAdapter {
SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
#Override
public Fragment getItem(int position) {
switch(position) {
case 0:
return new Set();
case 1:
return new List();
default:
return null;
}
}
#Override
public int getCount() {
// Show 3 total pages.
return 2;
}
#Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "ZADÁVÁNÍ";
case 1:
return "SEZNAM";
}
return null;
}
}
}
activity_main.xml (auto-generated):
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="cz.sudoman281.kubirovacikalkulacka.MainActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="#dimen/appbar_padding_top"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
fragments .xml files:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".layout.List">
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="List"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView6" />
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent" />
</GridLayout>
</FrameLayout>
The logcat filters does not always show logs when the app is getting started up. I faced a similar issue when integrating a library. This is how I found where the issue is.
Start the app in debug mode, set a breakpoint on the first line in onCreate method and keep steping over(F8) till you get the crash.
From your log output, I saw this line:
01-01 15:01:58.206 7457-7457/cz.sudoman281.kubirovacikalkulacka
W/System: ClassLoader referenced unknown path:
/data/app/cz.sudoman281.kubirovacikalkulacka-1/lib/arm64
I guess there is something wrong with your native libraries, double check your Make or CMake buid files, make sure you're loading your native libraries correctly from the Java class.
Another thing if you're running your app on a device/emulator with Android Nougat, you may need to check that your native libraries are not linking against non-NDK libraries as described here: https://developer.android.com/about/versions/nougat/android-7.0-changes.html#ndk

Categories

Resources