我开发的Android应用程序仅在4.1版本上启动

时间:2013-11-10 06:28:44

标签: android

我是Android开发的新手,我希望你的帮助,在我开发我的应用程序和测试后,我可以启动它并在我的物理Note 2或任何4.1 Android版本上运行它,但不是在模拟器上即使是相同的版本。

请参阅我的日志cat错误日志。

11-10 09:19:18.565: E/AndroidRuntime(1273): FATAL EXCEPTION: main
11-10 09:19:18.565: E/AndroidRuntime(1273): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.Frdaoud.moka/com.Frdaoud.moka.SplashActivity}: java.lang.NullPointerException
11-10 09:19:18.565: E/AndroidRuntime(1273):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
11-10 09:19:18.565: E/AndroidRuntime(1273):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
11-10 09:19:18.565: E/AndroidRuntime(1273):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-10 09:19:18.565: E/AndroidRuntime(1273):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-10 09:19:18.565: E/AndroidRuntime(1273):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-10 09:19:18.565: E/AndroidRuntime(1273):     at android.os.Looper.loop(Looper.java:130)
11-10 09:19:18.565: E/AndroidRuntime(1273):     at android.app.ActivityThread.main(ActivityThread.java:3683)
11-10 09:19:18.565: E/AndroidRuntime(1273):     at java.lang.reflect.Method.invokeNative(Native Method)
11-10 09:19:18.565: E/AndroidRuntime(1273):     at java.lang.reflect.Method.invoke(Method.java:507)
11-10 09:19:18.565: E/AndroidRuntime(1273):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-10 09:19:18.565: E/AndroidRuntime(1273):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-10 09:19:18.565: E/AndroidRuntime(1273):     at dalvik.system.NativeStart.main(Native Method)
11-10 09:19:18.565: E/AndroidRuntime(1273): Caused by: java.lang.NullPointerException
11-10 09:19:18.565: E/AndroidRuntime(1273):     at com.Frdaoud.moka.SplashActivity.StartAnimations(SplashActivity.java:57)
11-10 09:19:18.565: E/AndroidRuntime(1273):     at com.Frdaoud.moka.SplashActivity.onCreate(SplashActivity.java:40)
11-10 09:19:18.565: E/AndroidRuntime(1273):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-10 09:19:18.565: E/AndroidRuntime(1273):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
11-10 09:19:18.565: E/AndroidRuntime(1273):     ... 11 more




    package com.Frdaoud.moka;


import java.util.Timer;
import java.util.TimerTask;

import android.app.Activity;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.Window;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;



public class SplashActivity extends Activity {
    MediaPlayer OurSong;

    private long splashDelay = 3700; //3.7 seconds


    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        Window window = getWindow();
        window.setFormat(PixelFormat.RGBA_8888);
    }
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {



        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_splash);
        StartAnimations();
    }
    private void StartAnimations() {
        Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
        anim.reset();
        LinearLayout l=(LinearLayout) findViewById(R.id.logo1);
        l.clearAnimation();
        l.startAnimation(anim);

        anim = AnimationUtils.loadAnimation(this, R.anim.translate);
        anim.reset();
        ImageView iv = (ImageView) findViewById(R.id.logo);
        iv.clearAnimation();
        iv.startAnimation(anim);


        OurSong = MediaPlayer.create(SplashActivity.this, R.raw.test1);
        OurSong.start();
        TimerTask task = new TimerTask()
        {

            @Override
            public void run() {
                finish();
                Intent mainIntent = new Intent().setClass(SplashActivity.this, MainActivity.class);
                startActivity(mainIntent);

            }

        };

        Timer timer = new Timer();
        timer.schedule(task, splashDelay);
    }
}

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

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="16" />
<supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:anyDensity="true"></supports-screens>
<supports-screens android:anyDensity="true" />   
<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="@style/AppTheme" >
        <activity
            android:name="com.Frdaoud.moka.SplashActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
       <activity
            android:name="com.Frdaoud.moka.MainActivity"
            android:label="@string/app_name" >
        </activity>

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

        <activity
            android:name="com.Frdaoud.moka.Sermonsv"
            android:label="@string/title_activity_sermons" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Service"
            android:label="@string/title_activity_service" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.LiveStreaming"
            android:label="@string/title_activity_live_streaming" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Services"
            android:label="@string/title_activity_services" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Atakal"
            android:label="@string/title_activity_atakal" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Sad"
            android:label="@string/title_activity_sad" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Heart"
            android:label="@string/title_activity_heart" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Pray"
            android:label="@string/title_activity_pray" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Voicevideo"
            android:label="@string/title_activity_voicevideo" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Sermons2"
            android:label="@string/title_activity_sermons2" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Email"
            android:label="@string/title_activity_email" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Bible"
            android:label="@string/title_activity_bible" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.HttpExample"
            android:label="@string/title_activity_http_example" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Side_navigation"
            android:label="@string/title_activity_side_navigation" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Moka"
            android:label="@string/title_activity_moka" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Slider"
            android:label="@string/title_activity_slider" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Sermons3"
            android:label="@string/title_activity_sermons3" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Evan"
            android:label="@string/title_activity_evan" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Timing"
            android:label="@string/title_activity_timing" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Fragment_1"
            android:label="@string/title_activity_fragment_1" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Fragment_2"
            android:label="@string/title_activity_fragment_2" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Sermonsa"
            android:label="@string/title_activity_sermonsa" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Prayers"
            android:label="@string/title_activity_prayers" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.ActionDrawerBasic"
            android:label="@string/title_activity_action_drawer_basic" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Apologetics"
            android:label="@string/title_activity_apologetics" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Health"
            android:label="@string/title_activity_health" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Sexual"
            android:label="@string/title_activity_sexual" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Quotes"
            android:label="@string/title_activity_quotes" >
        </activity>
        <activity
            android:name="com.Frdaoud.moka.Quotesm"
            android:label="@string/title_activity_quotesm" >
        </activity>
    </application>

</manifest>

1 个答案:

答案 0 :(得分:0)

你正在获得空指针异常,这就是你的应用程序崩溃的原因。仔细查看logcat输出

Caused by: java.lang.NullPointerException
11-10 09:19:18.565: E/AndroidRuntime(1273):     at com.Frdaoud.moka.SplashActivity.StartAnimations(SplashActivity.java:57)
11-10 09:19:18.565: E/AndroidRuntime(1273):     at com.Frdaoud.moka.SplashActivity.onCreate(SplashActivity.java:40)

检查第57行。应用断点并检查它是否获得任何值或是否为空。使用调试工具。也可以发布您的代码并提及代码中的第57行