I know there are lots of same question and I checked its solutions\ suggestions. However, they are not working for me. I am trying to add fragment and when I am calling fragmentTransaction.commit() it throws that exception, but that happens only with my 2nd fragment.
I send a notification to my application, when it is clicked, it opens my app which open main fragment, at that time getSupportFragmentManager().findFragmentById(R.id.rl_content_fragment); returns null for current fragment ( which should be correct ), problem is my 2nd fragment ( playerFragment) when I try to add it ( while debugging) I found out that getSupportFragmentManager() still returns null for current fragment and it throws the exception that the activity has been destroyed when I call fragmentTransaction.commit().
My questions
1-is why does the Activity gets destroyed or finish while the application is starting?
2-how can I fix that issue?
Any hint will be appreciated, thanks.
EDIT this is the exception which I get, I know I should not change views unless I am on mainThread, but I do report on main thread, Sorry forgot to say we are using commitAllowingStateLoss() and this what i get
java.lang.IllegalStateException: Activity has been destroyed
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1399)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:637)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at android.support.v4.app.BackStackRecord.commitAllowingStateLoss(BackStackRecord.java:620)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at com.myApp.BaseActivity.addContentFragment(BaseActivity.java:502)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at com.myApp.BaseActivity$3.onCompleted(BaseActivity.java:837)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at com.myAppSDK.Managers.SignalManager.setCompleted(SignalManager.java:291)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at com.myAppSDK.Managers.EpisodeManager$5.onCompleted(EpisodeManager.java:1107)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at com.myAppSDK.Managers.SignalManager.setCompleted(SignalManager.java:291)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at com.myAppSDK.Managers.APIRequestManager$ConnectionTask.onPostExecute(APIRequestManager.java:645)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at com.myAppSDK.Managers.APIRequestManager$ConnectionTask.onPostExecute(APIRequestManager.java:546)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at android.os.AsyncTask.finish(AsyncTask.java:632)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at android.os.AsyncTask.access$600(AsyncTask.java:177)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at android.os.Looper.loop(Looper.java:136)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5146)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:515)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
11-26 12:57:06.464 26608-26608/com.myApp E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
and if i use commit() I get this exception
Process: com.myApp, PID: 10659
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1377)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1395)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:637)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:616)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at com.myApp.BaseActivity.addContentFragment(BaseActivity.java:502)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at com.myApp.BaseActivity$3.onCompleted(BaseActivity.java:837)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at com.myAppSDK.Managers.SignalManager.setCompleted(SignalManager.java:291)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at com.myAppSDK.Managers.EpisodeManager$5.onCompleted(EpisodeManager.java:1107)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at com.myAppSDK.Managers.SignalManager.setCompleted(SignalManager.java:291)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at com.myAppSDK.Managers.APIRequestManager$ConnectionTask.onPostExecute(APIRequestManager.java:645)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at com.myAppSDK.Managers.APIRequestManager$ConnectionTask.onPostExecute(APIRequestManager.java:546)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at android.os.AsyncTask.finish(AsyncTask.java:632)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at android.os.AsyncTask.access$600(AsyncTask.java:177)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at android.os.Looper.loop(Looper.java:136)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5146)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:515)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
11-26 12:41:12.529 10659-10659/com.myApp E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
sorry for much logs
Related
I am writing an android app that runs a service in the background that makes use of the OVERLAY_PERMISSION to draw on other apps. It starts with an intent from a button on my main activity. So far, so good.
In my service, in my onDestroy(), I have a if (myView != null) windowManager.removeView(myView);. And when I call stopService from the activity, I get an error, saying:
java.lang.RuntimeException: Unable to stop service com.supernovaapps.cameralevel.LevelService#ed1633f: java.lang.IllegalArgumentException: View=android.widget.AbsoluteLayout{94fb155 V.E...... ......I. 0,0-0,0} not attached to window manager
I am only able to close the service if I comment out that line. However, if I do that, the view remains on the screen even after the service is closed, which is not what I want.
What is the correct way to close the service and detach the view?
Full Trace:
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: FATAL EXCEPTION: main
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: Process: com.supernovaapps.cameralevel, PID: 21233
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: java.lang.RuntimeException: Unable to stop service com.supernovaapps.cameralevel.LevelService#ed1633f: java.lang.IllegalArgumentException: View=android.widget.AbsoluteLayout{94fb155 V.E...... ......I. 0,0-0,0} not attached to window manager
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.app.ActivityThread.handleStopService(ActivityThread.java:3059)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.app.ActivityThread.-wrap21(ActivityThread.java)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1447)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: Caused by: java.lang.IllegalArgumentException: View=android.widget.AbsoluteLayout{94fb155 V.E...... ......I. 0,0-0,0} not attached to window manager
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.view.WindowManagerGlobal.findViewLocked(WindowManagerGlobal.java:424)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:350)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:111)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at com.supernovaapps.cameralevel.LevelService.onDestroy(LevelService.java:164)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.app.ActivityThread.handleStopService(ActivityThread.java:3040)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.app.ActivityThread.-wrap21(ActivityThread.java)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1447)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
12-20 20:16:10.042 21233-21233/com.supernovaapps.cameralevel E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
Looks like you passed a different view to windowManager than what was added to it before.
Just pass it the right view and it would work.
So what im trying to do is use an ImageButton with and onClick to open the android side menu but i keep getting an error.
home.xml (where the ImageButton is located with the onClick)
<ImageButton
android:id="#+id/imgViewRefresh4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:visibility="gone"
android:onClick="click1"
style="?android:attr/borderlessButtonStyle"
android:src="#drawable/slide4" />
MainActivity.java (where the onClick is called)
public void click1(){
mDrawerLayout.openDrawer(mDrawerList);
}
Logcat error
12-13 21:38:01.276 3949-3949/com.projects.quickyAB E/AndroidRuntime: FATAL EXCEPTION: main
12-13 21:38:01.276 3949-3949/com.projects.quickyAB E/AndroidRuntime: java.lang.IllegalStateException: Could not find a method click1(View) in the activity class com.projects.quickyAB.MainActivity for onClick handler on view class android.widget.ImageButton with id 'imgViewRefresh4'
12-13 21:38:01.276 3949-3949/com.projects.quickyAB E/AndroidRuntime: at android.view.View$1.onClick(View.java:3825)
12-13 21:38:01.276 3949-3949/com.projects.quickyAB E/AndroidRuntime: at android.view.View.performClick(View.java:4475)
12-13 21:38:01.276 3949-3949/com.projects.quickyAB E/AndroidRuntime: at android.view.View$PerformClick.run(View.java:18796)
12-13 21:38:01.276 3949-3949/com.projects.quickyAB E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:730)
12-13 21:38:01.276 3949-3949/com.projects.quickyAB E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:92)
12-13 21:38:01.276 3949-3949/com.projects.quickyAB E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137)
12-13 21:38:01.276 3949-3949/com.projects.quickyAB E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5455)
You have to change your method like this to handle the click
public void click1(View v){
mDrawerLayout.openDrawer(mDrawerList);
}
I am using TabLayout inside a fragment of my app. It works OK with design API version of 23.0.0 and below but for 23.1.0 and 23.2.0 I have the following crash:
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: FATAL EXCEPTION: main
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: Process:
11-26 16:03:42.528 7794-7794/E/AndroidRuntime: android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class android.support.design.widget.TabLayout
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at fragment.PrizeListFragment.onCreateView(PrizeListFragment.java:148)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at android.app.Fragment.performCreateView(Fragment.java:2220)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:973)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at android.app.BackStackRecord.run(BackStackRecord.java:793)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1535)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at android.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:562)
11-26 16:03:42.528 7794-7794/E/AndroidRuntime: at android.support.v13.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:145)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at android.support.v4.view.ViewPager.populate(ViewPager.java:1106)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at android.support.v4.view.ViewPager.populate(ViewPager.java:952)
11-26 16:03:42.528 7794-7794/E/AndroidRuntime: at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1474)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at android.view.View.measure(View.java:18788)
11-26 16:03:42.528 7794-7794/E/AndroidRuntime: at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
11-26 16:03:42.528 7794-7794/E/AndroidRuntime: at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
11-26 16:03:42.528 7794-7794/E/AndroidRuntime: at android.view.View.measure(View.java:18788)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
11-26 16:03:42.528 7794-7794/E/AndroidRuntime: at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
11-26 16:03:42.528 7794-7794/E/AndroidRuntime: at android.view.View.measure(View.java:18788)
11-26 16:03:42.528 7794-7794/E/AndroidRuntime: at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
11-26 16:03:42.528 7794-7794/E/AndroidRuntime: at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:446)
11-26 16:03:42.528 7794-7794/E/AndroidRuntime: at android.view.View.measure(View.java:18788)
11-26 16:03:42.528 7794-7794/E/AndroidRuntime: at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
11-26 16:03:42.528 7794-7794/E/AndroidRuntime: at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2643)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at android.view.View.measure(View.java:18788)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2100)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1216)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1452)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
11-26 16:03:42.528 7794-7794/E/AndroidRuntime: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
11-26 16:03:42.528 7794-7794/E/AndroidRuntime: at android.view.Choreographer.doCallbacks(Choreographer.java:670)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at android.view.Choreographer.doFrame(Choreographer.java:606)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:739)
11-26 16:03:42.528 7794-7794/E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
11-26 16:03:42.528 7794-7794/E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
11-26 16:03:42.528 7794-7794/ E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Crash occurs at this line when i inflate my xml layout for the fragment:
View fragmentView = inflater.inflate(R.layout.fragment_prize_list, container, false);
Here is my TabLayout implementation in code:
TabLayout tabLayout = (TabLayout) fragmentView.findViewById(R.id.sliding_tabs_type);
tabLayout.setTabTextColors(getResources().getColor(R.color.text_gray), getResources().getColor(R.color.theme_light_blue));
tabLayout.setupWithViewPager(viewPager);
Here are the realted xmls
XML Layout Fragment
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#android:color/transparent">
<android.support.design.widget.TabLayout
android:id="#+id/sliding_tabs_type"
android:layout_width="match_parent"
android:layout_height="40dp"
app:tabGravity="fill"
android:background="#color/white"
app:tabTextAppearance="#style/TabLayoutPrizeType.Text"
style="#style/TabLayoutPrizeType"/>
<android.support.v4.view.ViewPager
android:id="#+id/vp_prize"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white" />
</LinearLayout>
Styles xml
<style name="TabLayoutPrizeType" parent="Widget.Design.TabLayout">
<item name="tabIndicatorColor">#color/semi_theme_blue</item>
</style>
<style name="TabLayoutPrizeType.Text" parent="TextAppearance.Design.Tab">
<item name="android:textSize">15sp</item>
</style>
I am trying to develop custom native toast component for android using below document. after deploying build i am getting following exception. Please help me to resolve this.
java.lang.AssertionError: Module ToastAndroid was already registered!
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at com.facebook.infer.annotation.Assertions.assertCondition(Assertions.java:65)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at com.facebook.react.bridge.NativeModuleRegistry$Builder.add(NativeModuleRegistry.java:162)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:447)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:416)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at com.facebook.react.ReactInstanceManager.recreateReactContext(ReactInstanceManager.java:345)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at com.facebook.react.ReactInstanceManager.onJSBundleLoadedFromServer(ReactInstanceManager.java:310)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at com.facebook.react.ReactInstanceManager.access$100(ReactInstanceManager.java:70)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at com.facebook.react.ReactInstanceManager$1.onJSBundleLoadedFromServer(ReactInstanceManager.java:97)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at com.facebook.react.devsupport.DevSupportManager$13$1.run(DevSupportManager.java:530)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:739)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at android.os.Looper.loop(Looper.java:135)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5257)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
10-15 18:06:20.576 6947-6947/com.helloworldbha E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
your module could not name ‘ ToastAndroid’ ,cause the core package already have a module with that name .
see 'com.facebook.react.modules.toast.ToastModule'.
so change your module's name will fix it.
My app crashed at this line inside onCreate() function
Fabric.with(this, new Crashlytics());
The device is SAMSUNG SM-G313 HZ, running 4.4.2
I've reported to their Twitter dev forum, but my post is automarked as spam.
Anybody knows a workaround?
This is the onCreate function:
public void onCreate() {
super.onCreate();
Fabric.with(this, new Crashlytics());
graph = ObjectGraph.create(getModules());
ImageLoaderConfiguration imageLoaderConfiguration =
ImageLoaderConfiguration.
createDefault(getApplicationContext());
ImageLoader.getInstance().init(imageLoaderConfiguration);
MMX.init(this, R.raw.initfile);
MMX.registerListener(new MessageEventListenerForLockScreen(this));
Intent intent = new Intent(getString(R.string.wake_up_key));
MMX.registerWakeupBroadcast(intent);
}
I've already declared fabric in AndroidManifest
<meta-data
android:name="io.fabric.ApiKey"
android:value="mykeyhere_a1cff923b11afaab1be7b005474d99b912b3"/>
Logcat:
10-06 13:31:53.452 16717-16717/funride.android.com.rideshare E/AndroidRuntime: FATAL EXCEPTION: main
10-06 13:31:53.452 16717-16717/funride.android.com.rideshare E/AndroidRuntime: Process: funride.android.com.rideshare, PID: 16717
10-06 13:31:53.452 16717-16717/funride.android.com.rideshare E/AndroidRuntime: java.lang.VerifyError: com/crashlytics/android/core/CrashlyticsCore
10-06 13:31:53.452 16717-16717/funride.android.com.rideshare E/AndroidRuntime: at com.crashlytics.android.Crashlytics.<init>(Crashlytics.java:29)
10-06 13:31:53.452 16717-16717/funride.android.com.rideshare E/AndroidRuntime: at funride.android.com.rideshare.application.CloudBikeApp.onCreate(CloudBikeApp.java:33)
10-06 13:31:53.452 16717-16717/funride.android.com.rideshare E/AndroidRuntime: at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
10-06 13:31:53.452 16717-16717/funride.android.com.rideshare E/AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4593)
10-06 13:31:53.452 16717-16717/funride.android.com.rideshare E/AndroidRuntime: at android.app.ActivityThread.access$1500(ActivityThread.java:151)
10-06 13:31:53.452 16717-16717/funride.android.com.rideshare E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1402)
10-06 13:31:53.452 16717-16717/funride.android.com.rideshare E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:110)
10-06 13:31:53.452 16717-16717/funride.android.com.rideshare E/AndroidRuntime: at android.os.Looper.loop(Looper.java:193)
10-06 13:31:53.452 16717-16717/funride.android.com.rideshare E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5344)
10-06 13:31:53.452 16717-16717/funride.android.com.rideshare E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
10-06 13:31:53.452 16717-16717/funride.android.com.rideshare E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:515)
10-06 13:31:53.452 16717-16717/funride.android.com.rideshare E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
10-06 13:31:53.452 16717-16717/funride.android.com.rideshare E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:676)
10-06 13:31:53.452 16717-16717/funride.android.com.rideshare E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
It may be a conflict with third-party libraries, I had a similar crash when using Retrofit2, because Fabric uses an older version of Retrofit.
It may be that you are using the retrofit 2.0 beta?
Twitter currently uses retrofit 1.8 and won't update until the final release of retrofit 2.0
Discussion that will hopefully be updated when it's fixed can be found here: https://twittercommunity.com/t/java-lang-verifyerror/53974