سؤال

When I try and test my app I receive the following error(s):

02-16 13:05:09.251: E/AndroidRuntime(1346): FATAL EXCEPTION: main
02-16 13:05:09.251: E/AndroidRuntime(1346): Process: biz.midl.debteliminator, PID: 1346
02-16 13:05:09.251: E/AndroidRuntime(1346): java.lang.RuntimeException: Unable to start activity ComponentInfo{biz.midl.debteliminator/biz.midl.debteliminator.MainActivity}: java.lang.RuntimeException: Binary XML file line #21: You must supply a layout_width attribute.
02-16 13:05:09.251: E/AndroidRuntime(1346):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at android.os.Handler.dispatchMessage(Handler.java:102)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at android.os.Looper.loop(Looper.java:136)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at android.app.ActivityThread.main(ActivityThread.java:5017)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at java.lang.reflect.Method.invokeNative(Native Method)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at java.lang.reflect.Method.invoke(Method.java:515)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at dalvik.system.NativeStart.main(Native Method)
02-16 13:05:09.251: E/AndroidRuntime(1346): Caused by: java.lang.RuntimeException: Binary XML file line #21: You must supply a layout_width attribute.
02-16 13:05:09.251: E/AndroidRuntime(1346):     at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:492)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:5948)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:6117)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at android.widget.LinearLayout$LayoutParams.<init>(LinearLayout.java:1831)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:1743)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:58)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:757)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at android.app.Activity.setContentView(Activity.java:1929)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at biz.midl.debteliminator.MainActivity.onCreate(MainActivity.java:25)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at android.app.Activity.performCreate(Activity.java:5231)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
02-16 13:05:09.251: E/AndroidRuntime(1346):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)

The line (25) is the following:

public class MainActivity extends Activity {

double interestRate;
double r, r1;
int nRemaining, nStarting, nDifference, originalBalance,
        outstandingBalance, originalTerm;
double minPayment, newPayment, newPmt;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);    //<------Error is here

My layout is called "main".

Here is my Manifest in case the error is in here:

<?xml version="1.0" encoding="utf-8"?>

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="19" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="biz.midl.debteliminator.MainActivity"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.DeviceDefault.Light.NoActionBar.Fullscreen" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

I would appreciate any assistance. Thanks!

هل كانت مفيدة؟

المحلول

As the LogCat says, you need to define the android:layout_width parameter in the XML file for your MainActivity. It should be located in your res/layout/ folder, under the name activity_main.xml or something similar.

نصائح أخرى

Your log says you need to imply layout with:

Binary XML file line #21: You must supply a layout_width attribute

To do that locate your XML file of your layout and add the following line:

android:layout_width="fill_parent"

Binary XML file line #21: You must supply a layout_width attribute

Check line 21 of main.xml and ensure that the view has the layout_width property

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top