Android,GoogleAnalytics - java.lang.NullPointerException - java

I'm using GoogleAnalyticsServicesAndroid_3.0, And Have a min sdk of Android API 9.
I keep seeing the following error in my bug report system :
java.lang.NullPointerException
at android.app.ContextImpl.openFileOutput(ContextImpl.java:431)
at android.content.ContextWrapper.openFileOutput(ContextWrapper.java:158)
at com.google.analytics.tracking.android.ClientIdDefaultProvider.storeClientId(ClientIdDefaultProvider.java:102)
at com.google.analytics.tracking.android.ClientIdDefaultProvider.generateClientId(ClientIdDefaultProvider.java:123)
at com.google.analytics.tracking.android.ClientIdDefaultProvider.initializeClientId(ClientIdDefaultProvider.java:179)
at com.google.analytics.tracking.android.ClientIdDefaultProvider$1.run(ClientIdDefaultProvider.java:134)
I haven't been able to find a solution for this, Any help is appreciated
This seems to only happen in 2.3. OS versions
Thanks,
Shimi

Related

How do I solve this NPE from trying to use Journey Browser

Using journey browser project I have set up a simple maven project in eclipse, using the dependency provided on the page, I have tried to run the code example (also provided on the page)
And I get an NPE:
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:588)
at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:583)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.desktop/java.awt.Toolkit.getDefaultToolkit(Toolkit.java:582)
at java.desktop/java.awt.Toolkit.getEventQueue(Toolkit.java:1494)
at java.desktop/java.awt.EventQueue.isDispatchThread(EventQueue.java:1086)
at java.desktop/javax.swing.SwingUtilities.isEventDispatchThread(SwingUtilities.java:1493)
at com.codebrig.journey.JourneyBrowserView.<init>(JourneyBrowserView.java:78)
at com.codebrig.journey.JourneyBrowserView.<init>(JourneyBrowserView.java:71)
at JourneyBrowser.main(JourneyBrowser.java:13)
Caused by: java.lang.NullPointerException
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2646)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:830)
at java.base/java.lang.System.loadLibrary(System.java:1870)
at java.desktop/sun.awt.windows.WToolkit$1.run(WToolkit.java:118)
at java.desktop/sun.awt.windows.WToolkit$1.run(WToolkit.java:115)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.desktop/sun.awt.windows.WToolkit.loadLibraries(WToolkit.java:114)
at java.desktop/sun.awt.windows.WToolkit.<clinit>(WToolkit.java:129)
... 12 more
Can anyone explain what is happening and why here, I have tried this on 64bit windows with java Coretto 11(jdk11.0.7_10),I initially found a bug here, relating to loadLibray in open JDK and thought that maybe the problem, I just don't have a good enough understanding to work out how to get around it?
I'm not sure, but I think that Corretto bug is probably the one that is causing the problem. As noted, it is from their "upstream"; i.e the OpenJDK codebase. It was due to regression that appeared in jdk11.0.7 due to a backport of a fix for another problem. Apparently, the fix changes some internal JDK fields and that breaks application code. As JDK-8240521 puts it:
The backport of the JDK-8231584 changes internal JDK fields processing. The problem is that the many third-party applications copy-pasted a hack that depends on particular JDK implementation.
If I am reading the Oracle bug entries correctly, the reversion of the broken fix should be in JDK11.0.8. Alternatively, an earlier JDK 11 release than 11.0.7 shouldn't have the broken fix.
Let me know if changing your Java 11 install solves the problem. (If not, I'll see if I can get the line numbers to match up.)

How to update timzone settings in Jre?

I am currently working on a project where in three location the timezones are coming incorrectly.I tried updating my tzmappings file from jre 1.8 .In this process I could able to see the correct time in one location and other location time are still wrong.We embedded the jre with our application and for that we were using jre 1.6.I understand upgrading to new jre i.e jre 1.6->Jre1.8 will be solve this problem.But let me know if anything apart from this i can do to resolve this.
Update: Tried running TZupdater but ends up getting NPE detail stack trace below
Exception in thread "main" com.sun.tools.tzupdater.TzRuntimeException: java.lang.NullPointerException
at com.sun.tools.tzupdater.TimezoneUpdater.main(TimezoneUpdater.java:662)
Caused by: java.lang.NullPointerException
at com.sun.tools.tzupdater.TimezoneUpdater.run(TimezoneUpdater.java:215)
at com.sun.tools.tzupdater.TimezoneUpdater.main(TimezoneUpdater.java:643)

Spark based application failing in JDK 8?

I am running built in sample example which comes as part of Spark installation, and running in Hadoop 2.7 + Spark with JDK 8. However it is giving me the following error:
Exception in thread "main" java.lang.OutOfMemoryError: Cannot allocate
new DoublePointer(10000000): totalBytes = 363M, physicalBytes = 911M
at
org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:187)
at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:212)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:126)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala) Caused by: java.lang.OutOfMemoryError: Physical memory usage is too
high: physicalBytes = 911M > maxPhysicalBytes = 911M
at org.bytedeco.javacpp.Pointer.deallocator(Pointer.java:572)
at org.bytedeco.javacpp.Pointer.init(Pointer.java:121)
I followed the following SO question as well, and did the configuration changes.
In addition to this, I referred to these links as well: YARN-4714 , HADOOP-11090
Are there any issues in running Spark in JDK 8.
The below are the versions of the softwares that I am running in my simple cluster:
jdk-8u131-linux-x64
scala-2.12.2
spark-2.1.1-bin-without-hadoop
hadoop-2.7.0
One thing when I run the program in JDK 7, it is working fine, but failing with JDK 8.
Has anyone encountered this problem and if so, what is the fix? Isn't hadoop , spark, scala not yet compatible with JDK 8?
Can anyone please help me?
You are receiving OOM error is the indication of shortage of memory for java to launch. As you have mentioned JDK7 it worked fine. Upgrading to JDK8 require more memory compare to JDK7. Please check JDK8 memory requirements here - https://dzone.com/articles/java-8-permgen-metaspace
Spark is not yet released for Scala 2.12. I don't know if it solves the original problem but you should switch to Scala 2.11 anyway.

Error when running Z3 java binding

I am running JavaExample.java provided with Z3 4.4.2 but I get the following output and then error:
Z3 Major Version: 4
Z3 Full Version: 4.3.2.0
SimpleExample
Opt
Exception in thread "main" java.lang.UnsatisfiedLinkError: com.microsoft.z3.Native.INTERNALmkOptimize(J)J
at com.microsoft.z3.Native.INTERNALmkOptimize(Native Method)
at com.microsoft.z3.Native.mkOptimize(Native.java:5208)
at com.microsoft.z3.Optimize.<init>(Optimize.java:262)
at com.microsoft.z3.Context.mkOptimize(Context.java:3043)
at Z3Example.optimizeExample(Z3Example.java:2323)
at Z3Example.main(Z3Example.java:2362)
To be fair, I am using the 64-bit libz3java.dll provided with 4.3.2, while using the jar file com.microsoft.z3.jar from version 4.4.2, because that was the only combination that I managed to get working (this details those problems). Could that be the version difference the reason for this error, or is there something else?
Yes, the version difference is responsible for this issue: 4.3.2 did not support optimization and thus doesn't come with mkOptimize. I'll take a look at the other issue separately.

Android Studio fails to load the Visual Layout Editor

I've been on google and android support forums for more than 8 hours now with no luck. My Android studio was working fine 2 days ago and last night when I wanted to continue my project, I got this error :
Render error
ActiveTool: com.intellij.designer.designSurface.tools.SelectionTool#7797899
SDK: Android 4.4.2 - API 19
java.lang.NoClassDefFoundError: org/kxml2/io/KXmlParser
at com.android.ide.common.resources.IdResourceParser.parse(IdResourceParser.java:75)
at com.android.ide.common.resources.IdGeneratingResourceFile.parseFileForIds(IdGeneratingResourceFile.java:150)
at com.android.ide.common.resources.IdGeneratingResourceFile.load(IdGeneratingResourceFile.java:72)
at com.android.ide.common.resources.ResourceFolder.getFile(ResourceFolder.java:286)
at com.android.ide.common.resources.ResourceFolder.processFile(ResourceFolder.java:74)
at org.jetbrains.android.sdk.FrameworkResourceLoader$IdeFrameworkResources.ensureInitialized(FrameworkResourceLoader.java:124)
at org.jetbrains.android.sdk.FrameworkResourceLoader.loadPlatformResources(FrameworkResourceLoader.java:60)
at org.jetbrains.android.sdk.FrameworkResourceLoader.load(FrameworkResourceLoader.java:54)
at org.jetbrains.android.sdk.AndroidTargetData.getFrameworkResources(AndroidTargetData.java:207)
at com.android.tools.idea.configurations.ResourceResolverCache.getFrameworkResources(ResourceResolverCache.java:248)
at com.android.tools.idea.configurations.ResourceResolverCache.getFrameworkResources(ResourceResolverCache.java:214)
at com.android.tools.idea.configurations.ResourceResolverCache.getResourceResolver(ResourceResolverCache.java:129)
at com.android.tools.idea.configurations.Configuration.getResourceResolver(Configuration.java:1137)
at com.android.tools.idea.rendering.RenderService.getResourceResolver(RenderService.java:276)
at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:469)
at com.android.tools.idea.rendering.RenderService.render(RenderService.java:691)
at com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel$6.run(AndroidDesignerEditorPanel.java:483)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:327)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.ClassNotFoundException: org.kxml2.io.KXmlParser PluginClassLoader[org.jetbrains.android, 10.0]
at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:68)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 30 more
Anyone got some thoughts on this? Oh yeah, The first time I used android studio, it was online, then it work, then offline, still worked and now it doesn't work again.
My setup :
Windows 8.1 pro 64-bit
Java JDK 1.7 64-bit
I tired changing the API level, but still no results. Here is a screenshot :
http://snag.gy/bSr7y.jpg
If there is already a thread on this, please point me to it and I'll remove this one. I did a quick search on StackOverflow and couldn't see anything.
Thanks in advance
Solution :
Turns out, my JDK was corrupt and it didn't fully remove the installation when uninstalled.
I finally got it fixed. Here is what I did :
First, I uninstalled Java JDK1.7 and removed all it's left over files.
Then I downloaded and installed JDK1.8 and it worked.
I had an error where the Studio said it couldn't detect JDK, so I only added an JAVA_HOME environment variable which points to my new JDK and it's all working fine now. Thanks everyone for the help and suggestions. I hope this can help someone in the future.
I dont know what the exact problem was ...
But NoClassDefFoundError is kind of hard ...
Anyway try this post
3 ways to solve java.lang.NoClassDefFoundError in Java
Check the XmlParser class (try commenting any class calls)
above link describes how this error gets generated

Categories

Resources