活跃的Android在Lollipop上崩溃而不是在kitkat中

时间:2015-07-31 08:28:58

标签: android activeandroid

我在lollipop设备上运行应用程序时遇到NoClassDefFoundError。但是在kitkat版本中,应用程序工作正常。

我在下面的代码中指出了错误行。

堆栈跟踪:

07-31 02:48:23.337  13673-13673/com.ms.ha E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.ms.ha, PID: 13673
    java.lang.NoClassDefFoundError: com.parse.ParseOkHttpClient$CountingOkHttpRequestBody
            at java.lang.Class.classForName(Native Method)
            at java.lang.Class.forName(Class.java:308)
            at com.activeandroid.ReflectionUtils.getModelClasses(ReflectionUtils.java:83)
            at com.activeandroid.DatabaseHelper.onCreate(DatabaseHelper.java:46)
            at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:251)
            at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
            at com.activeandroid.Registry.openDatabase(Registry.java:149)
            at com.activeandroid.Registry.initialize(Registry.java:107)
            at com.activeandroid.ActiveAndroid.initialize(ActiveAndroid.java:8)
            at com.ms.ha.fragment.HomeFirstFragment.onCreateView(HomeFirstFragment.java:73)
            at android.app.Fragment.performCreateView(Fragment.java:2053)
            at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:894)
            at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
            at android.app.BackStackRecord.run(BackStackRecord.java:833)
            at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1452)
            at android.app.Activity.performStart(Activity.java:5948)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2261)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

HomeFirstFragment.java:

public class HomeFirstFragment extends BaseFragment implements OnClickListener {


    SharedPreferences prefdatabase;
    private static String DB_PATH = "/data/data/com.ms.ha/databases/";
    private static final String DATABASE_NAME = "appdb";
    SharedPreferences.Editor eDIT;
    private String path = Environment.getExternalStorageDirectory()
            .getAbsolutePath() + "/AndroidApp";



    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragmetn_home, container, false);


        if (file.exists())
        {
            try {

                ActiveAndroid.initialize(getActivity()); ----> Error line
                initializeDatabase();
            } catch (Exception e) {

            }
            eDIT.putString("Value","true");
            eDIT.commit();
        } else {
            System.out.println("2ND");
            try {

                eDIT.putString("Value","true");
                eDIT.commit();
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
        }

        return view;
    }
 }

清单:

 <application
        android:name="com.ms.ha.activity.Application"
        android:allowBackup="true"
        android:icon="@drawable/icon_114x114"
        android:label="@string/app_name"
        android:windowSoftInputMode="stateHidden|adjustResize"
        android:theme="@style/AppTheme">

  .....
  .....


  <meta-data
            android:name="AA_DB_NAME"
            android:value="appdb" />
        <meta-data
            android:name="AA_DB_VERSION"
            android:value="1" />

  </application>

Application.java:

public class Application extends android.app.Application {

  public Application() {

  }

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

    // Initialize the Parse SDK.

    Parse.initialize(this, "", "");

    PushService.setDefaultPushCallback(this, MainActivity.class);

    ParseInstallation.getCurrentInstallation().saveInBackground();


  }
}

的build.gradle:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.0.+'
    compile files('libs/Parse-1.9.3.jar')
    compile files('libs/bolts-android-1.2.0.jar')
    compile files('libs/activeandroid-3.0.jar')     

}

我不知道为什么它在kitkat版本中工作而不是在棒棒糖版本中。我已经将appcompat lib更新为22.但是在运行时仍然发生错误。任何人都可以帮助我。谢谢。

2 个答案:

答案 0 :(得分:1)

我遇到了同样的问题。但我下载测试版并构建它。一切都很好。 从here下载测试版3.1。

答案 1 :(得分:1)

检查您之前是否在Lollipop上安装了应用程序,因此您必须在assetets中使用migration .sql文件或删除设备上的所有应用程序数据,然后安装新的应用程序版本。