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

Active Android crashing on Lollipop not in kitkat

我在 运行 棒棒糖 device.But kitkat 版本的应用程序上遇到了 NoClassDefFoundError,应用程序工作正常。

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

堆栈跟踪:

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.access0(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 版本而不是 lollipop 中工作 version.I 已将 appcompat lib 更新为 22.But runtime.Anyone 仍然发生错误可以帮助我 this.Thank你.

我遇到了同样的问题。但我下载了测试版并构建了它。一切正常。 从 here.

下载测试版 3.1

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