I wanted to make my own custom preference. But when I start the activity with the PreferenceFragment that contains the custom preference it fails with the following error:
01-13 07:11:26.117 14403-14403/com.laudien.p1xelfehler.batterywarner_pro E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.laudien.p1xelfehler.batterywarner_pro, PID: 14403
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laudien.p1xelfehler.batterywarner_pro/com.laudien.p1xelfehler.batterywarner.Activities.SettingsActivity.SettingsActivity}: android.view.InflateException: Binary XML file line #42: Error inflating class com.laudien.p1xelfehler.batterywarner.Activities.SettingsActivity.SliderPreference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: android.view.InflateException: Binary XML file line #42: Error inflating class com.laudien.p1xelfehler.batterywarner.Activities.SettingsActivity.SliderPreference
at android.preference.GenericInflater.createItem(GenericInflater.java:388)
at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:432)
at android.preference.GenericInflater.rInflate(GenericInflater.java:483)
at android.preference.GenericInflater.rInflate(GenericInflater.java:495)
at android.preference.GenericInflater.inflate(GenericInflater.java:327)
at android.preference.GenericInflater.inflate(GenericInflater.java:264)
at android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:280)
at android.preference.PreferenceFragment.addPreferencesFromResource(PreferenceFragment.java:326)
at com.laudien.p1xelfehler.batterywarner.Activities.SettingsActivity.NewSettingsFragment.onCreate(NewSettingsFragment.java:14)
at android.app.Fragment.performCreate(Fragment.java:2335)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:949)
at android.app.BackStackRecord.setLastIn(BackStackRecord.java:857)
at android.app.BackStackRecord.calculateFragments(BackStackRecord.java:897)
at android.app.BackStackRecord.run(BackStackRecord.java:727)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1578)
at android.app.FragmentController.execPendingActions(FragmentController.java:371)
at android.app.Activity.performStart(Activity.java:6680)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2609)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.NoSuchMethodException: [class android.content.Context, interface android.util.AttributeSet]
at java.lang.Class.getConstructor0(Class.java:2204)
at java.lang.Class.getConstructor(Class.java:1683)
at android.preference.GenericInflater.createItem(GenericInflater.java:378)
at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:432)
at android.preference.GenericInflater.rInflate(GenericInflater.java:483)
at android.preference.GenericInflater.rInflate(GenericInflater.java:495)
at android.preference.GenericInflater.inflate(GenericInflater.java:327)
at android.preference.GenericInflater.inflate(GenericInflater.java:264)
at android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:280)
at android.preference.PreferenceFragment.addPreferencesFromResource(PreferenceFragment.java:326)
at com.laudien.p1xelfehler.batterywarner.Activities.SettingsActivity.NewSettingsFragment.onCreate(NewSettingsFragment.java:14)
at android.app.Fragment.performCreate(Fragment.java:2335)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:949)
at android.app.BackStackRecord.setLastIn(BackStackRecord.java:857)
at android.app.BackStackRecord.calculateFragments(BackStackRecord.java:897)
at android.app.BackStackRecord.run(BackStackRecord.java:727)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1578)
at android.app.FragmentController.execPendingActions(FragmentController.java:371)
at android.app.Activity.performStart(Activity.java:6680)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2609)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
This is my SliderPreference.java:
public class SliderPreference extends Preference {
#Override
protected View onCreateView(ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
return inflater.inflate(R.layout.preference_slider, parent, false);
}
public SliderPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
#Override
protected void onClick() {
super.onClick();
}
}
This is the preference_slider.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/textView_lowBattery"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Title"
android:textSize="18sp" />
<CheckBox
android:id="#+id/checkBox_lowBattery"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/enabled" />
<SeekBar
android:id="#+id/seekBar_lowBattery"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
This is the NewSettingsFragment.java:
public class NewSettingsFragment extends PreferenceFragment {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PreferenceManager.setDefaultValues(getActivity(), R.xml.preferences, false);
addPreferencesFromResource(R.xml.preferences);
}
}
I added the preference in the preference.xml file just like that:
<com.laudien.p1xelfehler.batterywarner.Activities.SettingsActivity.SliderPreference />
Thank you for your help! :)
All right guys, i found the solution for myself.
You just have to use ALL constructors in the custom preference class. Like this:
#RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public SliderPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
public SliderPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public SliderPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public SliderPreference(Context context) {
super(context);
}
Related
I am a beginner and I am doing an Android game which I made the model in Java (on Eclipse).
I'm actually trying to draw a grid, but when I run, I have a java.lang.RuntimeException: Unable to start activity
I don't really understand where the problem is, it says the problem is from the setContentView (R.layout.activity_main).
This is my AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="e.khoig.test2">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
This is where it contains the game and its creation:
public class Game extends Application {
TenGame tenGame;
public void onCreate(){
super.onCreate();
tenGame=new TenGame();
}
TenGame getTenGame(){
return tenGame;
}
}
Then this is my GameView which I draw and do the actions:
public class GameView extends SurfaceView implements SurfaceHolder.Callback{
Game gam;
Paint paint=new Paint();
int canvasWidth;
int cellSize;
public GameView(Context context, AttributeSet attributeSet){
super(context,attributeSet);
getHolder().addCallback(this);
getGam(context);
}
public GameView(Context context){
super(context);
getHolder().addCallback(this);
this.getGam(context);
}
public final void getGam(Context context){
gam=(Game)(context.getApplicationContext());
}
#Override
public void surfaceCreated(SurfaceHolder holder) {
}
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
canvasWidth=width;
cellSize=width/5;
reDraw();
}
public void reDraw(){
Canvas c=getHolder().lockCanvas();
if(c!=null){
this.onDraw(c);
getHolder().unlockCanvasAndPost(c);
}
}
#Override
public boolean onTouchEvent(MotionEvent event) {
int x=(int)event.getX();
int y=(int)event.getY();
int action=event.getAction();
TenGame theGame=gam.getTenGame();
switch(action){
case MotionEvent.ACTION_DOWN:{
theGame.getSelectedGroup();
}
default:
return false;
}
}
#Override
public void surfaceDestroyed(SurfaceHolder holder) {
}
#Override
public void onDraw(Canvas canvas){
paint.reset();
TenGame theGame=gam.getTenGame();
canvas.drawColor(Color.GRAY);
paint.setColor(Color.BLACK);
for(int x=0;x<canvasWidth;x+=cellSize){
canvas.drawLine(x,0,x,canvasWidth,paint);
}
for(int y=0;y<canvasWidth;y+=cellSize){
canvas.drawLine(0,y,canvasWidth,y,paint);
}
paint.setTextSize(50);
paint.setFlags(Paint.ANTI_ALIAS_FLAG);
for(int x=0;x<5;x++){
for(int y=0;y<5;y++){
canvas.drawText("1",(x*cellSize)+11,(cellSize+y*cellSize)-6,paint);
}
}
}
}
And finally my MainActivity:
public class MainActivity extends Activity {
Game gam;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
gam=(Game)this.getApplication();
}
}
And my activity_main.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<e.khoig.test2.GameView
android:id="#+id/gameView"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center"
/>
</LinearLayout>
This is my error message:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: e.khoig.test2, PID: 15920
java.lang.RuntimeException: Unable to start activity ComponentInfo{e.khoig.test2/e.khoig.test2.MainActivity}: android.view.InflateException: Binary XML file line #18: Binary XML file line #18: Error inflating class e.khoig.test2.GameView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2957)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by: android.view.InflateException: Binary XML file line #18: Binary XML file line #18: Error inflating class e.khoig.test2.GameView
Caused by: android.view.InflateException: Binary XML file line #18: Error inflating class e.khoig.test2.GameView
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:461)
at android.app.Activity.setContentView(Activity.java:2737)
at e.khoig.test2.MainActivity.onCreate(MainActivity.java:12)
at android.app.Activity.performCreate(Activity.java:7183)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2910)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to e.khoig.test2.Game
at e.khoig.test2.GameView.getGam(GameView.java:34)
at e.khoig.test2.GameView.<init>(GameView.java:24)
UPDATE :
I resolved my problem, i just had to declare the application in the manifest, thank you for your helps !
The 3rd last line in your stacktrace states that you can't cast application to an instance of your game class.
Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to e.khoig.test2.Game
In your main activity after setContentView could you use getActivity without the this i.e.
gam = (Game) getActivity();
I believe the problem right now could be that you are trying to cast an instance of application to an instance of activity.
Just my two cents.
The stack trace says -
Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to e.khoig.test2.Game
at e.khoig.test2.GameView.getGam(GameView.java:34)
You are doing this -
public final void getGam(Context context){
gam=(Game)(context.getApplicationContext());
}
You should not cast the instance of superclass to subclass. This is leading to your ClassCastException.
This answer gives a better picture.
Hope it helps.
This stack trace shows this
Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to e.khoig.test2.Game
Because this
A extends B
A a = new B() // this is wrong
(B)a//this is wrong
B b = new A() // this is right
(A)b // this is right
You cannot cast the instance of superclass to subclass.
I have an application that uses a fragment view as part of its layout. Within this fragment, I want to instantiate a Paint Canvas where i can do custom drawing.
The problem is, my app crashes when I go to inflate the fragment with the error android.view.InflateException: Binary XML file line #15: Binary XML file line #15: Error inflating class com.example.xxxxx.NeckCanvasOverlay
I'm not sure what's causing my Paint class not to inflate properly. I know there are special rules about how you use findViewById inside a fragment, but I thought I was adhering to them since i'm calling findViewByid on the fragment's view itself (called "v" in my code).
How can I fix this issue?
FragmentNeckDisplayMenu.java (Fragment Class)
public class FragmentNeckDisplayMenu extends Fragment {
private static View v;
private NeckCanvasOverlay neckHUD;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
v = inflater.inflate(R.layout.menu_fragment_neck_display,container,false); //ERROR HERE
NeckCanvasOverlay neckHUD = (NeckCanvasOverlay) v.findViewById(R.id.neckHUD); //paint test
...
return v;
}
}
NeckCanvasOverlay.java (Paint Class)
class NeckCanvasOverlay extends View {
private Paint mPainter;
public NeckCanvasOverlay(Context context) {
super(context);
initView();
}
private void initView(){ //Initializes canvas & paint objects here to save performance
mPainter = new Paint(Paint.ANTI_ALIAS_FLAG);
mPainter.setColor(Color.BLUE);
mPainter.setAlpha(128);
}
#Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawCircle(180, 900, 200, mPainter);
}
}
menu_fragment_neck_display.xml (Fragment's Layout)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="#+id/canvas"
android:background="#drawable/image">
<LinearLayout
android:layout_width="148dp"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="4">
!--Custom view for Canvas here -->
<com.example.xxxxx.NeckCanvasOverlay
android:id="#+id/neckHUD"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/neck_for_menu"/>
</LinearLayout>
<Button
android:id="#+id/menuIcon"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="64dp"
android:text="Menu"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_gravity="bottom"
android:layout_weight="0.5"/>
</LinearLayout>
Full Stack Trace (Edit: Included full trace)
08-06 21:47:24.894 26334-26334/com.example.xxxxx E/ACRA: ACRA caught a InflateException for com.example.xxxxx
android.view.InflateException: Binary XML file line #15: Binary XML file line #15: Error inflating class com.example.gu.NeckCanvasOverlay
at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at com.example.xxxxx.FragmentNeckDisplayMenu.onCreateView(FragmentNeckDisplayMenu.java:32)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1106)
at android.support.v4.view.ViewPager.populate(ViewPager.java:952)
at android.support.v4.view.ViewPager.setOffscreenPageLimit(ViewPager.java:733)
at com.example.xxxxx.PlayFrets.configMenu(PlayFrets.java:150)
at com.example.xxxxx.AsyncTask_NoteFileLoader.onPostExecute(AsyncTask_NoteFileLoader.java:125)
at com.example.xxxxx.AsyncTask_NoteFileLoader.onPostExecute(AsyncTask_NoteFileLoader.java:9)
at android.os.AsyncTask.finish(AsyncTask.java:651)
at android.os.AsyncTask.access$500(AsyncTask.java:180)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class com.example.gu.NeckCanvasOverlay
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:788)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at com.example.xxxxx.FragmentNeckDisplayMenu.onCreateView(FragmentNeckDisplayMenu.java:32)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1106)
at android.support.v4.view.ViewPager.populate(ViewPager.java:952)
at android.support.v4.view.ViewPager.setOffscreenPageLimit(ViewPager.java:733)
at com.example.xxxxx.PlayFrets.configMenu(PlayFrets.java:150)
at com.example.xxxxx.AsyncTask_NoteFileLoader.onPostExecute(AsyncTask_NoteFileLoader.java:125)
at com.example.xxxxx.AsyncTask_NoteFileLoader.onPostExecute(AsyncTask_NoteFileLoader.java:9)
at android.os.AsyncTask.finish(AsyncTask.java:651)
at android.os.AsyncTask.access$500(AsyncTask.java:180)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.gu.NeckCanvasOverlay" on path: DexPathList[[zip file "/data/app/com.example.xxxxx-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.xxxxx-2/lib/arm64, /vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.view.LayoutInflater.createView(LayoutInflater.java:595)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at com.example.xxxxx.FragmentNeckDisplayMenu.onCreateView(FragmentNeckDisplayMenu.java:32)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1106)
at android.support.v4.view.ViewPager.populate(ViewPager.java:952)
at android.support.v4.view.ViewPager.setOffscreenPageLimit(ViewPager.java:733)
at com.example.xxxxx.PlayFrets.configMenu(PlayFrets.java:150)
at com.example.xxxxx.AsyncTask_NoteFileLoader.onPostExecute(AsyncTask_NoteFileLoader.java:125)
at com.example.xxxxx.AsyncTask_NoteFileLoader.onPostExecute(AsyncTask_NoteFileLoader.java:9)
at android.os.AsyncTask.finish(AsyncTask.java:651)
at android.os.AsyncTask.access$500(AsyncTask.java:180)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Suppressed: java.lang.ClassNotFoundException: com.example.gu.NeckCanvasOverlay
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 33 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
08-06 21:47:24.954 26334-27123/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.xxxxx, PID: 26334
android.view.InflateException: Binary XML file line #15: Binary XML file line #15: Error inflating class com.example.gu.NeckCanvasOverlay
at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at com.example.xxxxx.FragmentNeckDisplayMenu.onCreateView(FragmentNeckDisplayMenu.java:32)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1106)
at android.support.v4.view.ViewPager.populate(ViewPager.java:952)
at android.support.v4.view.ViewPager.setOffscreenPageLimit(ViewPager.java:733)
at com.example.xxxxx.PlayFrets.configMenu(PlayFrets.java:150)
at com.example.xxxxx.AsyncTask_NoteFileLoader.onPostExecute(AsyncTask_NoteFileLoader.java:125)
at com.example.xxxxx.AsyncTask_NoteFileLoader.onPostExecute(AsyncTask_NoteFileLoader.java:9)
at android.os.AsyncTask.finish(AsyncTask.java:651)
at android.os.AsyncTask.access$500(AsyncTask.java:180)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class com.example.gu.NeckCanvasOverlay
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:788)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at com.example.xxxxx.FragmentNeckDisplayMenu.onCreateView(FragmentNeckDisplayMenu.java:32)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1106)
at android.support.v4.view.ViewPager.populate(ViewPager.java:952)
at android.support.v4.view.ViewPager.setOffscreenPageLimit(ViewPager.java:733)
at com.example.xxxxx.PlayFrets.configMenu(PlayFrets.java:150)
at com.example.xxxxx.AsyncTask_NoteFileLoader.onPostExecute(AsyncTask_NoteFileLoader.java:125)
at com.example.xxxxx.AsyncTask_NoteFileLoader.onPostExecute(AsyncTask_NoteFileLoader.java:9)
at android.os.AsyncTask.finish(AsyncTask.java:651)
at android.os.AsyncTask.access$500(AsyncTask.java:180)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.gu.NeckCanvasOverlay" on path: DexPathList[[zip file "/data/app/com.example.xxxxx-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.xxxxx-2/lib/arm64, /vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.view.LayoutInflater.createView(LayoutInflater.java:595)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at com.example.xxxxx.FragmentNeckDisplayMenu.onCreateView(FragmentNeckDisplayMenu.java:32)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1106)
at android.support.v4.view.ViewPager.populate(ViewPager.java:952)
at android.support.v4.view.ViewPager.setOffscreenPageLimit(ViewPager.java:733)
at com.example.xxxxx.PlayFrets.configMenu(PlayFrets.java:150)
at com.example.xxxxx.AsyncTask_NoteFileLoader.onPostExecute(AsyncTask_NoteFileLoader.java:125)
The immediate problem is a ClassNotFoundException. When dealing with custom Views in a layout, a common cause for this is an incorrect class name in the layout XML, which seems to have been the issue here. Ensure that the XML tag has the correct, fully-qualified class name for the custom View class, which will be the class's package from the top of the file, prepended to the class name.
Additionally, Views inflated from your layout will be instantiated with a two-argument constructor that takes a Context and an AttributeSet. Your class definition needs to have at least that constructor to allow inflation, or you'll get a NoSuchMethodException. Also, it would make things a little simpler if you'd chain your constructors, if you're just extending View. For example:
public NeckCanvasOverlay(Context context) {
this(context, null);
}
public NeckCanvasOverlay(Context context, AttributeSet attrs) {
super(context, attrs);
initView();
}
It is safer to include all three constructors for the custom View. For example, include the following Constructors for your NeckCanvasOverlay.
public NeckCanvasOverlay(Context context) {
super(context);
initView();
}
public NeckCanvasOverlay(Context context, AttributeSet attrs) {
super(context, attrs);
initView();
}
public NeckCanvasOverlay(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
initView();
}
I hope this helps. Give it a try and let me know if you get the same error.
So I've checked all of the other threads on this topic repeatedly but none have yielded the solution. Here's the code:
The XML
<RelativeLayout 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=".MainActivity">
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.turingtechnologies.materialscrollbar.DragScrollBar
android:layout_width="wrap_content"
android:id="#+id/dragScrollBar"
android:layout_height="match_parent"/>
</RelativeLayout>
The Activity
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Stuff
recyclerView = (RecylerView)findViewById(R.id.recyclerView); //I've verified that this works properly.
DragScrollBar dragScrollBar = (DragScrollBar)findViewById(R.id.dragScrollBar);
if (dragScrollBar == null) { Log.d("d", "fail"); }
dragScrollBar.bindRecyclerView(recyclerView);
}
DragScrollBar.java
public class DragScrollBar extends MaterialScrollBar<DragScrollBar>{
public DragScrollBar(Context context, AttributeSet attrs){
super(context, attrs);
}
}
MaterialScrollBar.java
abstract class MaterialScrollBar<T> extends RelativeLayout {
MaterialScrollBar(Context context, AttributeSet attrs){
super(context, attrs);
initialise(context);
}
//Stuff
}
It draws correctly on the preview but returns a nullPointerException when dragScrollBar is used and 'fail' is printed to the console.
I've omitted the other normal constructors but when included they don't make a difference.
EDIT: Here's the stack trace
fail
Shutting down VM
FATAL EXCEPTION: main
Process: com.turingtechnologies.materialscrollbardemo, PID: 31890 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.turingtechnologies.materialscrollbardemo/com.turingtechnologies.materialscrollbardemo.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object com.turingtechnologies.materialscrollbar.DragScrollBar.bindRecyclerView(android.support.v7.widget.RecyclerView)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object com.turingtechnologies.materialscrollbar.DragScrollBar.bindRecyclerView(android.support.v7.widget.RecyclerView)' on a null object reference
at com.turingtechnologies.materialscrollbardemo.MainActivity.onCreate(MainActivity.java:26)
at android.app.Activity.performCreate(Activity.java:6251)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
I had run setID() inside of initalise as part of an earlier scheme and hadn't thought to remove it during refactoring.
I've already saw questions suggestions but I didn't find my answer.
The LogCat throws this error:
I/Timeline( 7748): Timeline: Activity_launch_request id:com.miracle.livapp time:45951871
I/ActivityManager( 768): START u0 {flg=0x10000000 cmp=com.miracle.livapp/com.odizzain.cordova.plugins.livestream.CameraStreamingActivity} from uid 10252 on display 0
E/AndroidRuntime( 7748): Process: com.miracle.livapp, PID: 7748
E/AndroidRuntime( 7748): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.miracle.livapp/com.odizzain.cordova.plugins.livestream.CameraStreamingActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class ru.denivip.nine00secondssdk.hlsstreaming.Nine00SecondsCameraView
D/ActivityManager( 768): New dropbox entry: com.miracle.livapp, data_app_crash, 877fda44-aca7-4a69-8c23-c0da45fa7bd4
W/ActivityManager( 768): Force finishing activity com.miracle.livapp/com.odizzain.cordova.plugins.livestream.CameraStreamingActivity
W/ActivityManager( 768): Force finishing activity com.miracle.livapp/.MainActivity
W/ActivityManager( 768): Activity pause timeout for ActivityRecord{3e7cfd61 u0 com.miracle.livapp/com.odizzain.cordova.plugins.livestream.CameraStreamingActivity t82 f}
W/ActivityManager( 768): Activity destroy timeout for ActivityRecord{338f1497 u0 com.miracle.livapp/.MainActivity t82 f}
W/ActivityManager( 768): Activity destroy timeout for ActivityRecord{3e7cfd61 u0 com.miracle.livapp/com.odizzain.cordova.plugins.livestream.CameraStreamingActivity t82 f}
The class involved has two constructor avoiding the second argument problem that I read in other places:
public Nine00SecondsCameraView(Context context){
super(context, null);
}
public Nine00SecondsCameraView(Context context, AttributeSet attrs) {
super(context, attrs);
....
}
This is the XML File:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ru.denivip.nine00secondssdk.hlsstreaming.Nine00SecondsCameraView
android:id="#+id/streamingView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ImageButton
android:id="#+id/toggleRecording_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="16dp"
android:background="#drawable/circle_button_background_selector"
android:src="#drawable/reccord_button"
android:clickable="true"
android:onClick="clickToggleRecording" />
</RelativeLayout>
And this is the CameraStreamingActivity.java
package com.odizzain.cordova.plugins.livestream;
import ru.denivip.nine00secondssdk.hlsstreaming.Nine00SecondsCameraView;
import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
public class CameraStreamingActivity extends Activity {
private String appPackageName = null;
private Resources appResources = null;
private Nine00SecondsCameraView streamingView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
appPackageName = getApplication().getPackageName();
appResources = getApplication().getResources();
// appResources.getIdentifier("activity_camerabroadcast", "layout", appPackageName)
setContentView(appResources.getIdentifier("camera_streaming_activity", "layout", appPackageName));
streamingView = (Nine00SecondsCameraView) findViewById(appResources.getIdentifier("streamingView", "id", appPackageName));
}
#Override
protected void onResume() {
super.onResume();
streamingView.onResume();
}
#Override
protected void onPause() {
super.onPause();
streamingView.onPause();
}
/**
* onClick handler for "record" button.
*/
public void clickToggleRecording(View unused) {
if (streamingView.isRecording())
streamingView.stopRecording();
else
streamingView.startRecording();
updateControls();
}
/**
* Updates the on-screen controls to reflect the current state of the app.
*/
private void updateControls() {
ImageButton toggleRelease = (ImageButton) findViewById(appResources.getIdentifier("toggleRecording_button", "id", appPackageName));
int id = streamingView.isRecording() ?
appResources.getIdentifier("stop_reccord_button", "drawable", appPackageName) :
appResources.getIdentifier("reccord_button", "drawable", appPackageName);
toggleRelease.setImageResource(id);
}
}
btw, i am using this sdk: http://livestreamsdk.com/
I solved adding constructors for this three and four arguments:
SurfaceView(Context context, AttributeSet attrs, int defStyleAttr)
SurfaceView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
Like the android documentation says.
I am trying to encorporate this plugin into a fragment of mine. I like the dependencie in my gradle file:
compile "com.splitwise:tokenautocomplete:1.3.1#aar"
My fragments onCreateView looks like:
View view = inflater.inflate(R.layout.fragment_tutor_setup, container, false);
String[] strings = new String[]{"photoshop",""};
adapter = new ArrayAdapter<String>(getActivity(), R.layout.fragment_tutor_setup, strings);
completionView = (ContactsCompletionView)view.findViewById(R.id.searchView);
completionView.setAdapter(adapter);
if (savedInstanceState == null) {
completionView.setPrefix("Skills: ");
}
return view;
And then I extend a ContactsCompletionView like so:
public class ContactsCompletionView extends TokenCompleteTextView {
public ContactsCompletionView(Context context) {
super(context);
}
public ContactsCompletionView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ContactsCompletionView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
#Override
protected View getViewForObject(Object object) {
String s = (String)object;
LayoutInflater l = (LayoutInflater)getContext().getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
LinearLayout view = (LinearLayout)l.inflate(R.layout.contact_token, (ViewGroup)ContactsCompletionView.this.getParent(), false);
((TextView)view.findViewById(R.id.name)).setText(s);
return view;
}
#Override
protected Object defaultObject(String completionText) {
return completionText;
}
}
And finally in my fragment_tutor_setup.xml:
<com.tokenautocomplete.ContactsCompletionView
android:id="#+id/searchView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
**EDIT STACK **
02-23 11:20:43.041 29587-29587/login.shogun.comet.samplelogin E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: login.shogun.comet.samplelogin, PID: 29587
android.view.InflateException: Binary XML file line #34: Error inflating class login.shogun.comet.halp.ContactsCompletionView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at login.shogun.comet.halp.TutorSetupFragment.onCreateView(TutorSetupFragment.java:76)
at android.app.Fragment.performCreateView(Fragment.java:2053)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:894)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.app.BackStackRecord.run(BackStackRecord.java:833)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1452)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:447)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
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:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.ClassNotFoundException: Didn't find class "login.shogun.comet.halp.ContactsCompletionView" on path: DexPathList[[zip file "/data/app/login.shogun.comet.samplelogin-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.view.LayoutInflater.createView(LayoutInflater.java:571)
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
I know I have came across this problem before so at first rebuilt my project and invalidate the caches. If you would like me to post more code I would be more than happy too.
In your layout xml, it should be:
<login.shogun.comet.halp.ContactsCompletionView
android:id="#+id/searchView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
or whatever the fully qualified name of your class is.