java.lang.RuntimeException:无法实例化活动

时间:2014-07-07 18:29:09

标签: java android nullpointerexception

如果您有此选项卡,我从Android 4.4的某些设备(如Galaxy Tab3 8.0(lt01wifi))收到此错误,请回复。 该应用程序在其余设备上运行良好。 请帮我!我的收视率很高......

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{aladin888.dessin/aladin888.dessin.Splash}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2208)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2340)
at android.app.ActivityThread.access$800(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5293)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.app.Activity.setRequestedOrientation(Activity.java:4453)

我无法弄清问题在哪里。在我的清单中,一切似乎都是正确的(对我而言)。有问题的活动会被注册,如您所见:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="aladin888.dessin"
    android:versionCode="10"
    android:versionName="1.9.0" >

    <supports-screens
        android:anyDensity="true"
        android:largeScreens="true"
        android:normalScreens="true"
        android:resizeable="true"
        android:smallScreens="true" />

    <uses-sdk android:minSdkVersion="8" />

    <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"/>
    <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
    <uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT"/>    


    <application
        android:icon="@drawable/icon"
        android:label="@string/app_name" >
        <activity
            android:name="aladin888.dessin.Splash"
            android:label="@string/app_name"
            android:exported="true"
            android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" 
            android:configChanges="keyboard|keyboardHidden|orientation">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="aladin888.dessin.EasyPaint"
            android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
            <intent-filter>

            </intent-filter>
        </activity>


    <activity android:name="com.google.ads.AdActivity"
              android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
   </application>

</manifest>

感谢Dawnkeeper的帮助!但我仍然遇到同样的问题,而且我的评分很差 任何更多的想法将非常感谢!!

1 个答案:

答案 0 :(得分:1)

您正在引用名称

中的包
 android:name="aladin888.dessin.Splash"

应该是

android:name=".Splash"

修改

我们发现这不是真正的问题。另一个提示是:

Caused by: java.lang.NullPointerException
at android.app.Activity.setRequestedOrientation(Activity.java:4453)

我搜索了一会儿,但找不到在给定行上有此方法的Android版本。我发现的是,方法在一段时间内没有改变:

 public void setRequestedOrientation(int requestedOrientation) {
       if (mParent == null) {
           try {
                ActivityManagerNative.getDefault().setRequestedOrientation(
                        mToken, requestedOrientation);
            } catch (RemoteException e) {
                // Empty
            }
        } else {
            mParent.setRequestedOrientation(requestedOrientation);
        }
    }

我发现失败的唯一机会是ActivityManagerNative.getDefault()返回null。我找不到任何有用的问题。