1

I am trying to integrate my library project with one of the application and getting following exception as follows,

E/AndroidRuntime(21990): FATAL EXCEPTION: IntentService[SchedulingService]
E/AndroidRuntime(21990): Process: com.newton.message, PID: 21990
E/AndroidRuntime(21990): java.lang.RuntimeException: Parcelable encountered ClassNotFoundException reading a Serializable object (name = com.app.library.database.a$a)
E/AndroidRuntime(21990):    at android.os.Parcel.readSerializable(Parcel.java:2384)
E/AndroidRuntime(21990):    at android.os.Parcel.readValue(Parcel.java:2203)
E/AndroidRuntime(21990):    at android.os.Parcel.readArrayMapInternal(Parcel.java:2485)
E/AndroidRuntime(21990):    at android.os.BaseBundle.unparcel(BaseBundle.java:221)
E/AndroidRuntime(21990):    at android.os.Bundle.getParcelable(Bundle.java:755)
E/AndroidRuntime(21990):    at android.content.Intent.getParcelableExtra(Intent.java:5214)
E/AndroidRuntime(21990):    at com.app.library.AlarmSchedulingService.onHandleIntent(Unknown Source)
E/AndroidRuntime(21990):    at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
E/AndroidRuntime(21990):    at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(21990):    at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(21990):    at android.os.HandlerThread.run(HandlerThread.java:61)
E/AndroidRuntime(21990): Caused by: java.lang.ClassNotFoundException: com.app.library.database.a$a
E/AndroidRuntime(21990):    at java.lang.Class.classForName(Native Method)
E/AndroidRuntime(21990):    at java.lang.Class.forName(Class.java:309)
E/AndroidRuntime(21990):    at android.os.Parcel$2.resolveClass(Parcel.java:2370)
E/AndroidRuntime(21990):    at java.io.ObjectInputStream.readEnumDescInternal(ObjectInputStream.java:1551)
E/AndroidRuntime(21990):    at java.io.ObjectInputStream.readEnumDesc(ObjectInputStream.java:1532)
E/AndroidRuntime(21990):    at java.io.ObjectInputStream.readEnum(ObjectInputStream.java:1577)
E/AndroidRuntime(21990):    at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:767)
E/AndroidRuntime(21990):    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1983)
E/AndroidRuntime(21990):    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1940)
E/AndroidRuntime(21990):    at android.os.Parcel.readSerializable(Parcel.java:2378)
E/AndroidRuntime(21990):    ... 10 more
E/AndroidRuntime(21990): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.app.library.database.a$a" on path: DexPathList[[zip file "/data/app/com.cube26.osp.message-2/base.apk"],nativeLibraryDirectories=[/data/app/com.cube26.osp.message-2/lib/arm, /vendor/lib, /system/lib]]
E/AndroidRuntime(21990):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/AndroidRuntime(21990):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/AndroidRuntime(21990):    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
E/AndroidRuntime(21990):    ... 20 more
E/AndroidRuntime(21990):    Suppressed: java.lang.ClassNotFoundException: com.app.library.database.a$a
E/AndroidRuntime(21990):        at java.lang.Class.classForName(Native Method)
E/AndroidRuntime(21990):        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
E/AndroidRuntime(21990):        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
E/AndroidRuntime(21990):        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
E/AndroidRuntime(21990):        ... 21 more
E/AndroidRuntime(21990):    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
E/SQLiteLog(21767): (284) automatic index on view_events(_id)

Library usage:

I have a AlarmScheduling tasks in my app and I am posting the data to the server once in a day.

Use cases:

  1. I already have an app in the playstore, if i try to update my library and release it as a new version, then I am getting this crash once if i change the system time for AlarmSchedulingTasks.

  2. The app is working fine if i clear the data or reboot the device. Also I could able to perform my AlarmScheduling tasks successfully.

What i tried:

I almost tried all the possible solutions listed in SO for the same error threads like as follows:

Android Studio: ClassNotFoundException

Java.lang.ClassNotFoundException after Android studio update

java.lang.ClassNotFoundException: Didn't find class on path: dexpathlist

Android ClassNotFoundException: Didn't find class on path

Android ClassNotFoundException: Didn't find class on path

ClassNotFoundException after starting app

  1. Manifest package name merging issue.

  2. In correct version of Android studio used. (i.e unstable version of canary channel)

  3. Gradle build version mismatch with library and app project.

  4. App method over count limit reached.

  5. Proguard build issue while creating multiple dexes.

  6. Also found some weird and useless solutions like cleaning the project, renaming lib folder into libs, deleting .idea, Intellij related folders.

  7. Multiple occurence of library project cache.

  8. Behaviour of alarm scheduling tasks with serializable or parcelable intent. (Might be an issue but works fine if i clear the data)

I tried everything but unable to solve this issue. Because of this I am completely stuck up and couldn't release the next version into the play store. Any sort of solutions and tips would be very helpful to me. Thanks in advance. I am posting my code for your reference as below

AlarmSchedulingServiceTest.java

public class AlarmSchedulingServiceTest extends IntentService {
    private DBAccess mDBAccess;

    public AlarmSchedulingServiceTest() {
        super("SchedulingService");
    }

    @Override
    protected void onHandleIntent(Intent intent) {

        CLog.i(Constants.LOG_TAG_LIBRARY," $$$ ALARM INITIATED $$$");

        if(intent != null) {

            Bundle bundle = intent.getParcelableExtra(Constants.BUNDLE.SEND_MODE);

            int mode = bundle.getInt(Constants.INTENT.SEND_MODE);



            sendData();
        }

    }

AlarmReceiver.java

public class AlarmReceiver {
    private AlarmManager alarmMgr;
    private PendingIntent alarmIntent;
    private Intent mIntent;


    public void setAlarm(Context context, int mode) {
        alarmMgr = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
        mIntent = new Intent(context, AlarmSchedulingServiceTest.class);


        Bundle bundle = new Bundle();


        bundle.putInt(Constants.INTENT.SEND_MODE,mode);
        mIntent.putExtra(Constants.BUNDLE.SEND_MODE, bundle);

        alarmIntent = PendingIntent.getService(context, mode, mIntent, PendingIntent.FLAG_UPDATE_CURRENT);

        alarmMgr.setInexactRepeating(AlarmManager.RTC_WAKEUP,
                        (long) 1 * 24 * 60 * 60 * 1000),
                        (long) 1 * 24 * 60 * 60 * 1000), alarmIntent);

    }

}
Community
  • 1
  • 1
Chandru
  • 5,954
  • 11
  • 45
  • 85

0 Answers0