Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upHave a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
commented Feb 25, 2016
While adding espresso tests with the androidTest build variant, I came across this error when running via USB on a Google Nexus 4: |
self-assigned this Feb 25, 2016
added this to the BIBLE-V1.1.0 milestone Feb 25, 2016
commented Feb 25, 2016
After spending days on this issue, I found a solution for my symptoms. It appears many people are having the issue with different root causes. Many people had this issue: http://stackoverflow.com/questions/21814825/you-need-to-use-a-theme-appcompat-theme-or-descendant-with-this-activity This is the issue that worked for me: http://stackoverflow.com/questions/28570785/material-design-support-below-lollipop-crashes Changes
|
commented Aug 29, 2017
If you add the android:theme='@style/Theme.AppCompat.Light' to <application> in AndroidManifest.xml file, problem is solving. |
commented Oct 11, 2017
thank u a lot |
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment
Please enable JavaScript in your browser to use all the features on this site.
Status
()
For bugs in Fennec which do not fit into other more specific Fennec components.
RESOLVED WONTFIX
2 years ago
6 months ago
Tracking
({crash, topcrash})
Trunk
---
crash, topcrash
---
Details
(crash signature)
Flags: needinfo?(cnevinchen) → needinfo?(topwu.tw)
Flags: needinfo?(jcheng)
status-firefox56: --- → ?
tracking-firefox55: blocking → +
Closed: 6 months ago
You need to log in before you can comment on or make changes to this bug.
Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upHave a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
commented Jun 30, 2017
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. at android.support.v7.app.AppCompatDelegateImplBase.onCreate(AppCompatDelegateImplBase.java:122) at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:146) at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:59) at com.didi.virtualapk.demo.aidl.BookManagerActivity.onCreate(BookManagerActivity.java:95) at android.app.Activity.performCreate(Activity.java:6302) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) at com.didi.virtualapk.internal.VAInstrumentation.callActivityOnCreate(VAInstrumentation.java:141) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2383) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490) at android.app.ActivityThread.access$900(ActivityThread.java:153) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1358) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5456) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:735) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) |
commented Jun 30, 2017
@MissBears 插件的构建请参考:Demo 工程运行须知 |
commented Jun 30, 2017
可能你的版本比较低吧! |
commented Jun 30, 2017
我也是类似的问题 |
commented Jun 30, 2017
我也是类似的情况 |
commented Jun 30, 2017
360马上也要开源rePlugin 了,看看哪个好用就用哪个吧 |
commented Jun 30, 2017
plugindemo的BookManagerActivity是继承的AppCompatActivity,但是在manifest里面没有使用v7包的主题,把BookManagerActivity改成直接继承Activity就好了 |
commented Jun 30, 2017
我连主题都删了,都不行了啊,我用FragmentActivity的啊 |
commented Jun 30, 2017
@moziqi @xns1001@tokiii@MissBears 插件需要执行 gradle assemblePlugin 任务来进行插件处理并生成apk, 不能用常规方式生成的apk让宿主去加载。 |
referenced this issue Jul 27, 2017
ClosedUnknown element under <manifest>: #89
referenced this issue Mar 16, 2018
ClosedJNI ERROR (app bug) local reference table overflow max=512 #192
referenced this issue Nov 26, 2018
OpenJNI ERROR (app bug): local reference table overflow (max=512) #279
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment
Android Studio 0.4.5
Android documentation for creating custom dialog boxes: http://developer.android.com/guide/topics/ui/dialogs.html
If you want a custom dialog, you can instead display an Activity as a dialog instead of using the Dialog APIs. Simply create an activity and set its theme to Theme.Holo.Dialog in
the
the
<activity>
manifest element:However, when I tried this I get the following exception:
I am supporting the following, and I can’t using something greater than 10 for the min:
In my styles I have the following:
And in my manifest I have this for the activity:
Creating the dialog box like this was something I was hopping to do, as I have already completed the layout.
Can anyone tell me how I can get around this problem?
Answers:
The reason you are having this problem is because the activity you are trying to apply the dialog theme to is extending
ActionBarActivity
which requires the AppCompat
theme to be applied. Update: Extending
AppCompatActivity
would also have this problem In this case, change the Java inheritance from
ActionBarActivity
to Activity
and leave the dialog theme in the manifest as it is, a non Theme.AppCompat
value The general rule is that if you want your code to support older versions of Android, it should have the
AppCompat
theme and the java code should extend AppCompatActivity
. If you have *an activity that doesn’t need this support, such as you only care about the latest versions and features of Android, you can apply any theme to it but the java code must extend plain old Activity
.NOTE: When change from
AppCompatActivity
(or a subclass, ActionBarActivity
), to Activity
, must also change the various calls with “support” to the corresponding call without “support”. So, instead of getSupportFragmentManager
, call getFragmentManager
.Answers:
All you need to do is add
android:theme='@style/Theme.AppCompat.Light'
to your application tag in the AndroidManifest.xml
file.Answers:
Copying answer from @MarkKeen in the comments above as I had the same problem.
I had the error stated at the top of the post and happened after I added an alert dialog. I have all the relevant style information in the manifest. My problem was cured by changing a context reference in the alert builder – I changed:
to:
And no more problems.
Answers:
min sdk is 10.
ActionBar
is available from api level 11. So for 10 you would be using AppCompat
from the support library for which you need to use Theme.AppCompat
or descendant of the same.Use
More info @
I might have misread op post.
Seems op wants a Dialog with a Activity Theme. So as already suggest by Bobbake4 extend
Activity
instead of ActionBarActivity
.Also have a look @ Dialog Attributes in the below link
Answers:
Questions:
This is what fixed it for me: instead of specifying the theme in manifest, I defined it in
onCreate
for each activity that extends ActionBarActivity
:Here
MyAppTheme
is a descendant of Theme.AppCompat
, and is defined in xml. Note that the theme must be set before super.onCreate
and setContentView
.Answers:
Questions:
I was experiencing this problem even though my Theme was an
AppCompat
Theme and my Activity was an AppCompatActivity
(or Activity
, as suggested on other’s answers). So I cleaned, rebuild and rerun the project. (Build -> Clean Project ; Build -> Rebuild Project ; Run -> Run)
It may seem dumb, but now it works great!
Just hope it helps!
Answers:
If you need to extend ActionBarActivity you need on your style.xml:
If you set as main theme of your application as android:Theme.Material.Light instead of AppTheme.Base then you’ll get an “IllegalStateException:You need to use a Theme.AppCompat theme (or descendant) with this activity” error.
Answers:
I had such crash on Samsung devices even though the activity did use Theme.AppCompat.
The root cause was related to weird optimizations on Samsung side:
The root cause was related to weird optimizations on Samsung side:
My solution was just removing
android:launchMode='singleTask'
Answers:
I had the same problem, but it solved when i put this on manifest: android:theme=”@style/Theme.AppCompat.
Answers:
In my case i have no values-v21 file in my res directory. Then i created it and added in it following codes:
Answers:
Change the theme of the desired Activity. Its work for me
Answers:
In Android manifest just change theme of activity to AppTheme as follow code snippet
Answers:
You have came to this because you want to apply Material Design in your theme style in previous sdk versions to 21.
ActionBarActivity
requires AppTheme
so if you also want to prevent your own customization about your AppTheme, only you have to change in your styles.xml (previous to sdk 21) so this way, can inherit for an App Compat theme.for this:
Answers:
Change your theme style parent to
This worked for me …
Answers:
Questions:
You have many solutions to that error.
- You should use Activity or FragmentActivity instead of ActionbarActivity or AppCompatActivity
- If you want use ActionbarActivity or AppCompatActivity, you should change in styles.xmlTheme.Holo.xxxx to Theme.AppCompat.Light (if necessary add to DarkActionbar)
If you don’t need advanced attributes about action bar or AppCompat you don’t need to use Actionbar or AppCompat.
Answers:
Your Activity is extending ActionBarActivity which requires the AppCompat.theme to be applied.
Change from ActionBarActivity to Activity or FragmentActivity, it will solve the problem.
Change from ActionBarActivity to Activity or FragmentActivity, it will solve the problem.
If you use no Action bar then :
Answers:
for me was solution to use ContextThemeWrapper:
from Android – How to create FAB programmatically?
Answers:
This is when you want a AlertDialog in a Fragment
Answers:
My Activity with SectionsPagerAdapter and ViewPager & Fragment
Answers:
This solution worked for me.
Design library depends on the Support v4 and AppCompat Support Libraries, so don’t use different version for appcompat and design library in gradle.
use
instead of
Answers:
NOTE: I had intended this as an answer, but further testing reveals it still fails when built using maven from the command line, so I’ve had to edit it to be a problem! ?
Unlike the Mangonel and the Trebuchet, it lacked alot of power however. When releasing the Ballista, the built up tension in the rope would send a large arrow towards the enemy with extreme accuracy.
Two wood arms are attached to a piece of rope and the rope is attached to a winch that is pulled back, bending the arms of the weapon. The Ballista is very similar to a crossbow in the sense that they function very similarly.
In my case when I got this error I was already using a AppCompat Theme and the error didn’t make much sense.
I was in the process of mavenizing my android build. I had already dependencies on the apklib and jar versions of app compat, thus:
Now, when I import the maven project and build and run from IntelliJ it’s fine.
But when I build and deploy and run from the command line with maven I still get this exception.
Answers:
In Android Studio:
Add support library to the gradle file and sync.
Edit build.gradle(Module:app) to have dependencies as follows:
Add support library to the gradle file and sync.
Edit build.gradle(Module:app) to have dependencies as follows:
My support Library version is 23.1.1; Use your support library version as applicable.
Answers:
For me none of the above answers worked even after I had
Theme.AppCompat
as my base theme for the application. I was using com.android.support:design:24.1.0
So I just changed the version to 24.1.1
. After the gradle sync, Its working again and the exception went away. Seems to me the issue was with gradle build.Just putting this here in case other answers don’t work for some people.
Answers:
For me issue resolved by changing the inheritance from AppCompatActivity to Activity in my customDialog class. No changes required in manifest for Theme.Dialog.
Answers:
Quick solution.
Change your base theme parent in styles.xml
Replace from
to
Answers:
I had this problem as well and what I did to fix it, AND still use the Holo theme was to take these steps:
first I replaced this import:
with this one:
then changed my extension from:
to this:
And also had to change this import:
to this import:
Also, when building the actual dialog box, at the point where you add the dialog box’s message I had to change it from
builder.setMessage(theMessage)
to builder.setTitle(theMessage)
and then you can use your theme tag in the manifest at the activity level:
and lastly, (unless you have other classes in your project that has to use v7 appCompat) you can either clean and rebuild your project or delete this entry in the gradle build file at the app level:
if you have other classes in your project that has to use v7 appCompat then just clean and rebuild the project.
Answers:
For me, the Android SDK didn’t seem to be able to find the styles definition. Everything was wired correctly and doing a simple project clean fixed it for me.
Android Studio 0.4.5
Android documentation for creating custom dialog boxes: http://developer.android.com/guide/topics/ui/dialogs.html
If you want a custom dialog, you can instead display an Activity as a dialog instead of using the Dialog APIs. Simply create an activity and set its theme to Theme.Holo.Dialog in the
<activity>
manifest element:However, when I tried this I get the following exception:
I am supporting the following, and I can't using something greater than 10 for the min:
In my styles I have the following:
And in my manifest I have this for the activity:
Creating the dialog box like this was something I was hopping to do, as I have already completed the layout.
Can anyone tell me how I can get around this problem?
Zoe16.1k99 gold badges6262 silver badges9494 bronze badges
ant2009ant2009190121121 gold badges329329 silver badges514514 bronze badges
44 Answers
12 next
The reason you are having this problem is because the activity you are trying to apply the dialog theme to is extending
ActionBarActivity
which requires the AppCompat
theme to be applied. Update: Extending
AppCompatActivity
would also have this problem In this case, change the Java inheritance from
ActionBarActivity
to Activity
and leave the dialog theme in the manifest as it is, a non Theme.AppCompat
value The general rule is that if you want your code to support older versions of Android, it should have the
AppCompat
theme and the java code should extend AppCompatActivity
. If you have *an activity that doesn't need this support, such as you only care about the latest versions and features of Android, you can apply any theme to it but the java code must extend plain old Activity
.NOTE: When change from
Bobbake4Bobbake4AppCompatActivity
(or a subclass, ActionBarActivity
), to Activity
, must also change the various calls with 'support' to the corresponding call without 'support'. So, instead of getSupportFragmentManager
, call getFragmentManager
.19.9k88 gold badges4848 silver badges8383 bronze badges
All you need to do is add
android:theme='@style/Theme.AppCompat.Light'
to your application tag in the AndroidManifest.xml
file.Caused By Java.lang.illegalstateexception You Need To Use A Theme.appcompat Theme
Michele La Ferla5,0331010 gold badges3434 silver badges6262 bronze badges
iustingiusting5,95511 gold badge1010 silver badges2626 bronze badges
Copying answer from @MarkKeen in the comments above as I had the same problem.
I had the error stated at the top of the post and happened after I added an alert dialog. I have all the relevant style information in the manifest. My problem was cured by changing a context reference in the alert builder - I changed:
to:
And no more problems.
Pang7,1021616 gold badges6868 silver badges107107 bronze badges
A.K.A.K.2,65611 gold badge1313 silver badges1717 bronze badges
min sdk is 10.
ActionBar
is available from api level 11. So for 10 you would be using AppCompat
from the support library for which you need to use Theme.AppCompat
or descendant of the same.Use
Or if you dont want action bar at the top
More info @
Edit:
I might have misread op post.
Seems op wants a Dialog with a Activity Theme. So as already suggested by Bobbake4 extend
Activity
instead of ActionBarActivity
.Also have a look @ Dialog Attributes in the link below
shareef5,40188 gold badges4545 silver badges7272 bronze badges
RaghunandanRaghunandan120k1919 gold badges198198 silver badges237237 bronze badges
DarushDarush5,28133 gold badges3434 silver badges4444 bronze badges
I was experiencing this problem even though my Theme was an
AppCompat
Theme and my Activity was an AppCompatActivity
(or Activity
, as suggested on other's answers). So I cleaned, rebuild and rerun the project. (Build -> Clean Project ; Build -> Rebuild Project ; Run -> Run)
It may seem dumb, but now it works great!
Just hope it helps!
Geraldo NetoGeraldo Neto
This is what fixed it for me: instead of specifying the theme in manifest, I defined it in
onCreate
for each activity that extends ActionBarActivity
:Here
k29k29MyAppTheme
is a descendant of Theme.AppCompat
, and is defined in xml. Note that the theme must be set before super.onCreate
and setContentView
.1,56011 gold badge1212 silver badges1313 bronze badges
Yamen NassifYamen Nassif1,54611 gold badge1212 silver badges3232 bronze badges
In my case i have no values-v21 file in my res directory. Then i created it and added in it following codes:
Ali GürelliAli Gürelli1,24411 gold badge1515 silver badges2121 bronze badges
If you need to extend ActionBarActivity you need on your style.xml:
If you set as main theme of your application as android:Theme.Material.Light instead of AppTheme.Base then you’ll get an “IllegalStateException:You need to use a Theme.AppCompat theme (or descendant) with this activity” error.
JonasOliveiraJonasOliveira
Change the theme of the desired Activity. This works for me:
sharma_kunalsharma_kunal
I had such crash on Samsung devices even though the activity did use Theme.AppCompat.The root cause was related to weird optimizations on Samsung side:
My solution was just removing
android:launchMode='singleTask'
goRGongoRGon
I had the same problem, but it solved when i put this on manifest: android:theme='@style/Theme.AppCompat.
Marc BaduqMarc Baduq
Ali AkramAli Akram88511 gold badge99 silver badges1818 bronze badges
for me was solution to use ContextThemeWrapper:
from Android - How to create FAB programmatically?
Community♦
PeterPeter
In my case such issue was appear when i tried to show Dialog.The problem was in context, I've use getBaseContext() which theoretically should return Activity context, but appears its not, or it return context before any Theme applied.
So I just replaced getBaseContexts() with 'this', and now it work as expected.
Vitaliy AVitaliy A2,22711 gold badge2222 silver badges2727 bronze badges
I had an activity with theme
<android:theme='@android:style/Theme.Dialog'>
used for showing dialog in my appWidget and i had same problemi solved this error by changing activity code like below:
Elyas NateghElyas Nategh
Change your theme style parent to
This worked for me ..
FazalFazal2,29911 gold badge1010 silver badges2020 bronze badges
You have many solutions to that error.
- You should use Activity or FragmentActivity instead of ActionbarActivity or AppCompatActivity
- If you want use ActionbarActivity or AppCompatActivity, you should change in styles.xmlTheme.Holo.xxxx to Theme.AppCompat.Light (if necessary add to DarkActionbar)
If you don't need advanced attributes about action bar or AppCompat you don't need to use Actionbar or AppCompat.
KalogluKaloglu86011 gold badge1212 silver badges2626 bronze badges
In Android manifest just change theme of activity to AppTheme as follow code snippet
maxhb6,24177 gold badges2222 silver badges4444 bronze badges
shikhashikha
This is when you want a AlertDialog in a Fragment
Avinash_ksAvinash_ks
I had this problem as well and what I did to fix it, AND still use the Holo theme was to take these steps:
first I replaced this import:
with this one:
then changed my extension from:
to this:
And also had to change this import:
to this import:
and then you can use your theme tag in the manifest at the activity level:
and lastly, (unless you have other classes in your project that has to use v7 appCompat) you can either clean and rebuild your project or delete this entry in the gradle build file at the app level:
if you have other classes in your project that has to use v7 appCompat then just clean and rebuild the project.
WraithiousWraithious
You have came to this because you want to apply Material Design in your theme style in previous sdk versions to 21.
ActionBarActivity
requires AppTheme
so if you also want to prevent your own customization about your AppTheme, only you have to change in your styles.xml (previous to sdk 21) so this way, can inherit for an App Compat theme.for this:
danigonlineadanigonlinea71811 gold badge99 silver badges1616 bronze badges
user1501382user1501382
Your Activity is extending ActionBarActivity which requires the AppCompat.theme to be applied.Change from ActionBarActivity to Activity or FragmentActivity, it will solve the problem.
If you use no Action bar then :
Md Imran ChoudhuryMd Imran Choudhury3,71711 gold badge2828 silver badges3838 bronze badges
In my experiences the problem was the context where I showed my dialog.Inside a button click I instantiate an AlertDialog in this way:
But the context was not correct and caused the error. I've changed it using the application context in this way:
In declare section:
in the onCreate method
And finally in the code where I need the AlertDialog:
This is the solution for me.
DanteDante
Quick solution.
Change your base theme parent in styles.xml
Replace from
to
KalogluKaloglu
86011 gold badge1212 silver badges2626 bronze badges
This solution worked for me.
Design library depends on the Support v4 and AppCompat Support Libraries, so don't use different version for appcompat and design library in gradle.
use
instead of
kiran boghrakiran boghra2,25211 gold badge1414 silver badges2121 bronze badges
I was getting this same problem. Because i was creating custom navigation drawer. But i forget to mention theme in my manifest like this
android:theme='@style/Theme.AppCompat.NoActionBar'
As soon i added the above the theme to my manifest it resolved the problem.
Azhar oswsAzhar osws
For me none of the above answers worked even after I had
Theme.AppCompat
as my base theme for the application. I was using com.android.support:design:24.1.0
So I just changed the version to 24.1.1
. After the gradle sync, Its working again and the exception went away. Seems to me the issue was with some older versions of design support libraries.Just putting this here in case other answers don't work for some people.
Sharp EdgeSharp Edge3,24622 gold badges1919 silver badges3333 bronze badges
12 next
protected by Community♦Apr 2 '16 at 21:18
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
Would you like to answer one of these unanswered questions instead?