1
I’m having a problem in an application I’m developing in Android Studio, it has the option to insert a Activity (Navigation Drawer Activity) then I inserted it and put a button to call it.
The problem is that when I click the button the application closes. When I create an application of this type (Navigation Drawer Activity) it works perfectly but I am not able to call it in my project already created.
I named it after MenuActivity
and I want to go from login to it by clicking the button.
The method you call Activity:
public void click_chamaMenu(View view){
Intent i = new Intent(Login.this,MenuActivity.class);
startActivity(i);
}
logcat Error:
02-04 15:10:52.814 21392-21392/com.example.celsoribeiro.titanapp E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.celsoribeiro.titanapp, PID: 21392
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.celsoribeiro.titanapp/com.example.celsoribeiro.titanapp.MenuActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2314)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:151)
at android.support.v7.app.ActionBarActivityDelegateBase.onCreate(ActionBarActivityDelegateBase.java:138)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:123)
at com.example.celsoribeiro.titanapp.MenuActivity.onCreate(MenuActivity.java:37)
at android.app.Activity.performCreate(Activity.java:5953)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1128)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
----------
Which logcat to quit? Show code where the error occurs.
– Guilherme Bernal
No error appears, build successfull but the application is terminated.
– celso
The fact that the application has no errors when compiling does not mean that it does not have them when executing. When terminating, a message is shown?
– ramaral
Navigation Drawer is not a Fragment? good if it is a
Activity
even then the problem may be that you did not insert in themanifest.xml
. Or because of what I saw you didn’t create Listener. Yes you put the call in XML in the instructiononClick
, check the java method name if it is the same in xml.– Skywalker
When you close the app, only the message appears: "The Titan App has stopped."
– celso
It is an Activity yes but it has the Navigationdrawerfragment class which is a fragment, but I have entered it in the manifest yes.
– celso
If message appears "The Titan App Has Stopped." then, if you are running the application in Android Studio, the error will be displayed in the logcat. Edit your question and place it there.
– ramaral
I think I got it right here , the line that says : You need to use a Theme.Appcompat Theme (or Descendant) with this Activity. We missed to put the theme of Activity in the manifest, so I put got what I wanted. Thanks to everyone who helped me.
– celso