I use this ((FrameLayout) findViewById(R.id.framePreview)).addView(preview); with no issues at all, maybe its the view type?
should this
ViewGroup root = (ViewGroup) findViewById(R.id.root);
root.addView(v);
not be this
LinearLayout root = (LinearLayout) findViewById(R.id.root);
root.addView(v);