Application crashes in onCreate due to newrelic exception - android

I've created an Android app using Android Studio beta 0.8.2 and all was going well until the last few days when i started getting this exception just as i run it:
07-24 14:50:11.044 1176-1176/com.vme.vme I/Crashlytics﹕ Initializing Crashlytics 1.1.11.10
07-24 14:50:11.764 2325-2325/system_process D/MobileDataStateTracker﹕ default: Broadcast received: android.intent.action.ANY_DATA_STATE apnType=default
07-24 14:50:11.769 2325-2325/system_process D/MobileDataStateTracker﹕ default: Received state=CONNECTED, old=CONNECTED, reason=(unspecified)
07-24 14:50:15.079 1176-1176/com.vme.vme W/Crashlytics﹕ Crashlytics initialization was not completed in the allotted time.
07-24 14:50:15.104 1176-1176/com.vme.vme I/dalvikvm﹕ Could not find method com.newrelic.agent.android.instrumentation.Instrumentation.openConnection, referenced from method com.vme.vme.model.network.httpClient.BasicRequestHandler.openConnection
07-24 14:50:15.104 1176-1176/com.vme.vme W/dalvikvm﹕ VFY: unable to resolve static method 30466: Lcom/newrelic/agent/android/instrumentation/Instrumentation;.openConnection (Ljava/net/URLConnection;)Ljava/net/URLConnection;
07-24 14:50:15.104 1176-1176/com.vme.vme D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0009
07-24 14:50:15.114 1176-1176/com.vme.vme I/dalvikvm﹕ Could not find method com.newrelic.agent.android.background.ApplicationStateMonitor.getInstance, referenced from method com.vme.vme.ui.activities_and_fragments.home.bases.VMEBaseActivity.onStart
07-24 14:50:15.114 1176-1176/com.vme.vme W/dalvikvm﹕ VFY: unable to resolve static method 30464: Lcom/newrelic/agent/android/background/ApplicationStateMonitor;.getInstance ()Lcom/newrelic/agent/android/background/ApplicationStateMonitor;
07-24 14:50:15.114 1176-1176/com.vme.vme D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0000
07-24 14:50:15.114 1176-1176/com.vme.vme I/dalvikvm﹕ Could not find method com.newrelic.agent.android.background.ApplicationStateMonitor.getInstance, referenced from method com.vme.vme.ui.activities_and_fragments.home.bases.VMEBaseActivity.onStop
07-24 14:50:15.114 1176-1176/com.vme.vme W/dalvikvm﹕ VFY: unable to resolve static method 30464: Lcom/newrelic/agent/android/background/ApplicationStateMonitor;.getInstance ()Lcom/newrelic/agent/android/background/ApplicationStateMonitor;
07-24 14:50:15.114 1176-1176/com.vme.vme D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0003
07-24 14:50:15.309 1176-1176/com.vme.vme D/AndroidRuntime﹕ Shutting down VM
07-24 14:50:15.309 1176-1176/com.vme.vme W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41797c80)
07-24 14:50:15.429 1176-1176/com.vme.vme E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.vme.vme, PID: 1176
java.lang.NoClassDefFoundError: com.newrelic.agent.android.background.ApplicationStateMonitor
at com.vme.vme.ui.activities_and_fragments.home.bases.VMEBaseActivity.onStart(VMEBaseActivity.java)
I never used newrelic in this project, i've searched "newrelic" and can't find it in the whole project.
Things i can share also:
I have 2 instance of the studio running all the time, in the other project **i am using newrelic - version 2.426.0 **
it's happened on Galaxy S3 and Note 2.
Cleaning, rebuilding, closing the studio, uninstalling and reinstalling are fixing the issue. BUT IT COME BACK EVERY ONCE A DAY :(
Please help...

Build your New Relic enabled project
Run gradle --stop from the terminal/command line
Open your non-NR enabled app and clean & rebuild
Run the app
If you still get messages about New Relic in your non-NR app, you can go to the ~/.gradle/caches and remove it. Then try the above steps again.
Newer versions of gradle utilize a daemon which caches New Relic instrumentation. So this will stop the daemon and allow the app to build.
You will also want to upgrade to the latest version of New Relic. 2.426.0 is many versions behind. Go here: http://docs.newrelic.com/docs/releases/android

The thing that fixed for me was upgrading to the newest gradle version 2.1 and android plugin version to 0.13.3 from right click project folder -> module settings

If you still get messages about New Relic in your non-NR app, you can go to the project directory and remove .gradle directory and re-build project.

Related

Many error messages after updating Gradle plugin for Android to 2.0.0

Since updating Gradle Plugin for Android to 2.0.0, there are many error messages in all projects in Android Studio 2.0.
I would like to know the reason for this and possibly how to avoid it.
This seems not related to the code of my projects, as the errors also show up in an empty or blank project. There are in fact hundreds of lines of warnings and errors, even before first call of onCreate() in a blank project.
This is a small excerpt of the logged errors:
I/dalvikvm: Could not find method android.content.Context.getSystemService, referenced from method com.example.test.MainActivity.access$super
W/dalvikvm: VFY: unable to resolve virtual method 450: Landroid/content/Context;.getSystemService (Ljava/lang/Class;)Ljava/lang/Object;
D/dalvikvm: VFY: replacing opcode 0x6f at 0x004b
I/dalvikvm: Could not find method android.app.Activity.stopLockTask, referenced from method com.example.test.MainActivity.access$super
W/dalvikvm: VFY: unable to resolve virtual method 246: Landroid/app/Activity;.stopLockTask ()V
D/dalvikvm: VFY: replacing opcode 0x6f at 0x00b9
E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.example.test.MainActivity.access$super
W/dalvikvm: VFY: unable to resolve check-cast 229 (Landroid/os/PersistableBundle;) in Lcom/example/test/MainActivity;
D/dalvikvm: VFY: replacing opcode 0x1f at 0x00f1
I/dalvikvm: Could not find method android.content.Context.getColorStateList, referenced from method com.example.test.MainActivity.access$super
W/dalvikvm: VFY: unable to resolve virtual method 432: Landroid/content/Context;.getColorStateList (I)Landroid/content/res/ColorStateList;
D/dalvikvm: VFY: replacing opcode 0x6f at 0x0101
I/dalvikvm: Could not find method android.app.Activity.onVisibleBehindCanceled, referenced from method com.example.test.MainActivity.access$super
W/dalvikvm: VFY: unable to resolve virtual method 169: Landroid/app/Activity;.onVisibleBehindCanceled ()V
D/dalvikvm: VFY: replacing opcode 0x6f at 0x0111
I/dalvikvm: Could not find method android.app.Activity.onWindowStartingActionMode, referenced from method com.example.test.MainActivity.access$super
W/dalvikvm: VFY: unable to resolve virtual method 173: Landroid/app/Activity;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
D/dalvikvm: VFY: replacing opcode 0x6f at 0x0137
E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.example.test.MainActivity.access$super
W/dalvikvm: VFY: unable to resolve check-cast 229 (Landroid/os/PersistableBundle;) in Lcom/example/test/MainActivity;
D/dalvikvm: VFY: replacing opcode 0x1f at 0x019a
E/dalvikvm: Could not find class 'android.media.session.MediaController', referenced from method com.example.test.MainActivity.access$super
With Gradle Plugin 1.5.0 everything went fine.
With Gradle Plugin 2.0.0 these errors come up.
I updated to 2.0.0, because Android Studio 2.0 recommends the update:
The project is using an old version of the Android Gradle plugin. To
take advantage of all the latest features, such as Instant Run, we
strongly recommend that you update the Android Gradle plugin to
version 2.0.0.
As there are hundreds of lines of errors at the start of any app and many more later, this makes using logcat for debugging extremely difficult.
I have tried to downgrade to 1.5.0 as described in this answer. This does actually prevent the errors to come up. Anyhow, I do not regard this as a solution, but rather a work-around, as I cannot use the new features of plugin 2.0.0.
Yes, unfortunately, the Android team decided to use the INFO rather than VERBOSE tag on these messages:
https://code.google.com/p/android/issues/detail?id=198567
The solution is to create a custom filter. Give it a [Filter Name]. Click [Edit Filter Configuration] on the right of the Android Monitor window toolbar. In the [Log Tag], enter "^(?!(dalvikvm))", minus the quotes, and make sure [Regex] is Checked next to it. In the [Package Name] field, enter your top-level package name (e.g. com.example.me). Select Debug for [Log Level] and click [OK]. Finally make sure to select your new filter back in the toolbar.

Could not find class 'com.google.android.gms.ads.AdView

I'm using Android Studio. I have added the googleAdMobAdsdk6-4-1.jar to the project in my previously added libs folder. I can expand the library file and actually navigate to the AdView class. It compiles with no problem but when I run it It crashes. Any assistance appreciated.
12-15 21:35:40.581 5375-5375/? E/dalvikvm﹕ Could not find class 'com.google.android.gms.ads.AdView', referenced from method net.kritico.todolist.ToDoListActivity.onCreate
12-15 21:35:40.581 5375-5375/? W/dalvikvm﹕ VFY: unable to resolve new-instance 996 (Lcom/google/android/gms/ads/AdView;) in Lnet/kritico/todolist/ToDoListActivity;
12-15 21:35:40.581 5375-5375/? D/dalvikvm﹕ VFY: replacing opcode 0x22 at 0x0037
12-15 21:35:40.585 5375-5375/? D/dalvikvm﹕ DexOpt: unable to opt direct call 0x2034 at 0x39 in Lnet/kritico/todolist/ToDoListActivity;.onCreate
12-15 21:35:40.585 5375-5375/? I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0b0b at 0x47 in Lnet/kritico/todolist/ToDoListActivity;.onCreate
12-15 21:35:40.585 5375-5375/? D/dalvikvm﹕ DexOpt: unable to opt direct call 0x2031 at 0x5c in Lnet/kritico/todolist/ToDoListActivity;.onCreate
12-15 21:35:40.597 5375-5375/? I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0b0a at 0x5f in Lnet/kritico/todolist/ToDoListActivity;.onCreate
12-15 21:35:40.765 5375-5375/? D/AndroidRuntime﹕ Shutting down VM
12-15 21:35:40.765 5375-5375/? W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xa617b908)
12-15 21:35:40.789 5375-5375/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{net.kritico.todolist/net.kritico.todolist.ToDoListActivity}: android.view.InflateException: Binary XML file line #19: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
Your XML references com.google.android.gms.ads.AdView (see stacktrace) which is contained in the Google Play Services library and is how Admob is now packaged.
But your have included Admob-6.4.1 whcih is the old Admob SDK and the Admob classes there are in a different package and have slightly different signatures.
Remove Admob-6.4.1 from your project and use Google play Services instead.
See https://developers.google.com/mobile-ads-sdk/docs/admob/fundamentals#play
Remove the jar from your libs folder (That sdk is now deprecated). You should use Google play services.
After removing the jar. Clean your project and add the following under dependencies in your app level build.gradle.
compile 'com.google.android.gms:play-services-ads:8.4.0'
Sync your project as prompted after which you should be good to go.
Use this latest library:
implementation 'com.google.android.gms:play-services-ads:19.3.0'
And feel free to read the admob documentation.
I'm using react-native-admob-next and seriously I face lot of problems in implementaion
i do just :-
npm i react-native-admob-next
then open node_modules then find react-native-admob-next/android/build.gradle i
change dependencies below is code : -
just add some lines
dependencies {
//noinspection GradleDynamicVersion
// implementation 'com.intellij:annotations:+#jar'
// implementation 'com.google.android.gms:play-services-ads:20.2.0'
implementation 'com.facebook.react:react-native:+'
implementation('com.google.android.gms:play-services-ads:+')
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.ads.mediation:facebook:+'
}

java.lang.NoClassDefFoundError: com.applovin.sdk.AppLovinSdk

Hi I get the following exception: 06-10 10:53:36.643: E/AndroidRuntime(10415): java.lang.NoClassDefFoundError: com.applovin.sdk.AppLovinSdk I imported the external lib and also copy pasted the lib to /libs folder. but I still get this error. I imported the lib as : import com.applovin.sdk.AppLovinSdk; and the program falls at this line : AppLovinSdk.initializeSdk(this); . What am I missing?
lines before the error:
06-10 10:53:36.603: I/dalvikvm(10415): Could not find method com.applovin.sdk.AppLovinSdk.initializeSdk, referenced from method sk.wblade.psy.GalleryActivity.onCreate
06-10 10:53:36.603: W/dalvikvm(10415): VFY: unable to resolve static method 230: Lcom/applovin/sdk/AppLovinSdk;.initializeSdk (Landroid/content/Context;)V
06-10 10:53:36.603: D/dalvikvm(10415): VFY: replacing opcode 0x71 at 0x0003
06-10 10:53:36.613: I/dalvikvm(10415): Could not find method com.applovin.adview.AppLovinInterstitialAd.show, referenced from method sk.wblade.psy.GalleryActivity.onResume
06-10 10:53:36.613: W/dalvikvm(10415): VFY: unable to resolve static method 229: Lcom/applovin/adview/AppLovinInterstitialAd;.show (Landroid/app/Activity;)V
06-10 10:53:36.613: D/dalvikvm(10415): VFY: replacing opcode 0x71 at 0x0012
06-10 10:53:36.633: D/AndroidRuntime(10415): Shutting down VM
06-10 10:53:36.633: W/dalvikvm(10415): threadid=1: thread exiting with uncaught exception (group=0x40a9b228)
project right click properties-> Java BuildPath select Library and add external .jar the follow these step.
Go to Project->Properties->Java Build Path than select Order and export tab. Set external .jar library checked and up it into top of the list. And clean and rebuild..It works for most of the cases
There is a bug in ADT 22. If you use this you have to check the Android Private Libraies in the Order and Export tab in Preferences/Java Build Path.
You can read about this in detail here:
Libraries do not get added to APK anymore after upgrade to ADT 22

Why is android.util.LruCache.* not found when using android-support-v4?

I am writing a project that uses LruCache, which is included in the android-support-v4.jar compat library. When running on devices with JB, the code works fine, but when I run it on my Droid X with GB, the app dies with the following errors:
I/dalvikvm(2459): Could not find method android.util.LruCache.put, referenced from method blah.blah.Utility.getBitmap
W/dalvikvm(2459): VFY: unable to resolve virtual method 2641: Landroid/util/LruCache;.put (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
D/dalvikvm(2459): VFY: replacing opcode 0x6e at 0x0026
... [repeats similar lines] ...
W/dalvikvm(2459): Unable to resolve superclass of Lblah/blah/Utility$1; (353)
W/dalvikvm(2459): Link of class 'Lblah/blah/Utility$1;' failed
E/dalvikvm(2459): Could not find class 'blah.blah.Utility$1', referenced from method blah.blah.Utility.initCaches
W/dalvikvm(2459): VFY: unable to resolve new-instance 559 (Lblah/blah/Utility$1;) in Lblah/blah/Utility;
D/dalvikvm(2459): VFY: replacing opcode 0x22 at 0x000d
D/dalvikvm(2459): VFY: dead code 0x000f-002c in Lblah/blah/Utility;.initCaches (ILandroid/content/Context;)V
I/dalvikvm(2459): Could not find method android.util.LruCache.get, referenced from method blah.blah.Utility.mCacheGet
W/dalvikvm(2459): VFY: unable to resolve virtual method 2640: Landroid/util/LruCache;.get (Ljava/lang/Object;)Ljava/lang/Object;
D/dalvikvm(2459): VFY: replacing opcode 0x6e at 0x0008
D/dalvikvm(2459): VFY: dead code 0x000b-000e in Lblah/blah/Utility;.mCacheGet (Ljava/lang/String;)Landroid/graphics/Bitmap;
... [repeats similar lines] ...
D/AndroidRuntime(2459): Shutting down VM
W/dalvikvm(2459): threadid=1: thread exiting with uncaught exception (group=0x40018560)
E/AndroidRuntime(2459): FATAL EXCEPTION: main
E/AndroidRuntime(2459): java.lang.NoClassDefFoundError: blah.blah.Utility$1
E/AndroidRuntime(2459): at blah.blah.Utility.initCaches(Utility.java:49)
E/AndroidRuntime(2459): at blah.blah.MainActivity.onCreate(MainActivity.java:40)
... [etc] ...
W/ActivityManager(1318): Force finishing activity blah.blah/.MainActivity
Utility.java:49 looks like this:
mCache = new LruCache<String, Bitmap>( mCacheSize ) // <-- line 49 --
{
#Override
protected int sizeOf( String key, Bitmap bitmap )
{
return bitmap.getByteCount();
}
};
So everywhere I referenced LruCache or its methods causes an error. The first thing that comes to mind is that android-support-v4.jar was somehow left out of the APK file, but that doesn't look like the case. I've placed the jar file under libs/, and checking classes.dex.d after running ant debug, I see that it has added the following line:
/home/paul/workspace/blah/libs/android-support-v4.jar \
My second thought was that maybe LruCache isn't in android-support-v4, but looking at the source I see that the following source file is in there, and that it has the methods I am trying to use:
/home/paul/bin/android-sdk/extras/android/support/v4/src/java/android/support/v4/util/LruCache.java
So why isn't it found?
The classes in the support library use a different namespace.
You need to import:
import android.support.v4.util.LruCache;
or alternatively you can copy & compile LruCache.java directly into your app.

Dalvik mess with library code and project cannot runs anymore

After updating ADT and Android SDK on my machine, all my projects get errors.
Now I have this:
PS: This error happens when running the project that have a jar as dependency (it was compiled with proguard and we dont have the original sourcecode to compile it again).
W/dalvikvm(3497): VFY: unable to resolve static field 994 (storeicon) in Lcom/ww/dgs/R$drawable;
D/dalvikvm(3497): VFY: replacing opcode 0x60 at 0x0042
W/dalvikvm(3497): VFY: unable to resolve static field 987 (libraryicon) in Lcom/ww/dgs/R$drawable;
D/dalvikvm(3497): VFY: replacing opcode 0x60 at 0x0060
W/dalvikvm(3497): VFY: unable to resolve static field 1069 (mainframe) in Lcom/ww/dgs/R$layout;
D/dalvikvm(3497): VFY: replacing opcode 0x60 at 0x00b1
I/dalvikvm(3497): DexOpt: unable to optimize static field ref 0x0467 at 0x16 in Lcom/ww/sharedlibrary/e;.a
D/AndroidRuntime(3497): Shutting down VM
W/dalvikvm(3497): threadid=1: thread exiting with uncaught exception (group=0x400f8760)
E/AndroidRuntime(3497): FATAL EXCEPTION: main
E/AndroidRuntime(3497): java.lang.NoClassDefFoundError: com.ww.dgs.R$layout
E/AndroidRuntime(3497): at com.ww.mainframe.MainFrame.onCreate(Unknown Source)
E/AndroidRuntime(3497): at com.ww.iba.DigiMag.onCreate(DigiMag.java:27)
E/AndroidRuntime(3497): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
E/AndroidRuntime(3497): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1715)
E/AndroidRuntime(3497): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1767)
E/AndroidRuntime(3497): at android.app.ActivityThread.access$1500(ActivityThread.java:122)
E/AndroidRuntime(3497): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1005)
E/AndroidRuntime(3497): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(3497): at android.os.Looper.loop(Looper.java:132)
E/AndroidRuntime(3497): at android.app.ActivityThread.main(ActivityThread.java:4028)
E/AndroidRuntime(3497): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(3497): at java.lang.reflect.Method.invoke(Method.java:491)
E/AndroidRuntime(3497): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
E/AndroidRuntime(3497): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
E/AndroidRuntime(3497): at dalvik.system.NativeStart.main(Native Method)
I/dalvikvm(3497): threadid=4: reacting to signal 3
I/dalvikvm(3497): Wrote stack traces to '/data/anr/traces.txt'
The code from com.ww is inside a jar that I used on the other builds.
I am getting this too now and am able to get around it by removing all external jars from the project. You can add them back in after it's been cleaned. I'm assuming you have access to the original project source code...
Rightclick on project, go to Java Build Path, and remove all external jars other than your Android libs. Then clean.
Got this error after updating to the Android Platform Tools preview 15 rc5 and Android Tools 21 rc5, plus running the "check for updates..." in eclipse.
LogCat error
java.lang.NoClassDefFoundError: com.someapplicationlibrary.lib.R$layout
Eclipse compiler error:
Errors occurred during the build.
Errors running builder 'Android Pre Compiler' on project 'myApplication'.
String index out of range: -51
Errors running builder 'Android Pre Compiler' on project 'someapplicationlibrary'.
String index out of range: -54
Tried to revert to the stabel Android Tools... but ending up with even more errors.
My solution was to load the workspace in a eclipse version that was not updated with the "check for updates..." in the eclipse Help menu.
Then it compiled correct, and the application worked again, hope this helps:)

Categories

Resources