I have an app in Google play already and has no problem at all until I upgrade my Android Studio. The build.gradle has to be modified so that the project can be compiled Here is what I changed:
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.google.android.gms:play-services:6+'
compile 'com.android.support:support-v4:+'
}
The only change is com.android.support:appcompat-v7:+ which is changed to com.android.support:appcompat-v7:21.0.0.
My problem is the .findViewById(R.id.tabhost) always return null so that the application crashes. Here is my layout file:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.app.FragmentTabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
My java code:
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTabHost;
public class MenuLeftFragment extends Fragment {
private FragmentTabHost mFragmentTabHost;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mView = getView();
if (mView != null) {
mFragmentTabHost = (FragmentTabHost) mView
.findViewById(R.id.tabhost);
Any idea? Thanks.