Open Bug 1255580 Opened 8 years ago Updated 2 years ago

LeakCanary startup crash when launching from AS with localDebug build variant

Categories

(Firefox Build System :: Android Studio and Gradle Integration, defect)

defect

Tracking

(Not tracked)

People

(Reporter: Margaret, Unassigned)

Details

This goes away if I use the localOldDebug build variant. I'm running my app on an N4 running 5.1.1:

03-10 16:18:35.850 20075-20075/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                   Process: org.mozilla.fennec_leibovic, PID: 20075
                                                   java.lang.NoClassDefFoundError: Failed resolution of: Lcom/squareup/leakcanary/LeakCanary;
                                                       at org.mozilla.gecko.GeckoApplication.onCreate(GeckoApplication.java:131)
                                                       at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1012)
                                                       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4553)
                                                       at android.app.ActivityThread.access$1500(ActivityThread.java:151)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
                                                       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.squareup.leakcanary.LeakCanary" on path: DexPathList[[zip file "/data/app/org.mozilla.fennec_leibovic-1/base.apk"],nativeLibraryDirectories=[/data/app/org.mozilla.fennec_leibovic-1/lib/arm, /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 org.mozilla.gecko.GeckoApplication.onCreate(GeckoApplication.java:131) 
                                                       at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1012) 
                                                       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4553) 
                                                       at android.app.ActivityThread.access$1500(ActivityThread.java:151) 
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364) 
                                                       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.ClassNotFoundException: com.squareup.leakcanary.LeakCanary
                                                       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)
                                                       		... 13 more
                                                    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
I had a contributor see the same thing in private email.  I can't explain this.

sebastian, any thoughts?
Flags: needinfo?(s.kaspari)
Mh, I have never seen this and no good explanation yet.

Does this still happen after running "Clean Project" or "Rebuild project"?

What version of the Android build tools are you using?
Flags: needinfo?(s.kaspari)
Hello!
I had the same problem bug 1255394 comment 25, and got the only when trying to build using Android Studio !(the build was successful with mach !), I have tried gradle clean and rebuild multiple times, artifact clear-cache and install multiple times too, but without a success...
(In reply to Mouaad from comment #3)
> Hello!
> I had the same problem bug 1255394 comment 25, and got the only when trying
> to build using Android Studio !(the build was successful with mach !), I
> have tried gradle clean and rebuild multiple times, artifact clear-cache and
> install multiple times too, but without a success...

Hi Mouaad -- yes, |mach build| and |mach gradle ...| are distinct.  The Gradle dex process is just flaky; I don't understand why we trigger this.  localOld appears to always work.
I just saw this too. I built on the command line using "mach gradle build" and then later in Android Studio I always got this startup bug. It went away after selecting "Build -> Rebuild Project".
(In reply to Sebastian Kaspari (:sebastian) from comment #5)
> I just saw this too. I built on the command line using "mach gradle build"
> and then later in Android Studio I always got this startup bug. It went away
> after selecting "Build -> Rebuild Project".

For the record, I think there are bad interactions with certain dex options (present in local but not localOld) and the Gradle daemon.  I can't explain them.

I am knee-deep in other Gradle things right now but intend to drop local vs. localOld and the dex options at some point.  I'd take a patch to do so now.
Product: Firefox for Android → Firefox Build System
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.