Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeException when launch my app #21

Open
nicopasso opened this issue Apr 17, 2016 · 8 comments
Open

RuntimeException when launch my app #21

nicopasso opened this issue Apr 17, 2016 · 8 comments

Comments

@nicopasso
Copy link

Hi,
my app crashes with this stack trace.

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nicopasso.android.debug/com.nicopasso.android.ui.start.StartingActivity}: java.lang.RuntimeException: MethodsTracingManager must be initialized by init(..)
                                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                                at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                at android.os.Looper.loop(Looper.java:148)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                             Caused by: java.lang.RuntimeException: MethodsTracingManager must be initialized by init(..)
                                                                                at com.frogermcs.androiddevmetrics.internal.MethodsTracingManager.checkInitialized(MethodsTracingManager.java:90)
                                                                                at com.frogermcs.androiddevmetrics.internal.MethodsTracingManager.shouldTraceMethod(MethodsTracingManager.java:84)
                                                                                at com.frogermcs.androiddevmetrics.aspect.ActivityLifecycleAnalyzer.executeWithTracingIfEnabled(ActivityLifecycleAnalyzer.java:77)
                                                                                at com.frogermcs.androiddevmetrics.aspect.ActivityLifecycleAnalyzer.ajc$inlineAccessMethod$com_frogermcs_androiddevmetrics_aspect_ActivityLifecycleAnalyzer$com_frogermcs_androiddevmetrics_aspect_ActivityLifecycleAnalyzer$executeWithTracingIfEnabled(ActivityLifecycleAnalyzer.java:1)
                                                                                at com.frogermcs.androiddevmetrics.aspect.ActivityLifecycleAnalyzer.logAndExecute(ActivityLifecycleAnalyzer.java:66)
                                                                                at com.nicopasso.android.ui.start.StartingActivity.onCreate(StartingActivity.java:43)
                                                                                at android.app.Activity.performCreate(Activity.java:6251)
                                                                                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476at android.app.ActivityThread.-wrap11(ActivityThread.javaat android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344at android.os.Handler.dispatchMessage(Handler.java:102at android.os.Looper.loop(Looper.java:148at android.app.ActivityThread.main(ActivityThread.java:5417at java.lang.reflect.Method.invoke(Native Methodat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616

I've already tried to implement

MethodsTracingManager.getInstance().init(this);

in my StartingActivity as the stack trace says but still I have the same issue.

How can I solve this problem?
Thanks

@frogermcs
Copy link
Owner

Hey!

AndroidDevMetrics should be initialized in Application class, not Activity (it's too late if you would do this).

Here is example code:

public class ExampleApplication extends Application {

 @Override
 public void onCreate() {
     super.onCreate();
     //Use it only in debug builds
     if (BuildConfig.DEBUG) {
         AndroidDevMetrics.initWith(this);
     }
  }
}

@nicopasso
Copy link
Author

Yes yes I've done that of course :)

@novalu
Copy link

novalu commented May 5, 2016

I have same issue with 4.0, getting that runtime exception.

I've tried AndroidDevMetrics.initWith(this); and MethodsTracingManager.getInstance().init(this); in Application onCreate() but with no success.

I have errors only in version 0.4, version 0.3.1 is working. Thanks.

@tokou
Copy link

tokou commented Jun 24, 2016

I have the same issue with 4.0

It crashes when I do not initialize it. It shouldn't it should just do nothing.

This behavior was correct in 0.3.1

@Max01010101010101
Copy link

Me too... uff.. i would like to test AndroidDevMetrics

@ar-g
Copy link

ar-g commented Aug 25, 2016

It crashes when I put

if (isInDebugMode) {
      AndroidDevMetrics.initWith(this);
    }

on top of onCreate of all initializations, but it fine when I put it at the end. It appears that it clashes with some other initialisations. I can say that I have other ActivityLifecycleListeners might be because of it.

@drd
Copy link

drd commented Dec 11, 2017

The plugin for android dev metrics assumes you will be using it for any debug build. I ran into this issue because I was disabling it when certain properties were passed to gradle. In order for this to work, I did following:

build:

In app/build.gradle, conditionally apply plugin based on a property passed through gradle (could be any condition of course):

if (project.hasProperty('ENABLE_TOOLS')) {
  apply plugin: 'com.frogermcs.androiddevmetrics'
}

If the tool is disabled, add a debugCompile dependency on the noop package:

if (project.hasProperty('ENABLE_TOOLS')) {
  debugCompile 'com.frogermcs.androiddevmetrics:androiddevmetrics-runtime-noop:0.5'
}

If you do not have an Application subclass for Debug builds:

Only initialize AndroidDevMetrics for debug builds:

onCreate() {
  // ...
  if (BuildConfig.DEBUG) {
    AndroidDevMetrics.initWith(this);
  }
  // ...
}

If you do have a DebugApplication class:

Always initialize for debug builds:

onCreate() {
  // ...
  AndroidDevMetrics.initWith(this);
  // ...
}

@leeGYPlus
Copy link

i meet this problem when i update my gradle`s version, i solve this problem by decreasing the gradle's version .Maybe the problem is the compatibility of the author's plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants