应用程序无法在任何设备上运行

时间:2014-05-06 06:32:36

标签: java android eclipse

我为客户制作了一个Android应用程序。它适用于我的设备和朋友的设备,但不适用于任何其他设备。

应用程序以名为 Spalsh.java 的活动开始,然后传递 Login.java 的意图。

我已经为应用程序附加了Stacktrace,Splash.java,Login.java,Splash.xml,Login.xml和Manifest。请帮助我,因为我无法找到问题。可以找到整个来源here

栈跟踪

05-02 23:44:24.855: D/OpenGLRenderer(30724): Enabling debug mode 0
05-02 23:44:24.925: W/OpenGLRenderer(30724): Bitmap too large to be uploaded into a texture (1620x2880, max=2048x2048)
05-02 23:44:26.887: D/dalvikvm(30724): GC_FOR_ALLOC freed 11035K, 28% free 33444K/46000K, paused 18ms, total 18ms
05-02 23:44:26.897: I/dalvikvm-heap(30724): Grow heap (frag case) to 42.031MB for 8294416-byte allocation
05-02 23:44:26.917: D/dalvikvm(30724): GC_CONCURRENT freed 2K, 10% free 41541K/46000K, paused 2ms+3ms, total 20ms
05-02 23:44:26.917: D/dalvikvm(30724): WAIT_FOR_CONCURRENT_GC blocked 15ms
05-02 23:44:26.987: E/dalvikvm(30724): adjustAdaptiveCoef max=4194304, min=1048576, ut=568
05-02 23:44:26.997: D/dalvikvm(30724): GC_FOR_ALLOC freed <1K, 10% free 41541K/46000K, paused 18ms, total 18ms
05-02 23:44:26.997: I/dalvikvm-heap(30724): Forcing collection of SoftReferences for 18662416-byte allocation
05-02 23:44:27.017: E/dalvikvm(30724): adjustAdaptiveCoef max=6291456, min=1572864, ut=368
05-02 23:44:27.017: D/dalvikvm(30724): GC_BEFORE_OOM freed 10K, 10% free 41531K/46000K, paused 28ms, total 28ms
05-02 23:44:27.017: E/dalvikvm-heap(30724): Out of memory on a 18662416-byte allocation.
05-02 23:44:27.017: I/dalvikvm(30724): "main" prio=5 tid=1 RUNNABLE
05-02 23:44:27.017: I/dalvikvm(30724):   | group="main" sCount=0 dsCount=0 obj=0x40fd19a0 self=0x40f58b80
05-02 23:44:27.017: I/dalvikvm(30724):   | sysTid=30724 nice=-19 sched=0/0 cgrp=apps handle=1074533852
05-02 23:44:27.017: I/dalvikvm(30724):   | state=R schedstat=( 0 0 0 ) utm=67 stm=19 core=0
05-02 23:44:27.017: I/dalvikvm(30724):   at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
05-02 23:44:27.027: I/dalvikvm(30724):   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596)
05-02 23:44:27.027: I/dalvikvm(30724):   at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
05-02 23:44:27.027: I/dalvikvm(30724):   at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:817)
05-02 23:44:27.027: I/dalvikvm(30724):   at android.content.res.Resources.loadDrawable(Resources.java:2854)
05-02 23:44:27.027: I/dalvikvm(30724):   at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
05-02 23:44:27.027: I/dalvikvm(30724):   at android.view.View.<init>(View.java:3522)
05-02 23:44:27.027: I/dalvikvm(30724):   at android.view.View.<init>(View.java:3451)
05-02 23:44:27.027: I/dalvikvm(30724):   at android.view.ViewGroup.<init>(ViewGroup.java:441)
05-02 23:44:27.027: I/dalvikvm(30724):   at android.widget.RelativeLayout.<init>(RelativeLayout.java:210)
05-02 23:44:27.027: I/dalvikvm(30724):   at java.lang.reflect.Constructor.constructNative(Native Method)
05-02 23:44:27.027: I/dalvikvm(30724):   at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
05-02 23:44:27.037: I/dalvikvm(30724):   at android.view.LayoutInflater.createView(LayoutInflater.java:593)
05-02 23:44:27.037: I/dalvikvm(30724):   at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
05-02 23:44:27.037: I/dalvikvm(30724):   at android.view.LayoutInflater.onCreateView(LayoutInflater.java:666)
05-02 23:44:27.037: I/dalvikvm(30724):   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
05-02 23:44:27.037: I/dalvikvm(30724):   at android.view.LayoutInflater.inflate(LayoutInflater.java:467)
05-02 23:44:27.037: I/dalvikvm(30724):   at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
05-02 23:44:27.037: I/dalvikvm(30724):   at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
05-02 23:44:27.037: I/dalvikvm(30724):   at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:364)
05-02 23:44:27.037: I/dalvikvm(30724):   at android.app.Activity.setContentView(Activity.java:1930)
05-02 23:44:27.037: I/dalvikvm(30724):   at com.royal.bikers.Login.onCreate(Login.java:41)
05-02 23:44:27.037: I/dalvikvm(30724):   at android.app.Activity.performCreate(Activity.java:5283)
05-02 23:44:27.037: I/dalvikvm(30724):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
05-02 23:44:27.037: I/dalvikvm(30724):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)
05-02 23:44:27.037: I/dalvikvm(30724):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2299)
05-02 23:44:27.037: I/dalvikvm(30724):   at android.app.ActivityThread.access$700(ActivityThread.java:150)
05-02 23:44:27.037: I/dalvikvm(30724):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
05-02 23:44:27.037: I/dalvikvm(30724):   at android.os.Handler.dispatchMessage(Handler.java:99)
05-02 23:44:27.037: I/dalvikvm(30724):   at android.os.Looper.loop(Looper.java:137)
05-02 23:44:27.037: I/dalvikvm(30724):   at android.app.ActivityThread.main(ActivityThread.java:5283)
05-02 23:44:27.037: I/dalvikvm(30724):   at java.lang.reflect.Method.invokeNative(Native Method)
05-02 23:44:27.037: I/dalvikvm(30724):   at java.lang.reflect.Method.invoke(Method.java:511)
05-02 23:44:27.037: I/dalvikvm(30724):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
05-02 23:44:27.037: I/dalvikvm(30724):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
05-02 23:44:27.037: I/dalvikvm(30724):   at dalvik.system.NativeStart.main(Native Method)
05-02 23:44:27.047: D/skia(30724): --- allocation failed for scaled bitmap
05-02 23:44:27.047: D/AndroidRuntime(30724): Shutting down VM
05-02 23:44:27.047: W/dalvikvm(30724): threadid=1: thread exiting with uncaught exception (group=0x40fd0930)
05-02 23:44:27.067: E/AndroidRuntime(30724): FATAL EXCEPTION: main
05-02 23:44:27.067: E/AndroidRuntime(30724): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.royal.bikers/com.royal.bikers.Login}: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2245)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2299)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.app.ActivityThread.access$700(ActivityThread.java:150)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.os.Looper.loop(Looper.java:137)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.app.ActivityThread.main(ActivityThread.java:5283)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at java.lang.reflect.Method.invokeNative(Native Method)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at java.lang.reflect.Method.invoke(Method.java:511)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at dalvik.system.NativeStart.main(Native Method)
05-02 23:44:27.067: E/AndroidRuntime(30724): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.view.LayoutInflater.createView(LayoutInflater.java:619)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:666)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.view.LayoutInflater.inflate(LayoutInflater.java:467)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:364)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.app.Activity.setContentView(Activity.java:1930)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at com.royal.bikers.Login.onCreate(Login.java:41)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.app.Activity.performCreate(Activity.java:5283)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)
05-02 23:44:27.067: E/AndroidRuntime(30724):    ... 11 more
05-02 23:44:27.067: E/AndroidRuntime(30724): Caused by: java.lang.reflect.InvocationTargetException
05-02 23:44:27.067: E/AndroidRuntime(30724):    at java.lang.reflect.Constructor.constructNative(Native Method)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.view.LayoutInflater.createView(LayoutInflater.java:593)
05-02 23:44:27.067: E/AndroidRuntime(30724):    ... 23 more
05-02 23:44:27.067: E/AndroidRuntime(30724): Caused by: java.lang.OutOfMemoryError
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:817)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.content.res.Resources.loadDrawable(Resources.java:2854)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.view.View.<init>(View.java:3522)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.view.View.<init>(View.java:3451)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.view.ViewGroup.<init>(ViewGroup.java:441)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.widget.RelativeLayout.<init>(RelativeLayout.java:210)
05-02 23:44:27.067: E/AndroidRuntime(30724):    ... 26 more

Splash.Java

package com.royal.bikers;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

import com.royal.bikers.resources.DatabaseHandler;
import com.royal.bikers.resources.Functions;

public class Splash extends Activity {
    Functions function = new Functions();

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

        setContentView(R.layout.splash);

        new Handler().postDelayed(new Runnable() {

            // Using handler with postDelayed called runnable run method

            @Override
            public void run() {

                DatabaseHandler db = new DatabaseHandler(
                        getApplicationContext());
                if (db.getRowCount() > 0) {
                    Intent gotoSearch = new Intent(getApplication(),
                            Search.class);
                    startActivity(gotoSearch);
                    overridePendingTransition(android.R.anim.slide_in_left,
                            android.R.anim.slide_out_right);
                } else {

                    Intent gotoLogin = new Intent(getApplication(), Login.class);
                    startActivity(gotoLogin);
                    overridePendingTransition(android.R.anim.slide_in_left,
                            android.R.anim.slide_out_right);
                }

                // close this activity
                finish();
            }
        }, 2000); // wait for 2 seconds

    }
}

Login.java

package com.royal.bikers;

import static com.royal.bikers.resources.Constants.KEY_DATA;
import static com.royal.bikers.resources.Constants.KEY_EMAIL;
import static com.royal.bikers.resources.Constants.KEY_ERROR;
import static com.royal.bikers.resources.Constants.KEY_ID;
import static com.royal.bikers.resources.Constants.KEY_MSG;
import static com.royal.bikers.resources.Constants.KEY_NAME;
import static com.royal.bikers.resources.Constants.KEY_USERNAME;
import static com.royal.bikers.resources.Constants.TF;

import org.json.JSONObject;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.royal.bikers.resources.DatabaseHandler;
import com.royal.bikers.resources.Functions;

public class Login extends Activity {

    EditText loginUsername, loginPassword;
    Button aboutUs, loginDo, registerIntent;
    String username, password, message;
    Functions Function = new Functions();
    JSONObject json;

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

        setContentView(R.layout.login);

        aboutUs = (Button) findViewById(R.id.aboutUs);
        loginDo = (Button) findViewById(R.id.loginDo);
        registerIntent = (Button) findViewById(R.id.loginRegisterIntent);
        loginUsername = (EditText) findViewById(R.id.loginUsername);
        loginPassword = (EditText) findViewById(R.id.loginPassword);
        TF = Typeface.createFromAsset(getAssets(), "fonts/usuzi.ttf");
        loginUsername.setTypeface(TF);
        loginPassword.setTypeface(TF);
        loginDo.setTypeface(TF);
        aboutUs.setTypeface(TF);
        registerIntent.setTypeface(TF);

        loginDo.setOnClickListener(new View.OnClickListener() {

            public void onClick(View view) {
                if (Function.isConnected(getApplicationContext())) {

                    username = loginUsername.getText().toString();
                    password = loginPassword.getText().toString();

                    if (username.isEmpty() || password.isEmpty()) {

                        Toast.makeText(getApplicationContext(),
                                "Username and/or Password missing",
                                Toast.LENGTH_SHORT).show();
                    } else {
                        // check for login response

                        LoginDo loginDo = new LoginDo();

                        loginDo.execute();
                        /*
                         * try { loginDo.get(5, TimeUnit.SECONDS); } catch
                         * (Exception e) { e.printStackTrace();
                         * loginDo.cancel(true);
                         * Toast.makeText(getApplicationContext(),
                         * "Connection Timeout", Toast.LENGTH_SHORT) .show(); }
                         */

                    }
                } else {
                    Toast.makeText(getApplicationContext(),
                            "No Internet Connection", Toast.LENGTH_SHORT)
                            .show();
                }
            }
        });

        registerIntent.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent loginToRegister = new Intent(getApplication(),
                        Register.class);
                startActivity(loginToRegister);
                overridePendingTransition(android.R.anim.slide_in_left,
                        android.R.anim.slide_out_right);
            }
        });

        aboutUs.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent aboutUs = new Intent(getApplication(), AboutUs.class);
                startActivity(aboutUs);
                overridePendingTransition(android.R.anim.slide_in_left,
                        android.R.anim.slide_out_right);
            }
        });
    }

    private class LoginDo extends AsyncTask<String, String, JSONObject> {
        private ProgressDialog pDialog;

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            pDialog = new ProgressDialog(Login.this);
            pDialog.setMessage("Logging In...");
            pDialog.setIndeterminate(false);
            pDialog.setCancelable(true);
            pDialog.show();
        }

        @Override
        protected JSONObject doInBackground(String... params) {

            json = Function.loginUser(username, password);
            return json;
        }

        protected void onPostExecute(JSONObject json) {
            pDialog.dismiss();
            try {
                if (json.getString(KEY_ERROR) != null) {
                    String res = json.getString(KEY_ERROR);
                    message = json.getString(KEY_MSG);
                    if (Integer.parseInt(res) == 0) {
                        // user successfully logged in
                        // Store user details in SQLite Database
                        DatabaseHandler db = new DatabaseHandler(
                                getApplicationContext());
                        JSONObject data = json.getJSONObject(KEY_DATA);

                        // Clear all previous data in database
                        Function.logoutUser(getApplicationContext());
                        db.addUser(data.getString(KEY_NAME),
                                data.getString(KEY_USERNAME),
                                data.getString(KEY_EMAIL),
                                data.getString(KEY_ID));

                        // Launch Dashboard Screen
                        Intent toSearch = new Intent(getApplication(),
                                Search.class);
                        Toast.makeText(getApplicationContext(), message,
                                Toast.LENGTH_SHORT).show();
                        // Close all views before launching
                        // Dashboard
                        startActivity(toSearch);
                        overridePendingTransition(android.R.anim.slide_in_left,
                                android.R.anim.slide_out_right);
                        finish();
                    } else {
                        // Error in login
                        Toast.makeText(getApplicationContext(), message,
                                Toast.LENGTH_SHORT).show();
                    }
                } else {
                    Toast.makeText(getApplicationContext(), message,
                            Toast.LENGTH_SHORT).show();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

}

的AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.royal.bikers"
    android:versionCode="1"
    android:versionName="1.0" >

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

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Holo.Light.NoActionBar" >
        <activity
            android:name="com.royal.bikers.Splash"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.royal.bikers.Home"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" >
        </activity>
        <activity
            android:name="com.royal.bikers.Login"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" >
        </activity>
        <activity
            android:name="com.royal.bikers.Register"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" >
        </activity>
        <activity
            android:name="com.royal.bikers.AboutUs"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" >
        </activity>
        <activity
            android:name="com.royal.bikers.Search"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" >
        </activity>
        <activity
            android:name="com.royal.bikers.RegisterEvent"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" >
        </activity>
        <activity
            android:name="com.royal.bikers.Event"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" >
        </activity>
        <activity
            android:name="com.royal.bikers.Account"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" >
        </activity>
        <activity
            android:name="com.royal.bikers.ChangePassword"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden" >
        </activity>
    </application>

</manifest>

Login.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/login"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/ic_bg"
    tools:context="com.royal.bikers.Login"
    tools:ignore="MergeRootFrame" >

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="105dp"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:layout_marginTop="65dp"
        android:background="#59FFFFFF" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical|center_horizontal"
            android:orientation="vertical" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical|center_horizontal"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="20dp"
                android:layout_marginTop="50dp"
                android:orientation="vertical" >

                <EditText
                    android:id="@+id/loginUsername"
                    android:layout_width="match_parent"
                    android:layout_height="45dp"
                    android:layout_marginBottom="10dp"
                    android:background="#A4372e2e"
                    android:hint="@string/username"
                    android:paddingLeft="20dp"
                    android:paddingRight="20dp"
                    android:textSize="25sp" />

                <EditText
                    android:id="@+id/loginPassword"
                    android:layout_width="match_parent"
                    android:layout_height="45dp"
                    android:layout_marginTop="10dp"
                    android:background="#A4372e2e"
                    android:hint="@string/password"
                    android:inputType="textPassword"
                    android:paddingLeft="20dp"
                    android:paddingRight="20dp"
                    android:textSize="25sp" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="60dp"
                android:orientation="vertical" >

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" >

                    <Button
                        android:id="@+id/loginDo"
                        android:layout_width="wrap_content"
                        android:layout_height="35dp"
                        android:layout_gravity="left"
                        android:layout_marginRight="5dp"
                        android:background="#A4372e2e"
                        android:paddingLeft="20dp"
                        android:paddingRight="20dp"
                        android:text="@string/login"
                        android:textSize="25sp" />

                    <Button
                        android:id="@+id/loginRegisterIntent"
                        android:layout_width="wrap_content"
                        android:layout_height="35dp"
                        android:layout_gravity="right"
                        android:layout_marginLeft="5dp"
                        android:background="#A4372e2e"
                        android:paddingLeft="20dp"
                        android:paddingRight="20dp"
                        android:text="@string/register"
                        android:textSize="25sp" />
                </LinearLayout>

                <Button
                    android:id="@+id/aboutUs"
                    android:layout_width="wrap_content"
                    android:layout_height="35dp"
                    android:layout_gravity="center_horizontal"
                    android:layout_marginTop="35dp"
                    android:background="#A4372e2e"
                    android:paddingLeft="20dp"
                    android:paddingRight="20dp"
                    android:text="@string/aboutUs"
                    android:textSize="25sp" />
            </LinearLayout>
        </LinearLayout>
    </ScrollView>

</RelativeLayout>

Splash.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/splash"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/ic_bg_splash"
    tools:context="com.royal.bikers.Splash"
    tools:ignore="MergeRootFrame" >

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:contentDescription="@string/app_name"
        android:src="@drawable/splash_bg" />

    <ImageView
        android:layout_width="120dp"
        android:layout_height="40dp"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="10dp"
        android:contentDescription="@string/app_name"
        android:src="@drawable/splash_watermark" />

</RelativeLayout>

2 个答案:

答案 0 :(得分:0)

将版本代码更改为AndroidManifest.xml

这     

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

答案 1 :(得分:0)

以下是如何阅读stacktrace:

05-02 23:44:27.067: E/AndroidRuntime(30724): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.royal.bikers/com.royal.bikers.Login}: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>

XML文件的第1行错误...

05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.app.Activity.setContentView(Activity.java:1930)
05-02 23:44:27.067: E/AndroidRuntime(30724):    at com.royal.bikers.Login.onCreate(Login.java:41)

...由setContentView()中的Login.onCreate() ...

触发
05-02 23:44:27.067: E/AndroidRuntime(30724): Caused by: java.lang.OutOfMemoryError
...
05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.content.res.Resources.loadDrawable(Resources.java:2854)

...由OOM解码位图drawable引起的......

05-02 23:44:27.067: E/AndroidRuntime(30724):    at android.widget.RelativeLayout.<init>(RelativeLayout.java:210)

... RelativeLayout(虽然我们已经知道,因为我们知道它位于第1行并且具有布局XML)。

罪魁祸首是RelativeLayout背景:

android:background="@drawable/ic_bg"

使drawable/ic_bg的像素尺寸变小,以便在解码时不会占用太多内存。