Binary XML file line #7: Error inflating class fragment - android

i do everything, research every but still not working. i read many page from here but not :(
I tried every solution.
Error logs:
03-20 14:46:49.627: I/Process(1895): Sending signal. PID: 1895 SIG: 9
03-20 14:46:59.608: E/Trace(1937): error opening trace file: No such file or directory (2)
03-20 14:46:59.608: W/Trace(1937): Unexpected value from nativeGetEnabledTags: 0
03-20 14:46:59.608: W/Trace(1937): Unexpected value from nativeGetEnabledTags: 0
03-20 14:46:59.608: W/Trace(1937): Unexpected value from nativeGetEnabledTags: 0
03-20 14:46:59.707: W/Trace(1937): Unexpected value from nativeGetEnabledTags: 0
03-20 14:46:59.707: W/Trace(1937): Unexpected value from nativeGetEnabledTags: 0
03-20 14:47:00.207: D/AndroidRuntime(1937): Shutting down VM
03-20 14:47:00.217: W/dalvikvm(1937): threadid=1: thread exiting with uncaught exception (group=0xb5dcc908)
03-20 14:47:00.327: E/AndroidRuntime(1937): FATAL EXCEPTION: main
03-20 14:47:00.327: E/AndroidRuntime(1937): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.panetest/com.example.panetest.PaneTest}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
03-20 14:47:00.327: E/AndroidRuntime(1937): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
03-20 14:47:00.327: E/AndroidRuntime(1937): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-20 14:47:00.327: E/AndroidRuntime(1937): at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-20 14:47:00.327: E/AndroidRuntime(1937): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-20 14:47:00.327: E/AndroidRuntime(1937): at android.os.Handler.dispatchMessage(Handler.java:99)
03-20 14:47:00.327: E/AndroidRuntime(1937): at android.os.Looper.loop(Looper.java:137)
03-20 14:47:00.327: E/AndroidRuntime(1937): at android.app.ActivityThread.main(ActivityThread.java:5039)
03-20 14:47:00.327: E/AndroidRuntime(1937): at java.lang.reflect.Method.invokeNative(Native Method)
03-20 14:47:00.327: E/AndroidRuntime(1937): at java.lang.reflect.Method.invoke(Method.java:511)
03-20 14:47:00.327: E/AndroidRuntime(1937): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-20 14:47:00.327: E/AndroidRuntime(1937): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-20 14:47:00.327: E/AndroidRuntime(1937): at dalvik.system.NativeStart.main(Native Method)
03-20 14:47:00.327: E/AndroidRuntime(1937): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
03-20 14:47:00.327: E/AndroidRuntime(1937): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
03-20 14:47:00.327: E/AndroidRuntime(1937): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
03-20 14:47:00.327: E/AndroidRuntime(1937): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
03-20 14:47:00.327: E/AndroidRuntime(1937): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
03-20 14:47:00.327: E/AndroidRuntime(1937): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
03-20 14:47:00.327: E/AndroidRuntime(1937): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
03-20 14:47:00.327: E/AndroidRuntime(1937): at android.app.Activity.setContentView(Activity.java:1881)
03-20 14:47:00.327: E/AndroidRuntime(1937): at com.example.panetest.PaneTest.onCreate(PaneTest.java:16)
03-20 14:47:00.327: E/AndroidRuntime(1937): at android.app.Activity.performCreate(Activity.java:5104)
03-20 14:47:00.327: E/AndroidRuntime(1937): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
03-20 14:47:00.327: E/AndroidRuntime(1937): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
03-20 14:47:00.327: E/AndroidRuntime(1937): ... 11 more
03-20 14:47:00.327: E/AndroidRuntime(1937): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.example.panetest.FirstPane: make sure class name exists, is public, and has an empty constructor that is public
03-20 14:47:00.327: E/AndroidRuntime(1937): at android.app.Fragment.instantiate(Fragment.java:592)
03-20 14:47:00.327: E/AndroidRuntime(1937): at android.app.Fragment.instantiate(Fragment.java:560)
03-20 14:47:00.327: E/AndroidRuntime(1937): at android.app.Activity.onCreateView(Activity.java:4709)
03-20 14:47:00.327: E/AndroidRuntime(1937): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
03-20 14:47:00.327: E/AndroidRuntime(1937): ... 21 more
03-20 14:47:00.327: E/AndroidRuntime(1937): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.panetest.FirstPane" on path: /data/app/com.example.panetest-1.apk
03-20 14:47:00.327: E/AndroidRuntime(1937): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
03-20 14:47:00.327: E/AndroidRuntime(1937): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-20 14:47:00.327: E/AndroidRuntime(1937): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-20 14:47:00.327: E/AndroidRuntime(1937): at android.app.Fragment.instantiate(Fragment.java:582)
03-20 14:47:00.327: E/AndroidRuntime(1937): ... 24 more
activity_pane_test.xml
<android.support.v4.widget.SlidingPaneLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/slidingpanelayout">
<fragment android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.example.panetest.FirstPane"
android:id="#+id/fragment_firstpane"/>
<fragment android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.example.panetest.SecondPane"
android:id="#+id/fragment_secondpane"/>
PaneTest.java
package com.example.panetest;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.widget.SlidingPaneLayout;
import android.view.Menu;
public class PaneTest extends Activity {
SlidingPaneLayout pane; #Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pane_test);
pane = (SlidingPaneLayout) findViewById(R.id.slidingpanelayout);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.pane_test, menu);
return true;
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.panetest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="13"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.panetest.PaneTest"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Please anyone provide solution.

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.panetest.FirstPane" on path: /data/app/com.example.panetest-1.apk
Your project does not seem to have a class FirstPane in package com.example.panetest.

Related

Android Eclipse application, compatible error

I'm developing Android app just for hobby, and I made an app, when I test on my phones works well, I tested on :
Alcatel idol OneTouch 2S ( 6050y )
Sony Xperia Tipo ( st21i )
Samsung Galaxy Ace
Asus Memo Pad HD7 (Tablet)
Works great, and no error at all...
but when I tested on Samsung Galaxy S4, and Samsung Galaxy S3..
no background music (on Galaxy S4 and no background pics are shown ), and what I click I see report error message so application crushes..
Error Log:
03-20 16:55:07.366: D/skia(29417): --- allocation failed for scaled bitmap
03-20 16:55:07.376: D/AndroidRuntime(29417): Shutting down VM
03-20 16:55:07.376: W/dalvikvm(29417): threadid=1: thread exiting with uncaught exception (group=0x4206c700)
03-20 16:55:07.391: E/AndroidRuntime(29417): FATAL EXCEPTION: main
03-20 16:55:07.391: E/AndroidRuntime(29417): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.**********a/com.***********a.Info}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2295)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.app.ActivityThread.access$700(ActivityThread.java:159)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.os.Handler.dispatchMessage(Handler.java:99)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.os.Looper.loop(Looper.java:176)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.app.ActivityThread.main(ActivityThread.java:5419)
03-20 16:55:07.391: E/AndroidRuntime(29417): at java.lang.reflect.Method.invokeNative(Native Method)
03-20 16:55:07.391: E/AndroidRuntime(29417): at java.lang.reflect.Method.invoke(Method.java:525)
03-20 16:55:07.391: E/AndroidRuntime(29417): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
03-20 16:55:07.391: E/AndroidRuntime(29417): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
03-20 16:55:07.391: E/AndroidRuntime(29417): at dalvik.system.NativeStart.main(Native Method)
03-20 16:55:07.391: E/AndroidRuntime(29417): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.view.LayoutInflater.createView(LayoutInflater.java:626)
03-20 16:55:07.391: E/AndroidRuntime(29417): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.view.LayoutInflater.inflate(LayoutInflater.java:470)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
03-20 16:55:07.391: E/AndroidRuntime(29417): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:361)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.app.Activity.setContentView(Activity.java:1956)
03-20 16:55:07.391: E/AndroidRuntime(29417): at *********.Info.onCreate(Info.java:16)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.app.Activity.performCreate(Activity.java:5372)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
03-20 16:55:07.391: E/AndroidRuntime(29417): ... 11 more
03-20 16:55:07.391: E/AndroidRuntime(29417): Caused by: java.lang.reflect.InvocationTargetException
03-20 16:55:07.391: E/AndroidRuntime(29417): at java.lang.reflect.Constructor.constructNative(Native Method)
03-20 16:55:07.391: E/AndroidRuntime(29417): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.view.LayoutInflater.createView(LayoutInflater.java:600)
03-20 16:55:07.391: E/AndroidRuntime(29417): ... 23 more
03-20 16:55:07.391: E/AndroidRuntime(29417): Caused by: java.lang.OutOfMemoryError
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:832)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.content.res.Resources.loadDrawable(Resources.java:2988)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.view.View.<init>(View.java:3563)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.view.ViewGroup.<init>(ViewGroup.java:475)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.widget.LinearLayout.<init>(LinearLayout.java:176)
03-20 16:55:07.391: E/AndroidRuntime(29417): at android.widget.LinearLayout.<init>(LinearLayout.java:172)
03-20 16:55:07.391: E/AndroidRuntime(29417): ... 26 more
Please any help ?

App not finding resources after locale change in Android

I am working on a project which requires on the fly language changes. I am attempting to set the desired Locale but as soon as I do, the app crashes complaining that it cannot find Resources (things like R.layout.* R.drawable.*)
This is the code I am using to set the new Locale:
String languageToLoad = "es";
Locale locale = new Locale(languageToLoad);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,
getBaseContext().getResources().getDisplayMetrics());
Edit: added log
E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.flavorburst.mcdonalds/com.flavorburst.mcdonalds.MyActivity}: android.view.InflateException: Binary XML file line #25: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #25: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
at android.app.Activity.setContentView(Activity.java:1881)
at com.flavorburst.mcdonalds.MyActivity.onCreate(MyActivity.java:106)
at android.app.Activity.performCreate(Activity.java:5104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: String array resource ID #0x7f08001e
at android.content.res.Resources.getStringArray(Resources.java:451)
at com.flavorburst.mcdonalds.NavigationDrawerFragment.onCreate(NavigationDrawerFragment.java:91)
at android.app.Fragment.performCreate(Fragment.java:1673)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:854)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1035)
at android.app.FragmentManagerImpl.addFragment(FragmentManager.java:1137)
at android.app.Activity.onCreateView(Activity.java:4717)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
at android.app.Activity.setContentView(Activity.java:1881)
at com.flavorburst.application.MyActivity.onCreate(MyActivity.java:106)
at android.app.Activity.performCreate(Activity.java:5104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
This error:
Caused by: android.content.res.Resources$NotFoundException: String array resource ID #0x7f08001e at android.content.res.Resources.getStringArray(Resources.java:451) at com.flavorburst.mcdonalds.NavigationDrawerFragment
refers to a string array that you have defined in one of your XML files, but you forgot to create the string array value in /values/array.xml. For example, in one of your XML files, you may have specified a string array value of "arrayNames", but you forgot to declare it in /values/array.xml like:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="arrayNames"/>
</resources>
So, at runtime, the compiler will complain that it cannot find "arrayNames" in /values/array.xml. Hence, the error you got when you run your app.
Have you tried to clean and rebuild your project? If you are using eclipse got to Project -> Clean. And then build again. If you are using Android Studio and gradle, type the following command line on a terminal:
./gradlew clean
or
use the Build -> Rebuild Project

Spinner on an ActionBar issue on a Dialog Activity

Hi I have an activity that shows a dialog form an standard layout.
android:theme="#android:style/Theme.Holo.Light.Dialog"/>
I was trying to add a simple spinner to the actionbar but I am having issues and error in the line getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST).
When I change my theme to a common activity it works perfect.
This are the errors showed by the logcat:
3114-3114/org.PeteProto E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.PeteProto/org.PeteProto.Detail}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5039)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at org.PeteProto.Detail.onCreate(Detail.java:30)
at android.app.Activity.performCreate(Activity.java:5104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
... 11 more

App Crashes after moving an image button! android

So my app Ive been developing lately is going great, and I just updated the image in the background of the app. Well the app was working right before I tweaked an image button to line up with this image I made. Right after I moved it, the app will no longer work and I have tried everything with no success. Here is the xml of the activity
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/title_screen"
tools:context=".TitleScreen" >
<TextView
android:id="#+id/txtCoins"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="18dp"
android:layout_marginTop="11dp"
android:text="000"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#f3c50d"
android:textSize="12sp" />
<ImageButton
android:id="#+id/imageBtnPlay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/txtCoins"
android:layout_centerHorizontal="true"
android:layout_marginTop="51dp"
android:background="#null"
android:src="#drawable/btn_play" />
</RelativeLayout>
EDIT: Here is my logcat
03-20 17:08:29.847: W/dalvikvm(28692): threadid=1: thread exiting with uncaught exception (group=0x416282a0)
03-20 17:08:29.852: E/AndroidRuntime(28692): FATAL EXCEPTION: main
03-20 17:08:29.852: E/AndroidRuntime(28692): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ChonBonStudios.Tidbits/com.ChonBonStudios.Tidbits.TitleScreen}: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.ImageButton
03-20 17:08:29.852: E/AndroidRuntime(28692): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
03-20 17:08:29.852: E/AndroidRuntime(28692): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
03-20 17:08:29.852: E/AndroidRuntime(28692): at android.app.ActivityThread.access$600(ActivityThread.java:140)
03-20 17:08:29.852: E/AndroidRuntime(28692): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
03-20 17:08:29.852: E/AndroidRuntime(28692): at android.os.Handler.dispatchMessage(Handler.java:99)
03-20 17:08:29.852: E/AndroidRuntime(28692): at android.os.Looper.loop(Looper.java:137)
03-20 17:08:29.852: E/AndroidRuntime(28692): at android.app.ActivityThread.main(ActivityThread.java:4898)
03-20 17:08:29.852: E/AndroidRuntime(28692): at java.lang.reflect.Method.invokeNative(Native Method)
03-20 17:08:29.852: E/AndroidRuntime(28692): at java.lang.reflect.Method.invoke(Method.java:511)
03-20 17:08:29.852: E/AndroidRuntime(28692): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
03-20 17:08:29.852: E/AndroidRuntime(28692): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
03-20 17:08:29.852: E/AndroidRuntime(28692): at dalvik.system.NativeStart.main(Native Method)
03-20 17:08:29.852: E/AndroidRuntime(28692): Caused by: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.ImageButton
03-20 17:08:29.852: E/AndroidRuntime(28692): at com.ChonBonStudios.Tidbits.TitleScreen.onCreate(TitleScreen.java:20)
03-20 17:08:29.852: E/AndroidRuntime(28692): at android.app.Activity.performCreate(Activity.java:5191)
03-20 17:08:29.852: E/AndroidRuntime(28692): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
03-20 17:08:29.852: E/AndroidRuntime(28692): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
03-20 17:08:29.852: E/AndroidRuntime(28692): ... 11 more
android.widget.TextView cannot be cast to android.widget.ImageButton
You are casting to the wrong class in your activity change TextView to ImageButton somewhere in com.ChonBonStudios.Tidbits.TitleScreen class.
this is a common issue. Clean your project by selecting Project - Clean and it will work. And like gpasci said, check if you initialize your fields correctly
If I understand you correctly you just have switched the position of the TextView and the ImageButton in the layout, no code changes.
Try to simply clean the project and/or restart Eclipse. Sometimes I had a similar problem where the auto-generated Ids were just ouf of sync and that's the reason why a findViewById(R.id.imageBtnPlay) actually returns the TextView.

Fatal Exception Main (unable to start activity) Caused by: java.lang.NullPointerException

i'm noob at android and i face a strange exception when i try to settext or setcolor or anything that was working before
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
pageNoSeek = (SeekBar)findViewById(R.id.pageNoSeekBar);
pageNotv = (TextView)findViewById(R.id.pageNotv);
nextButton=(ImageButton)findViewById(R.id.leftButton);
backButton=(ImageButton)findViewById(R.id.rightButton);
mainText = (TextView)findViewById(R.id.mainText);
mainText.setTextColor(Color.RED);
}
as shown in code above there's nothing unusual .. acutally i've used this same code before at another machine .. it gives error at setTextColor or setTextSize if i added it..
> 03-20 07:55:17.552: E/AndroidRuntime(1718): FATAL EXCEPTION: main
03-20 07:55:17.552: E/AndroidRuntime(1718): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thedarkdimension.keyboardShortcut/com.thedarkdimension.keyboardShortcut.StoryViewController}: java.lang.NullPointerException
03-20 07:55:17.552: E/AndroidRuntime(1718): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
03-20 07:55:17.552: E/AndroidRuntime(1718): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-20 07:55:17.552: E/AndroidRuntime(1718): at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-20 07:55:17.552: E/AndroidRuntime(1718): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-20 07:55:17.552: E/AndroidRuntime(1718): at android.os.Handler.dispatchMessage(Handler.java:99)
03-20 07:55:17.552: E/AndroidRuntime(1718): at android.os.Looper.loop(Looper.java:137)
03-20 07:55:17.552: E/AndroidRuntime(1718): at android.app.ActivityThread.main(ActivityThread.java:5041)
03-20 07:55:17.552: E/AndroidRuntime(1718): at java.lang.reflect.Method.invokeNative(Native Method)
03-20 07:55:17.552: E/AndroidRuntime(1718): at java.lang.reflect.Method.invoke(Method.java:511)
03-20 07:55:17.552: E/AndroidRuntime(1718): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-20 07:55:17.552: E/AndroidRuntime(1718): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-20 07:55:17.552: E/AndroidRuntime(1718): at dalvik.system.NativeStart.main(Native Method)
03-20 07:55:17.552: E/AndroidRuntime(1718): Caused by: java.lang.NullPointerException
03-20 07:55:17.552: E/AndroidRuntime(1718): at com.thedarkdimension.keyboardShortcut.StoryViewController.getNextPage(StoryViewController.java:95)
03-20 07:55:17.552: E/AndroidRuntime(1718): at com.thedarkdimension.keyboardShortcut.StoryViewController.connectToDB(StoryViewController.java:84)
03-20 07:55:17.552: E/AndroidRuntime(1718): at com.thedarkdimension.keyboardShortcut.StoryViewController.onCreate(StoryViewController.java:47)
03-20 07:55:17.552: E/AndroidRuntime(1718): at android.app.Activity.performCreate(Activity.java:5104)
03-20 07:55:17.552: E/AndroidRuntime(1718): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
03-20 07:55:17.552: E/AndroidRuntime(1718): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
03-20 07:55:17.552: E/AndroidRuntime(1718): ... 11 more
and i can't get it .. can anyone help :)
From you code snippet for onCreate it seems that you have not called setContentView.
For this reason all calls for (X)findViewById(R.id.x); returns null and thus you are getting a Null Pointer Exception when you try to operate on the variables. [mainText is null since the view was not found].
Solution:
Call setContentView first and then initialize your variables and do the remaining stuff

Categories

Resources