This question already has answers here:
App crashing when setting new content view
(3 answers)
Closed 8 years ago.
Edit: Definite Duplicate
My app is crashing when I try to call the setContentView() method to my layout.
I tried a few solutions and when I removed my styles for my buttons the error went away.
It seems that the styles I am using for my buttons is causing this.
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="#drawable/lights_over" />
<item android:state_focused="true" android:drawable="#drawable/lights_over" />
<item android:state_selected = "true" android:drawable = "#drawable/lights_over" />
<item android:drawable = "#drawable/lights" android:id="#+id/button_L"/>
</selector>
My LogCat
01-09 12:04:24.161: D/dalvikvm(20682): GC_BEFORE_OOM freed 9K, 5% free 122880K/129056K, paused 20ms, total 20ms
01-09 12:04:24.161: E/dalvikvm-heap(20682): Out of memory on a 9027940-byte allocation.
01-09 12:04:24.171: E/AndroidRuntime(20682): FATAL EXCEPTION: main
01-09 12:04:24.171: E/AndroidRuntime(20682): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.androidexample.broadcastreceiver/com.androidexample.broadcastreceiver.StartMenu}: android.view.InflateException: Binary XML file line #79: Error inflating class <unknown>
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2246)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2296)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.app.ActivityThread.access$700(ActivityThread.java:151)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.os.Handler.dispatchMessage(Handler.java:99)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.os.Looper.loop(Looper.java:137)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.app.ActivityThread.main(ActivityThread.java:5293)
01-09 12:04:24.171: E/AndroidRuntime(20682): at java.lang.reflect.Method.invokeNative(Native Method)
01-09 12:04:24.171: E/AndroidRuntime(20682): at java.lang.reflect.Method.invoke(Method.java:511)
01-09 12:04:24.171: E/AndroidRuntime(20682): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
01-09 12:04:24.171: E/AndroidRuntime(20682): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
01-09 12:04:24.171: E/AndroidRuntime(20682): at dalvik.system.NativeStart.main(Native Method)
01-09 12:04:24.171: E/AndroidRuntime(20682): Caused by: android.view.InflateException: Binary XML file line #79: Error inflating class <unknown>
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.view.LayoutInflater.createView(LayoutInflater.java:619)
01-09 12:04:24.171: E/AndroidRuntime(20682): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:666)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.view.LayoutInflater.rInflate(LayoutInflater.java:760)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
01-09 12:04:24.171: E/AndroidRuntime(20682): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:327)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.app.Activity.setContentView(Activity.java:1928)
01-09 12:04:24.171: E/AndroidRuntime(20682): at com.androidexample.broadcastreceiver.StartMenu.onCreate(StartMenu.java:20)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.app.Activity.performCreate(Activity.java:5250)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2210)
01-09 12:04:24.171: E/AndroidRuntime(20682): ... 11 more
01-09 12:04:24.171: E/AndroidRuntime(20682): Caused by: java.lang.reflect.InvocationTargetException
01-09 12:04:24.171: E/AndroidRuntime(20682): at java.lang.reflect.Constructor.constructNative(Native Method)
01-09 12:04:24.171: E/AndroidRuntime(20682): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.view.LayoutInflater.createView(LayoutInflater.java:593)
01-09 12:04:24.171: E/AndroidRuntime(20682): ... 25 more
01-09 12:04:24.171: E/AndroidRuntime(20682): Caused by: java.lang.OutOfMemoryError
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:817)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.content.res.Resources.loadDrawable(Resources.java:2854)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.content.res.Resources.getDrawable(Resources.java:1521)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:173)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:921)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:858)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.content.res.Resources.loadDrawable(Resources.java:2839)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.view.View.<init>(View.java:3460)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.widget.TextView.<init>(TextView.java:791)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.widget.Button.<init>(Button.java:107)
01-09 12:04:24.171: E/AndroidRuntime(20682): at android.widget.Button.<init>(Button.java:103)
01-09 12:04:24.171: E/AndroidRuntime(20682): ... 28 more
Does anyone know how to resolve this issue?
It's an OutOfMemoryError, so it seems that the drawable your are using in your selector are to heavy.
Related
I want to start the navigation drawer activity when pressing a button.
Here's my code:-
public void logdinScreen(View view) {
codeM = (EditText)findViewById(R.id.editText2);
if(codeM.getText().toString().equals("0000"))
{
//Toast.makeText(getBaseContext(),"LogedIn",Toast.LENGTH_LONG).show();
Intent intent2 = new Intent(OTPScreen.this,HomeScreen.class);
startActivity(intent2);
}
}
Android Manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.harpreet.btp_project" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".OTPScreen"
android:label="#string/title_activity_otpscreen" >
</activity>
<activity
android:name=".HomeScreen"
android:label="#string/title_activity_home_screen" >
</activity>
</application>
</manifest>
logcat:-
05-23 01:08:23.999 3326-3326/? D/dalvikvm﹕ Late-enabling CheckJNI
05-23 01:08:24.059 3326-3326/? E/Trace﹕ error opening trace file: No such file or directory (2)
05-23 01:08:24.059 3326-3326/? D/ActivityThread﹕ setTargetHeapUtilization:0.25
05-23 01:08:24.059 3326-3326/? D/ActivityThread﹕ setTargetHeapIdealFree:8388608
05-23 01:08:24.059 3326-3326/com.example.harpreet.btp_project D/ActivityThread﹕ setTargetHeapConcurrentStart:2097152
05-23 01:08:24.239 3326-3326/com.example.harpreet.btp_project D/dalvikvm﹕ GC_FOR_ALLOC freed 70K, 35% free 12967K/19779K, paused 21ms, total 22ms
05-23 01:08:24.259 3326-3326/com.example.harpreet.btp_project I/dalvikvm-heap﹕ Grow heap (frag case) to 29.330MB for 8294416-byte allocation
05-23 01:08:24.289 3326-3328/com.example.harpreet.btp_project D/dalvikvm﹕ GC_CONCURRENT freed 1K, 25% free 21066K/27911K, paused 12ms+1ms, total 35ms
05-23 01:08:24.429 3326-3326/com.example.harpreet.btp_project D/libEGL﹕ loaded /system/lib/egl/libEGL_adreno200.so
05-23 01:08:24.449 3326-3326/com.example.harpreet.btp_project D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_adreno200.so
05-23 01:08:24.459 3326-3326/com.example.harpreet.btp_project D/libEGL﹕ loaded /system/lib/egl/libGLESv2_adreno200.so
05-23 01:08:24.469 3326-3326/com.example.harpreet.btp_project I/Adreno200-EGL﹕ <qeglDrvAPI_eglInitialize:299>: EGL 1.4 QUALCOMM build: (Merge)
Build Date: 07/09/13 Tue
Local Branch: AU_41
Remote Branch:
Local Patches:
Reconstruct Branch:
05-23 01:08:24.529 3326-3326/com.example.harpreet.btp_project D/OpenGLRenderer﹕ Enabling debug mode 0
05-23 01:08:39.009 3326-3326/com.example.harpreet.btp_project D/AndroidRuntime﹕ Shutting down VM
05-23 01:08:39.009 3326-3326/com.example.harpreet.btp_project W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x413e2378)
05-23 01:08:39.029 3326-3326/com.example.harpreet.btp_project E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.harpreet.btp_project/com.example.harpreet.btp_project.HomeScreen}: android.view.InflateException: Binary XML file line #19: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2071)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096)
at android.app.ActivityThread.access$600(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:4787)
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:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
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: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 android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
at com.example.harpreet.btp_project.HomeScreen.onCreate(HomeScreen.java:39)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2035)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096)
at android.app.ActivityThread.access$600(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:4787)
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:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.example.harpreet.btp_project.NavigationDrawerFragment.onCreateView(NavigationDrawerFragment.java:100)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1789)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:924)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1116)
at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1218)
at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2170)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:300)
at android.support.v7.app.AppCompatDelegateImplV7.callActivityOnCreateView(AppCompatDelegateImplV7.java:816)
at android.support.v7.app.AppCompatDelegateImplV11.callActivityOnCreateView(AppCompatDelegateImplV11.java:72)
at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:804)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:675)
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 android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
at com.example.harpreet.btp_project.HomeScreen.onCreate(HomeScreen.java:39)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2035)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096)
at android.app.ActivityThread.access$600(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:4787)
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:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.NativeStart.main(Native Method)
The app is working untill i press that button. When i comment the intent part and uncomment the Toast part, it is working perfect.
Am i doing it wrong?
I am trying to reuse csipsimple as a library. and calling ui which is present in the same library
My xml file looks like
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".DialerActivity" >
<view
class="com.csipsimple.widgets.Dialpad"
android:id="#+id/dialPad"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:paddingBottom="10dip"
android:paddingLeft="5dip"
android:paddingRight="5dip" />
</LinearLayout>
My activity from which i am calling the
package com.*****.payphone;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class DialerActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dialer);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_dialer, menu);
return true;
}
}
and stack trace for the same is I don't understand what have i done wrong
03-28 18:52:18.847: I/ActivityThread(16221): Pub com.csipsimple.db: com.csipsimple.db.DBProvider
03-28 18:52:18.870: D/dalvikvm(16221): GC_CONCURRENT freed 152K, 2% free 9116K/9296K, paused 8ms+6ms, total 71ms
03-28 18:52:18.894: V/DummySetUp(16206): <sip:****#*****.net> IwYzK5IbKJv8DQT 1
03-28 18:52:18.956: D/AndroidRuntime(16206): Shutting down VM
03-28 18:52:18.956: W/dalvikvm(16206): threadid=1: thread exiting with uncaught exception (group=0x41f27930)
03-28 18:52:18.964: E/AndroidRuntime(16206): FATAL EXCEPTION: main
03-28 18:52:18.964: E/AndroidRuntime(16206): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.novanet.payphone/com.*****.payphone.DialerActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class com.csipsimple.widgets.Dialpad
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.os.Handler.dispatchMessage(Handler.java:99)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.os.Looper.loop(Looper.java:137)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.app.ActivityThread.main(ActivityThread.java:5039)
03-28 18:52:18.964: E/AndroidRuntime(16206): at java.lang.reflect.Method.invokeNative(Native Method)
03-28 18:52:18.964: E/AndroidRuntime(16206): at java.lang.reflect.Method.invoke(Method.java:511)
03-28 18:52:18.964: E/AndroidRuntime(16206): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-28 18:52:18.964: E/AndroidRuntime(16206): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-28 18:52:18.964: E/AndroidRuntime(16206): at dalvik.system.NativeStart.main(Native Method)
03-28 18:52:18.964: E/AndroidRuntime(16206): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class com.csipsimple.widgets.Dialpad
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
03-28 18:52:18.964: E/AndroidRuntime(16206): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.app.Activity.setContentView(Activity.java:1881)
03-28 18:52:18.964: E/AndroidRuntime(16206): at com.novanet.payphone.DialerActivity.onCreate(DialerActivity.java:12)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.app.Activity.performCreate(Activity.java:5104)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
03-28 18:52:18.964: E/AndroidRuntime(16206): ... 11 more
03-28 18:52:18.964: E/AndroidRuntime(16206): Caused by: java.lang.reflect.InvocationTargetException
03-28 18:52:18.964: E/AndroidRuntime(16206): at java.lang.reflect.Constructor.constructNative(Native Method)
03-28 18:52:18.964: E/AndroidRuntime(16206): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
03-28 18:52:18.964: E/AndroidRuntime(16206): ... 22 more
03-28 18:52:18.964: E/AndroidRuntime(16206): Caused by: android.view.InflateException: Binary XML file line #31: Error inflating class android.widget.ImageButton
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
03-28 18:52:18.964: E/AndroidRuntime(16206): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.view.LayoutInflater.inflate(LayoutInflater.java:459)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
03-28 18:52:18.964: E/AndroidRuntime(16206): at com.csipsimple.widgets.Dialpad.<init>(Dialpad.java:105)
03-28 18:52:18.964: E/AndroidRuntime(16206): ... 25 more
03-28 18:52:18.964: E/AndroidRuntime(16206): Caused by: java.lang.reflect.InvocationTargetException
03-28 18:52:18.964: E/AndroidRuntime(16206): at java.lang.reflect.Constructor.constructNative(Native Method)
03-28 18:52:18.964: E/AndroidRuntime(16206): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
03-28 18:52:18.964: E/AndroidRuntime(16206): ... 33 more
03-28 18:52:18.964: E/AndroidRuntime(16206): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f01000f a=2}
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.content.res.Resources.loadDrawable(Resources.java:1927)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.view.View.<init>(View.java:3328)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.widget.ImageView.<init>(ImageView.java:114)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.widget.ImageButton.<init>(ImageButton.java:87)
03-28 18:52:18.964: E/AndroidRuntime(16206): at android.widget.ImageButton.<init>(ImageButton.java:83)
03-28 18:52:18.964: E/AndroidRuntime(16206): ... 36 more
My Library project is outside my main project which is in package com.*.payphone and the lisbrary project being used is com.csipsimple.widget.Dialpad
have you tried to use <com.csipsimple.widgets.Dialpad instead of
<view
class="com.csipsimple.widgets.Dialpad"
?
You should define your custom view in XML as below:
<com.csipsimple.widgets.Dialpad
android:id="#+id/dialPad"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:paddingBottom="10dip"
android:paddingLeft="5dip"
android:paddingRight="5dip" />
Make sure your theme extends one of the ActionBarSherlock themes. The dialpad buttons use a background from ABS. See this similar issue.
My reports provide me this error but I can't understand how is it possible?
java.lang.RuntimeException: Unable to start activity ComponentInfo{net.aviascanner.aviascanner/net.aviascanner.aviascanner.ui.activities.GetCitiesActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2753)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2769)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3905)
at android.app.ActivityThread.access$2600(ActivityThread.java:129)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2121)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:4717)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:513)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:853)
at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:262)
at net.aviascanner.aviascanner.ui.activities.GetCitiesActivity.onCreate(GetCitiesActivity.java:115)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2717)
... 12 more
Caused by: java.lang.reflect.InvocationTargetException
at android.widget.EditText.<init>(EditText.java:51)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
... 25 more
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/selector_edittext.xml from drawable resource ID #0x7f0200c4
at android.content.res.Resources.loadDrawable(Resources.java:1725)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:1901)
at android.widget.TextView.<init>(TextView.java:440)
at android.widget.EditText.<init>(EditText.java:55)
... 29 more
Caused by: java.lang.NullPointerException
at android.graphics.drawable.DrawableContainer$DrawableContainerState.addChild(DrawableContainer.java:349)
at android.graphics.drawable.StateListDrawable$StateListState.addStateSet(StateListDrawable.java:265)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:173)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:796)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:737)
at android.content.res.Resources.loadDrawable(Resources.java:1722)
... 33 more
android.view.InflateException: Binary XML file line #11: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:513)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:853)
at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:262)
at net.aviascanner.aviascanner.ui.activities.GetCitiesActivity.onCreate(GetCitiesActivity.java:115)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2717)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2769)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3905)
at android.app.ActivityThread.access$2600(ActivityThread.java:129)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2121)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:4717)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at android.widget.EditText.<init>(EditText.java:51)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
... 25 more
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/selector_edittext.xml from drawable resource ID #0x7f0200c4
at android.content.res.Resources.loadDrawable(Resources.java:1725)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:1901)
at android.widget.TextView.<init>(TextView.java:440)
at android.widget.EditText.<init>(EditText.java:55)
... 29 more
Caused by: java.lang.NullPointerException
at android.graphics.drawable.DrawableContainer$DrawableContainerState.addChild(DrawableContainer.java:349)
at android.graphics.drawable.StateListDrawable$StateListState.addStateSet(StateListDrawable.java:265)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:173)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:796)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:737)
at android.content.res.Resources.loadDrawable(Resources.java:1722)
... 33 more
java.lang.reflect.InvocationTargetException
at android.widget.EditText.<init>(EditText.java:51)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:853)
at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:262)
at net.aviascanner.aviascanner.ui.activities.GetCitiesActivity.onCreate(GetCitiesActivity.java:115)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2717)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2769)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3905)
at android.app.ActivityThread.access$2600(ActivityThread.java:129)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2121)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:4717)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/selector_edittext.xml from drawable resource ID #0x7f0200c4
at android.content.res.Resources.loadDrawable(Resources.java:1725)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:1901)
at android.widget.TextView.<init>(TextView.java:440)
at android.widget.EditText.<init>(EditText.java:55)
... 29 more
Caused by: java.lang.NullPointerException
at android.graphics.drawable.DrawableContainer$DrawableContainerState.addChild(DrawableContainer.java:349)
at android.graphics.drawable.StateListDrawable$StateListState.addStateSet(StateListDrawable.java:265)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:173)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:796)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:737)
at android.content.res.Resources.loadDrawable(Resources.java:1722)
... 33 more
android.content.res.Resources$NotFoundException: File res/drawable/selector_edittext.xml from drawable resource ID #0x7f0200c4
at android.content.res.Resources.loadDrawable(Resources.java:1725)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:1901)
at android.widget.TextView.<init>(TextView.java:440)
at android.widget.EditText.<init>(EditText.java:55)
at android.widget.EditText.<init>(EditText.java:51)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:853)
at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:262)
at net.aviascanner.aviascanner.ui.activities.GetCitiesActivity.onCreate(GetCitiesActivity.java:115)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2717)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2769)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3905)
at android.app.ActivityThread.access$2600(ActivityThread.java:129)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2121)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:4717)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.graphics.drawable.DrawableContainer$DrawableContainerState.addChild(DrawableContainer.java:349)
at android.graphics.drawable.StateListDrawable$StateListState.addStateSet(StateListDrawable.java:265)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:173)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:796)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:737)
at android.content.res.Resources.loadDrawable(Resources.java:1722)
... 33 more
java.lang.NullPointerException
at android.graphics.drawable.DrawableContainer$DrawableContainerState.addChild(DrawableContainer.java:349)
at android.graphics.drawable.StateListDrawable$StateListState.addStateSet(StateListDrawable.java:265)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:173)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:796)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:737)
at android.content.res.Resources.loadDrawable(Resources.java:1722)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:1901)
at android.widget.TextView.<init>(TextView.java:440)
at android.widget.EditText.<init>(EditText.java:55)
at android.widget.EditText.<init>(EditText.java:51)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:853)
at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:262)
at net.aviascanner.aviascanner.ui.activities.GetCitiesActivity.onCreate(GetCitiesActivity.java:115)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2717)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2769)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3905)
at android.app.ActivityThread.access$2600(ActivityThread.java:129)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2121)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:4717)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
I have found this error in my application also. In my application I solved my problem by making the copies of the drawables in all the folders of the drawables i.e. drawable-ldpi, drawable-mdpi, drawable-hdpi, drawable-xhdpi. This works correctly in my application. Hope this will solve your problem if u have not kept the drawables into all the provided drawable folders.
I have changed my app so the user can have 2 different styles to the whole app. I have updated the Custom Tabs I created so they link to a Style which in turns (depending on the selected style) links to a Selector xml in drawable (ie what to show for selected or unselected).
Running this gives me the following Errors
01-09 10:46:28.701: E/AndroidRuntime(375): FATAL EXCEPTION: main
01-09 10:46:28.701: E/AndroidRuntime(375): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myappname/com.myappname.RoundSelect}: android.view.InflateException: Binary XML file line #11: Error inflating class <unknown>
01-09 10:46:28.701: E/AndroidRuntime(375): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
01-09 10:46:28.701: E/AndroidRuntime(375): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
01-09 10:46:28.701: E/AndroidRuntime(375): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-09 10:46:28.701: E/AndroidRuntime(375): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
01-09 10:46:28.701: E/AndroidRuntime(375): at android.os.Handler.dispatchMessage(Handler.java:99)
01-09 10:46:28.701: E/AndroidRuntime(375): at android.os.Looper.loop(Looper.java:123)
01-09 10:46:28.701: E/AndroidRuntime(375): at android.app.ActivityThread.main(ActivityThread.java:3683)
01-09 10:46:28.701: E/AndroidRuntime(375): at java.lang.reflect.Method.invokeNative(Native Method)
01-09 10:46:28.701: E/AndroidRuntime(375): at java.lang.reflect.Method.invoke(Method.java:507)
01-09 10:46:28.701: E/AndroidRuntime(375): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-09 10:46:28.701: E/AndroidRuntime(375): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-09 10:46:28.701: E/AndroidRuntime(375): at dalvik.system.NativeStart.main(Native Method)
01-09 10:46:28.701: E/AndroidRuntime(375): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class <unknown>
01-09 10:46:28.701: E/AndroidRuntime(375): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
01-09 10:46:28.701: E/AndroidRuntime(375): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
01-09 10:46:28.701: E/AndroidRuntime(375): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
01-09 10:46:28.701: E/AndroidRuntime(375): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
01-09 10:46:28.701: E/AndroidRuntime(375): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
01-09 10:46:28.701: E/AndroidRuntime(375): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
01-09 10:46:28.701: E/AndroidRuntime(375): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
01-09 10:46:28.701: E/AndroidRuntime(375): at com.myappname.RoundSelect.createTabView(RoundSelect.java:234)
01-09 10:46:28.701: E/AndroidRuntime(375): at com.myappname.RoundSelect.setupTab(RoundSelect.java:223)
01-09 10:46:28.701: E/AndroidRuntime(375): at com.myappname.RoundSelect.setupCustomTabs(RoundSelect.java:215)
01-09 10:46:28.701: E/AndroidRuntime(375): at com.myappname.RoundSelect.onCreate(RoundSelect.java:90)
01-09 10:46:28.701: E/AndroidRuntime(375): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-09 10:46:28.701: E/AndroidRuntime(375): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
01-09 10:46:28.701: E/AndroidRuntime(375): ... 11 more
01-09 10:46:28.701: E/AndroidRuntime(375): Caused by: java.lang.reflect.InvocationTargetException
01-09 10:46:28.701: E/AndroidRuntime(375): at java.lang.reflect.Constructor.constructNative(Native Method)
01-09 10:46:28.701: E/AndroidRuntime(375): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
01-09 10:46:28.701: E/AndroidRuntime(375): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
01-09 10:46:28.701: E/AndroidRuntime(375): ... 23 more
01-09 10:46:28.701: E/AndroidRuntime(375): Caused by: android.content.res.Resources$NotFoundException: File res/drawable/custom_tab_text_selector_black.xml from drawable resource ID #0x7f020023
01-09 10:46:28.701: E/AndroidRuntime(375): at android.content.res.Resources.loadDrawable(Resources.java:1697)
01-09 10:46:28.701: E/AndroidRuntime(375): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
01-09 10:46:28.701: E/AndroidRuntime(375): at android.view.View.<init>(View.java:1951)
01-09 10:46:28.701: E/AndroidRuntime(375): at android.widget.TextView.<init>(TextView.java:344)
01-09 10:46:28.701: E/AndroidRuntime(375): at android.widget.TextView.<init>(TextView.java:337)
01-09 10:46:28.701: E/AndroidRuntime(375): ... 26 more
01-09 10:46:28.701: E/AndroidRuntime(375): Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #7: <item> tag requires a 'drawable' attribute or child tag defining a drawable
01-09 10:46:28.701: E/AndroidRuntime(375): at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:167)
01-09 10:46:28.701: E/AndroidRuntime(375): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:787)
01-09 10:46:28.701: E/AndroidRuntime(375): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:728)
01-09 10:46:28.701: E/AndroidRuntime(375): at android.content.res.Resources.loadDrawable(Resources.java:1694)
01-09 10:46:28.701: E/AndroidRuntime(375): ... 30 more
Code for the Custombackground
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/tabsLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
style="?custom_tab_background_selector">
<TextView
android:id="#+id/customTabsText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?custom_tab_text_selector">
</TextView>
</LinearLayout>
Method that is calling this
private static View createTabView(Context pContext, String pTabTitleText) {
View view = LayoutInflater.from(pContext).inflate(R.layout.custom_tabs_background, null);
TextView tv = (TextView) view.findViewById(R.id.customTabsText);
tv.setText(pTabTitleText);
return view;
}
The rest is just a xml Theme that points to a Selector XML which in turns points to some drawble xml files. Here is the Selector XML
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Active tab -->
<item
android:state_selected="true"
android:state_focused="false"
android:state_pressed="false"
android:drawable="#drawable/custom_tab_background_selected_black" />
<!-- Inactive tab -->
<item
android:state_selected="false"
android:state_focused="false"
android:state_pressed="false"
android:drawable="#drawable/custom_tab_background_unselected_black" />
<!-- Pressed tab -->
<item
android:state_pressed="true"
android:drawable="#android:color/transparent" />
<!-- Selected tab (using d-pad) -->
<item
android:state_focused="true"
android:state_selected="true"
android:state_pressed="false"
android:drawable="#android:color/transparent" />
</selector>
Any ideas on why I am getting this error would be great. Thanks for you time
It appears I tracked it down.
the background of the tab I was using android:background=.... but was also using the same for the colour of the text and it should have been android:textColour=....
all works now. Sorry for the confusion
I have the following layout:
<TextView
android:id = "#+id/HRNoninTextBox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/exitbtn"
android:text="Heart Rate"
android:textSize = "20sp"/>
<EditText
android:id="#+id/labelNoninHeartRate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00"
android:layout_alignParentRight="true">
</EditText>
from the code i refer to these views, form my activity, in this way:
TextView tvHr= (TextView)findViewById(R.id.HRNoninTextBox);
EditText etHr = (EditText)findViewById(R.id.labelNoninHeartRate);
the first one does not produce any error, while the second statement produce the following error:
01-09 13:24:57.599: W/dalvikvm(28816): threadid=1: thread exiting with uncaught exception (group=0x4001e578)
01-09 13:24:57.619: E/AndroidRuntime(28816): FATAL EXCEPTION: main
01-09 13:24:57.619: E/AndroidRuntime(28816): java.lang.RuntimeException: Unable to start activity ComponentInfo{aid.assistant233/aid.assistant233.AidAssistant233Activity}: java.lang.ClassCastException: android.widget.TextView
01-09 13:24:57.619: E/AndroidRuntime(28816): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
01-09 13:24:57.619: E/AndroidRuntime(28816): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
01-09 13:24:57.619: E/AndroidRuntime(28816): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-09 13:24:57.619: E/AndroidRuntime(28816): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
01-09 13:24:57.619: E/AndroidRuntime(28816): at android.os.Handler.dispatchMessage(Handler.java:99)
01-09 13:24:57.619: E/AndroidRuntime(28816): at android.os.Looper.loop(Looper.java:130)
01-09 13:24:57.619: E/AndroidRuntime(28816): at android.app.ActivityThread.main(ActivityThread.java:3691)
01-09 13:24:57.619: E/AndroidRuntime(28816): at java.lang.reflect.Method.invokeNative(Native Method)
01-09 13:24:57.619: E/AndroidRuntime(28816): at java.lang.reflect.Method.invoke(Method.java:507)
01-09 13:24:57.619: E/AndroidRuntime(28816): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
01-09 13:24:57.619: E/AndroidRuntime(28816): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
01-09 13:24:57.619: E/AndroidRuntime(28816): at dalvik.system.NativeStart.main(Native Method)
01-09 13:24:57.619: E/AndroidRuntime(28816): Caused by: java.lang.ClassCastException: android.widget.TextView
01-09 13:24:57.619: E/AndroidRuntime(28816): at aid.assistant233.AidAssistant233Activity.onCreate(AidAssistant233Activity.java:331)
01-09 13:24:57.619: E/AndroidRuntime(28816): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-09 13:24:57.619: E/AndroidRuntime(28816): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
01-09 13:24:57.619: E/AndroidRuntime(28816): ... 11 more
Where may be the problem?
Step1 : you can clean/build your project as everyone said . but If you are not getting your issue solve by clean/build then check my step2 for it.
Step:2:
I am not Sure But Can you please check your xml file once again?
this also could be happen if You've two elements with the same ID:
<TextView android:text="Hello Ahmedabad:"
android:id="#+id/txtahmedabad"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<EditText android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="#+id/txtahmedabad"
android:text="">
</EditText>
if this is so then Give them different IDs -
it could picking the first one (the TextView) which obviously can't be cast to an EditText.
Hope it will some how help you.