Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8493711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:05:48+00:00 2026-06-10T23:05:48+00:00

* update: I don’t know why, but removing some unused imports apparently fixed it.

  • 0

* update: I don’t know why, but removing some unused imports apparently fixed it. *

When starting my app on older android versions (e.g. 2.2) I do get the following error log…

But I don’t get any errors on newer Android versions.

"at my.package.MainActivity.onCreate(MainActivity.java:12)"

is where my activity_main.xml is getting loaded, so I think there is something wrong with my

<fragment>

?

LogCat

09-06 14:18:47.037: E/AndroidRuntime(5887): FATAL EXCEPTION: main
09-06 14:18:47.037: E/AndroidRuntime(5887): java.lang.RuntimeException: Unable to start activity ComponentInfo{my.package/my.package.MainActivity}: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x2
09-06 14:18:47.037: E/AndroidRuntime(5887):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1768)
09-06 14:18:47.037: E/AndroidRuntime(5887):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
09-06 14:18:47.037: E/AndroidRuntime(5887):     at android.app.ActivityThread.access$1500(ActivityThread.java:123)
09-06 14:18:47.037: E/AndroidRuntime(5887):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
09-06 14:18:47.037: E/AndroidRuntime(5887):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-06 14:18:47.037: E/AndroidRuntime(5887):     at android.os.Looper.loop(Looper.java:130)
09-06 14:18:47.037: E/AndroidRuntime(5887):     at android.app.ActivityThread.main(ActivityThread.java:3835)
09-06 14:18:47.037: E/AndroidRuntime(5887):     at java.lang.reflect.Method.invokeNative(Native Method)
09-06 14:18:47.037: E/AndroidRuntime(5887):     at java.lang.reflect.Method.invoke(Method.java:507)
09-06 14:18:47.037: E/AndroidRuntime(5887):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
09-06 14:18:47.037: E/AndroidRuntime(5887):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
09-06 14:18:47.037: E/AndroidRuntime(5887):     at dalvik.system.NativeStart.main(Native Method)
09-06 14:18:47.037: E/AndroidRuntime(5887): Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x2
09-06 14:18:47.037: E/AndroidRuntime(5887):     at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)
09-06 14:18:47.037: E/AndroidRuntime(5887):     at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:3692)
09-06 14:18:47.037: E/AndroidRuntime(5887):     at android.widget.LinearLayout$LayoutParams.<init>(LinearLayout.java:1400)
09-06 14:18:47.037: E/AndroidRuntime(5887):     at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:1326)
09-06 14:18:47.037: E/AndroidRuntime(5887):     at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:47)
09-06 14:18:47.037: E/AndroidRuntime(5887):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:625)
09-06 14:18:47.037: E/AndroidRuntime(5887):     at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
09-06 14:18:47.037: E/AndroidRuntime(5887):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
09-06 14:18:47.037: E/AndroidRuntime(5887):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
09-06 14:18:47.037: E/AndroidRuntime(5887):     at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:857)
09-06 14:18:47.037: E/AndroidRuntime(5887):     at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:251)
09-06 14:18:47.037: E/AndroidRuntime(5887):     at my.package.MainActivity.onCreate(MainActivity.java:12)
09-06 14:18:47.037: E/AndroidRuntime(5887):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-06 14:18:47.037: E/AndroidRuntime(5887):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
09-06 14:18:47.037: E/AndroidRuntime(5887):     ... 11 more

MainActivity.java

package my.package;

import android.os.Bundle;
import com.actionbarsherlock.app.SherlockFragmentActivity;

public class MainActivity extends SherlockFragmentActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);
    }
}

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<fragment
    android:id="@+id/mainFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="my.package.MainFragment" />
</LinearLayout>

MainFragment.java

package my.package;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.content.Intent;
import com.actionbarsherlock.app.SherlockFragment;

public class MainFragment extends SherlockFragment {

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_main, container, false);

    Button button = (Button) view.findViewById(R.id.bmibutton1);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            updateDetail();
        }
    });

    return view;
}

// May also be triggered from the Activity
public void updateDetail() {
    BmiFragment fragment = (BmiFragment) getFragmentManager()
            .findFragmentById(R.id.bmiFragment);

    if (fragment != null && fragment.isInLayout()) {
    } else {
        Intent intent = new Intent(getActivity().getApplicationContext(),
                BmiActivity.class);

        startActivity(intent);
    }
}
}

fragment_main.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" >

<Button
    android:id="@+id/bmibutton1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:text="BMI" />

<Button
    android:id="@+id/whtrbutton2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignRight="@+id/bmibutton1"
    android:layout_below="@+id/bmibutton1"
    android:text="WHtR" />

</RelativeLayout>

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="my.package"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="7"
    android:targetSdkVersion="15" />

<application
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:theme="@style/Theme.Sherlock.Light.DarkActionBar" >
    <activity android:name=".MainActivity" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".BmiActivity"
        android:label="@string/title_activity_bmi" >
    </activity>
</application>

</manifest>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:05:49+00:00Added an answer on June 10, 2026 at 11:05 pm

    I don’t know why, but removing some unused imports apparently fixed it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've installed ASP.NET MVC3 and the Tools Update, but don't see any MVC3 controls
Update: I don't use TFS anymore. But from the comments I can see that
Update I don't think I was clear enough when I originally posted this quesion.
UPDATE : I do appreciate don't want that, want this instead suggestions. They are
UPDATE: After searching a bit I don't seem to be alone about this problem:
[2015 update: I think it's safe to say that Flash is rapidly dying. Don't
I am having problems using the update method of scala.collection.immutable.HashMap.I don't see the reason
I'm trying to update a table to remove all but the first instance of
I'm getting a little annoyed that the update statements don't show in the console
I have an app that is completely free. I want to update it with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.