I am following a tutorial on how to make a launcher but for some reason when I add this line of code to my main activity with in the manifest the app crashes saying that my app has stopped
android:theme="#android:style/Theme.Holo.Wallpaper.NoTitleBar"
10-18 15:04:25.245 18122-18122/com.example.harrops.h20droidlauncher E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.harrops.h20droidlauncher, PID: 18122
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.harrops.h20droidlauncher/com.example.harrops.h20droidlauncher.HomeLayout}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2400)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2458)
at android.app.ActivityThread.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1305)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5598)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:309)
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:278)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:252)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
at com.example.harrops.h20droidlauncher.HomeLayout.onCreate(HomeLayout.java:13)
at android.app.Activity.performCreate(Activity.java:5459)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2458)
at android.app.ActivityThread.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1305)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5598)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
if I remove the line of code the app runs just fine.
Any help would be great. Thanks as always in advance.
To change the Background use:
android:background=" "
You selected a wallpaper.
Try this instead
android:background="#b6db49">
Below you have said that you want to use the theme. So you have to go in the manifest and edit the theme there which is
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo.Wallpaper.NoTitleBar">
If You've begun Your project in Android Studio by default main activity extends
ActionBarActivity which requires the AppCompat theme. Change the Java inheritance from ActionBarActivity to Activity and leave the theme in the manifest as it is. Or use AppCompat theme.
Related
java.lang.NoClassDefFoundError: org.brickred.socialauth.SocialAuthManager
at org.brickred.socialauth.android.SocialAuthAdapter.authorize(SocialAuthAdapter.java:544)
at com.example.koolkrew.MainActivity.initSocialAdapter(MainActivity.java:90)
at com.example.koolkrew.MainActivity.bindWidgetEvents(MainActivity.java:55)
at com.example.koolkrew.MainActivity.onCreate(MainActivity.java:41)
at android.app.Activity.performCreate(Activity.java:5451)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
at android.app.ActivityThread.access$900(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Download socialauth-android.jar from following link: http://www.java2s.com/Code/JarDownload/socialauth/socialauth-android.jar.zip
And if still getting the same error then You just need to define a new activity in AndroidManifest.xml file.
Put the below code inside ---- tag of your manifest file.
<uses-library android:name="org.brickred.socialauth.android.SocialAuthAdapter" />
I'm trying to create a transparent activity so I give the activity the following style:
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
I don't know why but it crashes the app.
Any idea why?
EDIT: this is my logcat, i'm a newbie so I don't know much about debugging it.
05-14 06:25:08.919 1218-1307/system_process I/ActivityManager﹕ START u0 {cmp=com.myapp.enterprise/.GreenViewActivity} from uid 10057 on display 0
05-14 06:25:08.924 1218-1265/system_process W/AudioTrack﹕ AUDIO_OUTPUT_FLAG_FAST denied by client
05-14 06:25:08.959 6744-6744/com.myapp.enterprise D/AndroidRuntime﹕ Shutting down VM
05-14 06:25:08.959 6744-6744/com.myapp.enterprise E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.myapp.enterprise, PID: 6744
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.enterprise/com.myapp.enterprise.GreenViewActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5257)
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:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
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:113)
at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:146)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:59)
at com.myapp.enterprise.GreenViewActivity.onCreate(GreenViewActivity.java:13)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5257)
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:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
05-14 06:25:08.965 1218-7949/system_process W/ActivityManager﹕ Force finishing activity 1 com.myapp.enterprise/.GreenViewActivity
05-14 06:25:08.978 1218-7949/system_process W/ActivityManager﹕ Force finishing activity 2 com.myapp.enterprise/.NoteActivity
05-14 06:25:09.083 1218-2572/system_process I/OpenGLRenderer﹕ Initialized EGL, version 1.4
05-14 06:25:09.110 1218-2572/system_process W/EGL_emulation﹕ eglSurfaceAttrib not implemented
05-14 06:25:09.110 1218-2572/system_process W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0x9d932880, error=EGL_SUCCESS
05-14 06:25:09.490 1218-1236/system_process W/ActivityManager﹕ Activity pause timeout for ActivityRecord{5ebb3cd u0 com.myapp.enterprise/.GreenViewActivity t546 f}
You require to use parent="#style/Theme.AppCompat" as parent instead of current parent="android:Theme"
just Use this theme in your activity in Menifest xml file to create Transparent Activity
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen"
if you are extending your activity from AppCompactActivity or ActionBarActivity the you must your parent theme
<style name="Theme.Transparent" parent="#style/Theme.AppCompat.Light.DarkActionBar">
for whole application or for just activty
I am developing an expandable list view application on which i want to add action bar.
It seems for action bar visibility I need to extend ActionBarActivity Class, but to run my Expandable list activity I should extend activity class.
So, I changed following code
from
public class Time extends Activity {
to
public class Time extends ActionBarActivity {
assuming following hierarchy
java.lang.Object
↳ android.content.Context
↳ android.content.ContextWrapper
↳ android.view.ContextThemeWrapper
↳ android.app.Activity
↳ android.support.v4.app.FragmentActivity
↳ android.support.v7.app.ActionBarActivity
But,when i run my application now i get null pointer exception at super.onCreate(savedInstanceState);
Please check log here:
12-19 00:10:48.995 14128-14128/sudharshanapps.clock E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: sudharshanapps.clock, PID: 14128
java.lang.RuntimeException: Unable to start activity ComponentInfo{sudharshanapps.clock/sudharshanapps.clock.Time}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2198)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
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 sudharshanapps.clock.Time.onCreate(Time.java:247)
at android.app.Activity.performCreate(Activity.java:5248)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Could you please suggest, what is missing here or any references or ideas where to look for.
Changed Manifest file from
<application
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="Time across Globe"
android:theme="#style/AppTheme" >
to
<application
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="Time across Globe"
android:theme="#style/Theme.AppCompat.Light" >
It solved the issue
When I create a new navigation drawer activity in Android Studio, the basic example runs perfectly. I've changed a few lines to integrate Material Design and v4 - v7 support, and consequently the app breaks. I also included in some lines of basic code from Firebase that does a simple auth with Google+.
Starting the app returns a runtime exception, and "error inflating class fragment" message.
I'm guessing that the NPE is coming from the view not being inflated, but I have no idea how that is happening.
Below is my logcat, my activities, and my layouts. Any help or guidance would be appreciated.
Logcat:
11-24 16:29:26.735 6127-6127/com.starkenglish E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.starkenglish, PID: 6127
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.starkenglish/com.starkenglish.MainActivity}: android.view.InflateException: Binary XML file line #19: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2212)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2271)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1205)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5146)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:796)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #19: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:343)
at android.app.Activity.setContentView(Activity.java:1929)
at com.starkenglish.MainActivity.onCreate(MainActivity.java:110)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2169)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2271)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1205)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5146)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:796)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.starkenglish.NavigationDrawerFragment.onCreateView(NavigationDrawerFragment.java:101)
at android.app.Fragment.performCreateView(Fragment.java:1700)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:866)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1040)
at android.app.FragmentManagerImpl.addFragment(FragmentManager.java:1142)
at android.app.Activity.onCreateView(Activity.java:4786)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:343)
at android.app.Activity.setContentView(Activity.java:1929)
at com.starkenglish.MainActivity.onCreate(MainActivity.java:110)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2169)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2271)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1205)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5146)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:796)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
at dalvik.system.NativeStart.main(Native Method)
To keep this post clean, I have posted my code as GIST on github.
MainActivity.java:
https://gist.github.com/markbratanov/a94291edaf02b0b236d3
NavigationDrawerFragment.java:
https://gist.github.com/markbratanov/92bb583f14604b68b34d
fragment_main.xml:
https://gist.github.com/markbratanov/d1bda8b3c99d47e0257c
fragment_navigation_drawer.xml:
https://gist.github.com/markbratanov/5f5e334e40e253736e49
If there is missing code / files please let me know and I'll include it immediately.
your main activity extends FragmentActivity, and in order to get an actionBar
which is listed in your NavigationDrawerFragment line 101, just like the error says
mDrawerListView.setAdapter(new ArrayAdapter<String>(
getActivity().getActionBar().getThemedContext(), <== this is the null part
android.R.layout.simple_list_item_activated_1,
android.R.id.text1,
new String[]{
getString(R.string.title_section1),
getString(R.string.title_section2),
getString(R.string.title_section3),
}));
you need to extend the ActionBarActivity from the app compat
quote from the documentation
ActionBarCompat contains one Activity class which all of your Activity
classes should extend: ActionBarActivity. This class itself extends
from FragmentActivity so you can continue to use Fragments in your
application.
When I run my app, I am taken to an Edit Configuration screen and it says, "Default Activity not found". I believe I got this error after I tried to import a library from another app I have.
I keep getting this error even after I rebuilt my project, restarted IntelliJ IDEA and file > Invalidated Cache. I did set a main activity so I'm not sure why it says that.
Here's the exception:
Process: com.example.Device, PID: 24635
java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.IllegalStateException: Unable to get package info for com.example.Device; is package not installed?
at android.app.LoadedApk.makeApplication(LoadedApk.java:507)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4301)
at android.app.ActivityThread.access$1500(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: Unable to get package info for com.example.Device; is package not installed?
at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:368)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:321)
at android.app.LoadedApk.makeApplication(LoadedApk.java:500)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4301)
at android.app.ActivityThread.access$1500(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
I can run my application anyway even though the "configuration is not set" and all is well.
Are you capable to "select" the activity from the list of activities ?
There is an activity defined in AndroidManifest as the main activity (launcher)
If it shows Edit configuration Screen and Error as "Default activity not found" then go to your manifest file and in activity tag which will be your launching activity name should be like "packageName.MainActivty" instead of ".MainActivity" see below code for your reference
<activity
android:name="com.your.package.name.YourActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>