Android-job: Proguard config

Created on 13 Jul 2016  路  13Comments  路  Source: evernote/android-job

This is my service config:


       <service
            android:name="com.evernote.android.job.gcm.PlatformGcmService"
            android:exported="true"
            android:permission="com.google.android.gms.permission.BIND_NETWORK_TASK_SERVICE"
            android:process=":updater"
            >
            <intent-filter>
                <action android:name="com.google.android.gms.gcm.ACTION_TASK_READY"/>
            </intent-filter>
        </service>

proguard:
-keep class com.evernote.android.job.gcm.PlatformGcmService { *; }

exception:

FATAL EXCEPTION: main
Process: com.example.app:updater, PID: 26258
java.lang.RuntimeException: Unable to instantiate service com.evernote.android.job.gcm.PlatformGcmService: java.lang.ClassNotFoundException: Didn't find class "com.evernote.android.job.gcm.PlatformGcmService" on path: DexPathList[[zip file "/data/app/com.example.app-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.app-2/lib/x86, /vendor/lib, /system/lib]]
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2746)
at android.app.ActivityThread.access$1800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1386)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
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:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.evernote.android.job.gcm.PlatformGcmService" on path: DexPathList[[zip file "/data/app/com.example.app-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.app-2/lib/x86, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2743)
at android.app.ActivityThread.access$1800(ActivityThread.java:151)聽
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1386)聽
at android.os.Handler.dispatchMessage(Handler.java:102)聽
at android.os.Looper.loop(Looper.java:135)聽
at android.app.ActivityThread.main(ActivityThread.java:5254)聽
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:903)聽
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)聽
Suppressed: java.lang.NoClassDefFoundError: com.evernote.android.job.gcm.PlatformGcmService
at dalvik.system.DexFile.defineClassNative(Native Method)
at dalvik.system.DexFile.defineClass(DexFile.java:226)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
at dalvik.system.DexPathList.findClass(DexPathList.java:321)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
... 12 more
Suppressed: java.lang.ClassNotFoundException: com.evernote.android.job.gcm.PlatformGcmService
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 11 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
help wanted question

All 13 comments

Are you sure that you've added the GCM dependency?

dependencies {
    compile 'com.google.android.gms:play-services-gcm:8.4.0' // or newer
}

Also try to remove the process attribute. I've never tested to run the services with different processes and I wouldn't recommend it.

Also test the proguard config with

-keep public class com.evernote.android.job.gcm.PlatformGcmService {
  public protected private *;
}

Not sure if that helps.

Thanks for response.
My bad. One of our team members accidently had deleted the compile 'com.google.android.gms:play-services-gcm:8.4.0' line from the gradle file.

Why does the readme for this project not mention that you need this dependency?

It's optional and not required. In my own app if don't need the Google Play Services, then I wouldn't want that this library requires the Play Services

Well, it works for me without the dependency on Android 4.4, but I need it on Android 7.1.1, otherwise I will get Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.gcm.GcmTaskService"

I tested it this moment and don't get the exception. Does the library crash or is this just a warning? Can you add a full log?

Interesting, I have attached the log file. First a info/warning then it crashes.

evernote_android-job_gcm_error.txt

Is it possible that you included the Play Services and switched to Firebase? Your crash looks really similar to another I saw a while ago. If yes, then this should help you. Unfortunately, there is no better way to do this.

Thank you I will test it! 馃憤 I used Firebase JobDispatcher with that dependency before, but had to switch to evernote android-job due to I don't have Google Play Services installed on all internal devices we use.

That makes sense. Follow the instruction in the link and it shouldn't crash anymore.

There is no crash, but I can still see the ugly stacktrace coming from the following line: https://github.com/evernote/android-job/blob/1dfcca57615f80bd816bae0b8e19df04889a0d56/library/src/main/java/com/evernote/android/job/util/GcmAvailableHelper.java#L55

I can see the comment "still sometimes seeing a NoClassDefFoundError here". Do you have to log the whole throwable object? Thanks for the help.

No, good idea to remove that. I'll do this as part of #165

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tatocaster picture tatocaster  路  6Comments

judemanutd picture judemanutd  路  4Comments

deviant-studio picture deviant-studio  路  5Comments

ruhul015 picture ruhul015  路  4Comments

mohamadk picture mohamadk  路  6Comments