java.lang.IllegalStateException:AssetManager已经完成

时间:2017-05-21 09:19:44

标签: java android illegalstateexception

我昨天在我的应用程序工作时去睡觉,今天当我试图运行它时根本没有开始。一旦我尝试打开它就会崩溃java.lang.IllegalStateException。我已经在我的代码中做了几次提交,只是为了排除这是我最近做过的事情。这没有任何意义,应用程序如何才能停止工作一夜?我在互联网上寻找错误,并没有很多有用的信息。这真的是一个奇怪的错误吗?

这里是完整的堆栈跟踪:

  

E / AndroidRuntime:致命异常:主要                                                      java.lang.IllegalStateException:AssetManager已经完成!                                                          在android.os.Parcel.readException(Parcel.java:1439)                                                          在android.os.Parcel.readException(Parcel.java:1385)                                                          在android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1947)                                                          在android.app.Instrumentation.execStartActivity(Instrumentation.java:1419)                                                          在android.app.Activity.startActivityForResult(Activity.java:3390)                                                          在android.app.Activity.startActivity(Activity.java:3583)                                                          在com.android.launcher2.Launcher.startActivity(Launcher.java:2442)                                                          在com.android.launcher2.Launcher.startActivitySafely(Launcher.java:2469)                                                          在com.android.launcher2.AppsCustomizePagedView.onClick(AppsCustomizePagedView.java:584)                                                          在android.view.View.performClick(View.java:4240)                                                          在android.view.View $ PerformClick.run(View.java:17721)                                                          在android.os.Handler.handleCallback(Handler.java:730)                                                          在android.os.Handler.dispatchMessage(Handler.java:92)                                                          在android.os.Looper.loop(Looper.java:137)                                                          在android.app.ActivityThread.main(ActivityThread.java:5136)                                                          at java.lang.reflect.Method.invokeNative(Native Method)                                                          在java.lang.reflect.Method.invoke(Method.java:525)                                                          在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:737)                                                          在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)                                                          在dalvik.system.NativeStart.main(本地方法)

因为我说它似乎不是我所做的任何事情,所以我不确定发布什么代码。但鉴于应用程序在此处崩溃,应该首先启动两个主要类的代码:

应用

public class App extends Application {

  private static App instance;
  private static final String TAG = "Starter";

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

    instance = this;
    // Enable Local Datastore.
    Parse.enableLocalDatastore(this);

    //TODO: Register subclasses
//    ParseObject.registerSubclass(Challenge.class);

    //Parse server
    Log.d(TAG, "Initializing Parse");
    Parse.initialize(new Parse.Configuration.Builder(this)
            .applicationId(getString(R.string.parse_app_id))
            .clientKey(getString(R.string.parse_client_key))
            .server(getString(R.string.server_address)).build()
    );

    //Facebook
    if (AccessToken.getCurrentAccessToken() == null)
      ParseFacebookUtils.initialize(this);

    ParseUser.enableAutomaticUser();
    ParseACL defaultACL = new ParseACL();
    // Optionally enable public read access.
    defaultACL.setPublicReadAccess(true);
    defaultACL.setPublicWriteAccess(true);
    ParseACL.setDefaultACL(defaultACL, true);
    Log.d(TAG, "Parse ready");
  }

  public static App getInstance(){
    return instance;
  }
}

SplashActivity

public class SplashActivity extends AppCompatActivity {

    private static final String TAG = "Splash";
    private boolean firstTime = true;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Hide title bar
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_splash);

        firstTime = getSharedPreferences(Constants.GENERAL_SHARED_PREFS, MODE_PRIVATE)
                .getBoolean(Constants.FIRSTTIME, true);


        if (isLoggedIn())
            if (firstTime)
                startActivity(new Intent(SplashActivity.this, FirstTimeActivity.class));
            else
                startActivity(new Intent(SplashActivity.this, MenuActivity.class));

        else {
            Log.d(TAG, "Calling Home");
            startActivity(new Intent(SplashActivity.this, WelcomeActivity.class));
            finish();
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    public boolean isLoggedIn() {
        AccessToken accessToken = AccessToken.getCurrentAccessToken();
        String parseSession = ParseUser.getCurrentUser().getSessionToken();
        return parseSession != null;
    }
}

2 个答案:

答案 0 :(得分:6)

您的堆栈跟踪链接{AOSP中的to this class

我认为此次崩溃与您的应用无关,但是作为Launcher类中的错误。尝试从USB调试安装,看看是否有效。

但仍有一些细节模糊不清。这些行(从stacktrace的底部到顶部)是导致com.android.launcher2包中出现问题的行:

https://android.googlesource.com/platform/packages/apps/Launcher2/+/android-4.2.2_r1/src/com/android/launcher2/AppsCustomizePagedView.java#584

https://android.googlesource.com/platform/packages/apps/Launcher2/+/master/src/com/android/launcher2/Launcher.java#2469

https://android.googlesource.com/platform/packages/apps/Launcher2/+/master/src/com/android/launcher2/Launcher.java#2442

从这个错误中,我假设您使用的是Nexus或Pixel(或任何带有未经修改的源代码的设备,意思是股票安卓。)。

从我从这个错误中可以看出,不是与您的应用相关的错误。它似乎是您正在使用的启动器的问题。尝试从USB调试安装,或更改启动器,看看是否有效。尝试重新启动设备。

此外,根据我的代码,我们正在使用无可分类

答案 1 :(得分:1)

即时运行与Android模拟器失去连接时,也会导致此错误,因此模拟器中不会保留新的应用更改。

再次运行应用程序将解决问题。