应用程序重新启动时,Parse.enableLocalDatastore抛出异常

时间:2015-04-05 11:19:04

标签: java android parse-platform

我正在与众所周知的Parse.enableLocalDatastore / Parse.initialize问题作斗争。

第一次调用这些,即使我从MainActivity调用它们也很顺利,但是在重新启动后Parse.enableLocalDatastore会抛出一个异常,说首先应该调用Parse.enableLocalDatastore:)))

我根据几条建议改变了我的代码。我创建了一个MyApp类并将调用移到那里。然后我尝试修改AndroidManifest.xml。问题是,我不知道android的正确格式是什么:tag的name属性。

这是我的应用程序类,从“工作”示例中复制粘贴:

    package com.android.adorjan.iskolaesjatek;

    import android.app.Application;
    import com.parse.Parse;

    public class MyApp extends Application {

        @Override
        public void onCreate(){
            super.onCreate();
            // Enable Local Datastore.
            Parse.enableLocalDatastore(this);
            //This is what Parse was complaining about
            Parse.initialize(this, "KYZET9yhUrMQHHB", "1chhdVIUyMWkcXTlQdJl");
        }
    }

这是AndroidManifest.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.adorjan.iskolaesjatek" >

    <application
        android:name="com.android.adorjan.iskolaesjatek.MyApp"
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        >

但是android:name的价值是错误的,Android工作室说'class'或'interface'是预期的。我不知道如何拼写它。

我也试过:“。MyApp”,“com.android.app.MyApp”以及其他许多愚蠢。

感谢您的帮助。一个真正有效的例子就是奖金。

2 个答案:

答案 0 :(得分:1)

简而言之,这是一个已知问题,将在下一个SDK版本中修复。

https://groups.google.com/forum/#!topic/parse-developers/IQgQ21KOBFo

答案 1 :(得分:0)

You find the answer but is good to not post your Parse credentials like that:

Parse.initialize(this, "KYZET9yhUrMQHHB", "1chhdVIUyMWkcXTlQdJl");