Jsoup throwing NullPointerException on Connection.get() in Android Emulator - android

I'm using Jsoup for one of my android applications, and I have a relatively simple piece of code that keeps throwing NullPointerException when I call connection.get().
This used to work a couple months back, but after installing the latest SDK it no longer works in the emulator. It is working fine on my physical device, but I don't know if this is an emulation only bug or could impact other handsets.
This is my code:
String URL = "http://finance.google.com/finance/feeds/default/portfolios?returns=true"
String _AUTHPARAMS = "GoogleLogin auth="
String AuthToken = "random string of characters"
Connection c = Jsoup.connect(URL);
c.header("Authorization", _AUTHPARAMS + AuthToken);
c.userAgent("foo");
c.timeout(10000);
c.ignoreContentType(true);
Document doc = c.get();
I am catching a NullPointerException on the last line (c.get())
If I call exception.getMessage(), it just says "null". I'm not sure what else could be causing this other than a bug in android or jsoup?
======= EDIT ========
I'm using Jsoup 1.6.1
Here's the stack trace from eclipse:
03-01 00:43:22.459: E/AndroidRuntime(392): FATAL EXCEPTION: AsyncTask #1
03-01 00:43:22.459: E/AndroidRuntime(392): java.lang.RuntimeException: An error occured while executing doInBackground()
03-01 00:43:22.459: E/AndroidRuntime(392): at android.os.AsyncTask$3.done(AsyncTask.java:200)
03-01 00:43:22.459: E/AndroidRuntime(392): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
03-01 00:43:22.459: E/AndroidRuntime(392): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
03-01 00:43:22.459: E/AndroidRuntime(392): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
03-01 00:43:22.459: E/AndroidRuntime(392): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
03-01 00:43:22.459: E/AndroidRuntime(392): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
03-01 00:43:22.459: E/AndroidRuntime(392): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
03-01 00:43:22.459: E/AndroidRuntime(392): at java.lang.Thread.run(Thread.java:1096)
03-01 00:43:22.459: E/AndroidRuntime(392): Caused by: java.lang.NullPointerException
03-01 00:43:22.459: E/AndroidRuntime(392): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.readln(HttpURLConnectionImpl.java:1279)
03-01 00:43:22.459: E/AndroidRuntime(392): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl$ChunkedInputStream.readChunkSize(HttpURLConnectionImpl.java:404)
03-01 00:43:22.459: E/AndroidRuntime(392): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl$ChunkedInputStream.<init>(HttpURLConnectionImpl.java:340)
03-01 00:43:22.459: E/AndroidRuntime(392): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getContentStream(HttpURLConnectionImpl.java:1175)
03-01 00:43:22.459: E/AndroidRuntime(392): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.doRequestInternal(HttpURLConnectionImpl.java:1754)
03-01 00:43:22.459: E/AndroidRuntime(392): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.doRequest(HttpURLConnectionImpl.java:1649)
03-01 00:43:22.459: E/AndroidRuntime(392): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:1374)
03-01 00:43:22.459: E/AndroidRuntime(392): at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:381)
03-01 00:43:22.459: E/AndroidRuntime(392): at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:364)
03-01 00:43:22.459: E/AndroidRuntime(392): at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:143)
03-01 00:43:22.459: E/AndroidRuntime(392): at org.jsoup.helper.HttpConnection.get(HttpConnection.java:132)
03-01 00:43:22.459: E/AndroidRuntime(392): at com.karwosts.PortfolioMap.GoogleFinance.SendHttpRequest(GoogleFinance.java:138)
03-01 00:43:22.459: E/AndroidRuntime(392): at com.karwosts.PortfolioMap.GoogleFinance.getDocument(GoogleFinance.java:78)
03-01 00:43:22.459: E/AndroidRuntime(392): at com.karwosts.PortfolioMap.GoogleFinance.GetPortfolioList(GoogleFinance.java:36)
03-01 00:43:22.459: E/AndroidRuntime(392): at com.karwosts.PortfolioMap.GooglePortfolioSelector$AsyncPortfolioRetriever.doInBackground(GooglePortfolioSelector.java:134)
03-01 00:43:22.459: E/AndroidRuntime(392): at com.karwosts.PortfolioMap.GooglePortfolioSelector$AsyncPortfolioRetriever.doInBackground(GooglePortfolioSelector.java:1)
03-01 00:43:22.459: E/AndroidRuntime(392): at android.os.AsyncTask$2.call(AsyncTask.java:185)
03-01 00:43:22.459: E/AndroidRuntime(392): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
03-01 00:43:22.459: E/AndroidRuntime(392): ... 4 more

From your stack trace I'm guessing you're encountering this bug (15554) on an Android 2.1 (or other "old" version) - you should be able to download the document using the Apache HTTP client - which works a lot better on older Android implementations (since HttpURLConnection is/was a buggy piece of shit).

Related

Caused by: java.lang.NoClassDefFoundError: com.google.android.gms.gcm.GoogleCloudMessaging using flex

I am developing an Android native extension for push notification. I have added the gcm library to the class path but the class GoogleCloudMessaging could not be found. Even thought the jar from google is added to the class path of the android project, I still get the error message, so after I export the jar I am updating with the classes from the Google gcm jar. After this everything looks ok at jar level but the problem still persist and I have the following error:
W/dalvikvm(10513): VFY: unable to resolve static method 2592: Lcom/google/android/gms/gcm/GoogleCloudMessaging;.getInstance (Landroid/content/Context;)Lcom/google/android/gms/gcm/GoogleCloudMessaging;
08-17 19:32:10.328: W/dalvikvm(10513): threadid=16: thread exiting with uncaught exception (group=0x40adb9f0)
08-17 19:32:10.348: E/AndroidRuntime(10513): FATAL EXCEPTION: AsyncTask #1
08-17 19:32:10.348: E/AndroidRuntime(10513): java.lang.RuntimeException: An error occured while executing doInBackground()
08-17 19:32:10.348: E/AndroidRuntime(10513): at android.os.AsyncTask$3.done(AsyncTask.java:278)
08-17 19:32:10.348: E/AndroidRuntime(10513): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
08-17 19:32:10.348: E/AndroidRuntime(10513): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
08-17 19:32:10.348: E/AndroidRuntime(10513): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
08-17 19:32:10.348: E/AndroidRuntime(10513): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
08-17 19:32:10.348: E/AndroidRuntime(10513): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
08-17 19:32:10.348: E/AndroidRuntime(10513): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
08-17 19:32:10.348: E/AndroidRuntime(10513): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
08-17 19:32:10.348: E/AndroidRuntime(10513): at java.lang.Thread.run(Thread.java:856)
08-17 19:32:10.348: E/AndroidRuntime(10513): Caused by: java.lang.NoClassDefFoundError: com.google.android.gms.gcm.GoogleCloudMessaging
08-17 19:32:10.348: E/AndroidRuntime(10513): at com.microsoft.windowsazure.notifications.NotificationsManager$1.doInBackground(NotificationsManager.java:43)
08-17 19:32:10.348: E/AndroidRuntime(10513): at com.microsoft.windowsazure.notifications.NotificationsManager$1.doInBackground(NotificationsManager.java:1)
08-17 19:32:10.348: E/AndroidRuntime(10513): at android.os.AsyncTask$2.call(AsyncTask.java:264)
08-17 19:32:10.348: E/AndroidRuntime(10513): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
08-17 19:32:10.348: E/AndroidRuntime(10513): ... 5 more

i am trying to send request to https://www.google.com and get a responce. I am using asyncTask but getting the following exception [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
12-17 11:01:44.227: E/AndroidRuntime(1768): FATAL EXCEPTION: AsyncTask #1
12-17 11:01:44.227: E/AndroidRuntime(1768): java.lang.RuntimeException: An error occured while executing doInBackground()
12-17 11:01:44.227: E/AndroidRuntime(1768): at android.os.AsyncTask$3.done(AsyncTask.java:299)
12-17 11:01:44.227: E/AndroidRuntime(1768): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
12-17 11:01:44.227: E/AndroidRuntime(1768): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
12-17 11:01:44.227: E/AndroidRuntime(1768): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
12-17 11:01:44.227: E/AndroidRuntime(1768): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
12-17 11:01:44.227: E/AndroidRuntime(1768): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
12-17 11:01:44.227: E/AndroidRuntime(1768): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
12-17 11:01:44.227: E/AndroidRuntime(1768): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
12-17 11:01:44.227: E/AndroidRuntime(1768): at java.lang.Thread.run(Thread.java:856)
12-17 11:01:44.227: E/AndroidRuntime(1768): Caused by: android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
12-17 11:01:44.227: E/AndroidRuntime(1768): at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:4607)
12-17 11:01:44.227: E/AndroidRuntime(1768): at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:835)
12-17 11:01:44.227: E/AndroidRuntime(1768): at android.view.View.requestLayout(View.java:15129)
12-17 11:01:44.227: E/AndroidRuntime(1768): at android.view.View.requestLayout(View.java:15129)
12-17 11:01:44.227: E/AndroidRuntime(1768): at android.view.View.requestLayout(View.java:15129)
12-17 11:01:44.227: E/AndroidRuntime(1768): at android.view.View.requestLayout(View.java:15129)
12-17 11:01:44.227: E/AndroidRuntime(1768): at android.widget.RelativeLayout.requestLayout(RelativeLayout.java:292)
12-17 11:01:44.227: E/AndroidRuntime(1768): at android.view.View.requestLayout(View.java:15129)
12-17 11:01:44.227: E/AndroidRuntime(1768): at android.widget.TextView.checkForRelayout(TextView.java:6303)
12-17 11:01:44.227: E/AndroidRuntime(1768): at android.widget.TextView.setText(TextView.java:3547)
12-17 11:01:44.227: E/AndroidRuntime(1768): at android.widget.TextView.setText(TextView.java:3405)
12-17 11:01:44.227: E/AndroidRuntime(1768): at android.widget.TextView.setText(TextView.java:3380)
12-17 11:01:44.227: E/AndroidRuntime(1768): at com.example.internet.MainActivity$RequestTask.doInBackground(MainActivity.java:150)
12-17 11:01:44.227: E/AndroidRuntime(1768): at com.example.internet.MainActivity$RequestTask.doInBackground(MainActivity.java:1)
12-17 11:01:44.227: E/AndroidRuntime(1768): at android.os.AsyncTask$2.call(AsyncTask.java:287)
12-17 11:01:44.227: E/AndroidRuntime(1768): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
12-17 11:01:44.227: E/AndroidRuntime(1768): ... 5 more
12-17 11:01:44.857: W/IInputConnectionWrapper(1768): showStatusIcon on inactive InputConnection
this is the cause.
Caused by: android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
UI cant be updated from doInBackground
You should provide the code as well , specifically for the relevant part.
Here is an example of an approach that can be used
private class SaveProfile extends AsyncTask<String, Void, Boolean>{
#Override
protected Boolean doInBackground(String... params) {
//---------- so your stuff here.... non ui related
Log.v("response from saving",response);
if(response.equals("1")){
return true;
}else{
return false;
}
}
protected void onPostExecute(Boolean result) {
if(result) {
//------ UPDATE UI HERE
Toast.makeText(ProfileCompanyActivity.this, "profile saved", 2500).show();
}else{
Toast.makeText(ProfileCompanyActivity.this, "an error occured", 2500).show();
}
}
}
First you must Understand the Concept of AsynTask in android...
1) you cannot update or change your UI element in backGround thread i.e doInBackGround()
2) use onPreExcecute() or onPostExcecute() to change or update your UI element
And to be Sure you are accessing UI element into doInBackGround
Check out this Example to Understant how the Methods work
Hope this could help....

android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3147)

Any idea why would this crash appear? The trace has only native code so very hard to track it down. Happens on Samsung Galaxy s3 platform 4.1.2 when I run animation inside a Fragment and when animation ends I call notifyDataSetChanged for the FragmentStatePagerAdapter. The issue is not 100% reproducible.
Thanks.
Trace:
03-01 11:50:11.836: E/AndroidRuntime(21136): FATAL EXCEPTION: main
03-01 11:50:11.836: E/AndroidRuntime(21136): java.lang.NullPointerException
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3147)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12646)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12754)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3151)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12646)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12754)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3151)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12646)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12754)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3151)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12646)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12754)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3151)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12646)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12754)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3151)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12646)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12754)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3151)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12646)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12754)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3151)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12646)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12754)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3151)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12646)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12754)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3151)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12646)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12754)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3151)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12646)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.View.getDisplayList(View.java:12754)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1144)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewRootImpl.draw(ViewRootImpl.java:2273)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2145)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1956)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1112)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4472)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.Choreographer.doFrame(Choreographer.java:525)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.os.Handler.handleCallback(Handler.java:615)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.os.Handler.dispatchMessage(Handler.java:92)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.os.Looper.loop(Looper.java:137)
03-01 11:50:11.836: E/AndroidRuntime(21136): at android.app.ActivityThread.main(ActivityThread.java:4898)
03-01 11:50:11.836: E/AndroidRuntime(21136): at java.lang.reflect.Method.invokeNative(Native Method)
03-01 11:50:11.836: E/AndroidRuntime(21136): at java.lang.reflect.Method.invoke(Method.java:511)
03-01 11:50:11.836: E/AndroidRuntime(21136): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
03-01 11:50:11.836: E/AndroidRuntime(21136): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
03-01 11:50:11.836: E/AndroidRuntime(21136): at dalvik.system.NativeStart.main(Native Method)
Fix was simple but no idea why works.
In the AnimationListener's onAnimationEnd callback I had a callback which triggered notifyDataSetChanged. I add that callback into Runnable and ran the Runnable with getView().post
#Override
public void onAnimationEnd(Animation animation) {
getView().post(new Runnable() {
#Override
public void run() {
// notifyDataSetChanged here
}
});
}
Good answer but as in all things Android these answers become dated pretty quickly.
I would use runOnUiThread now. I was running in a baseclass with the animator as a private class. For a deeper dive on runOnUiThread see
Android basics: running code in the UI thread
#Override
public void onAnimationEnd(Animator animation) {
//
MyBaseActivity.this.runOnUiThread(new Runnable() {
public void run() {
Log.d("UI thread", "I am the UI thread");
}
});
}

Fatal error on LoadedApk,makeApplication

I'm developing an application here and it's been working good so far, but now I've put the HoloEverywhere lib to update the layout to the ICS look, and I started getting a random error on startup.
I searched for this error and found out that it could be related to the Eclipse ADT plugin incorrectly building the apk or something like that, but the error doesn't occurs only when I starde from Eclipse, it occurs frequently almost every time I reopen the application after not using it for a while.
And there's really nothing wrong with my application, because it worked well before HoloEverywhere, and when I get this crash (The app crashed everytime I get the error), I just have to reopen it again and it'll work.
This is what I'm getting:
03-01 12:37:03.913: E/AndroidRuntime(29273): FATAL EXCEPTION: main
03-01 12:37:03.913: E/AndroidRuntime(29273): java.lang.RuntimeException: Unable to instantiate application br.uff.uffmobile.context.UffMobileApplication: java.lang.NullPointerException
03-01 12:37:03.913: E/AndroidRuntime(29273): at android.app.LoadedApk.makeApplication(LoadedApk.java:501)
03-01 12:37:03.913: E/AndroidRuntime(29273): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4159)
03-01 12:37:03.913: E/AndroidRuntime(29273): at android.app.ActivityThread.access$1400(ActivityThread.java:134)
03-01 12:37:03.913: E/AndroidRuntime(29273): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
03-01 12:37:03.913: E/AndroidRuntime(29273): at android.os.Handler.dispatchMessage(Handler.java:99)
03-01 12:37:03.913: E/AndroidRuntime(29273): at android.os.Looper.loop(Looper.java:137)
03-01 12:37:03.913: E/AndroidRuntime(29273): at android.app.ActivityThread.main(ActivityThread.java:4856)
03-01 12:37:03.913: E/AndroidRuntime(29273): at java.lang.reflect.Method.invokeNative(Native Method)
03-01 12:37:03.913: E/AndroidRuntime(29273): at java.lang.reflect.Method.invoke(Method.java:511)
03-01 12:37:03.913: E/AndroidRuntime(29273): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
03-01 12:37:03.913: E/AndroidRuntime(29273): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
03-01 12:37:03.913: E/AndroidRuntime(29273): at dalvik.system.NativeStart.main(Native Method)
03-01 12:37:03.913: E/AndroidRuntime(29273): Caused by: java.lang.NullPointerException
03-01 12:37:03.913: E/AndroidRuntime(29273): at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:377)
03-01 12:37:03.913: E/AndroidRuntime(29273): at android.app.LoadedApk.getClassLoader(LoadedApk.java:320)
03-01 12:37:03.913: E/AndroidRuntime(29273): at android.app.LoadedApk.makeApplication(LoadedApk.java:493)
03-01 12:37:03.913: E/AndroidRuntime(29273): ... 11 more
I have also put try/catches everywhere I could to see if I could avoid this nullpointer, but it seems it's either a HoloEverywhere problem or an internal Android bug. I'm testing it with a 4.1.2 android Galaxy S Advance.

Permission denied exception is coming while retrieving the icon in android

I have created an application which will allow the user to set a new theme to their phone. I am trying to change the icons of the default applications(mms,camera,calculator etc) after applying the theme. I am trying to do this by storing the theme icon images into the local memory.
In Iconcache.java I have modified the code. I am checking there which theme is currently used and if it is not default theme then I am checking the local memory to get which theme is assigned and getting icon location and assigning that particular icon.
I am getting icon location correctly there, but not able open it. It is showing permission denied exception. See the logs below.
03-01 12:14:30.324: INFO/System.out(197): CN: ComponentInfo{com.android.settings/com.android.settings.Settings}
03-01 12:14:30.324: INFO/System.out(197): *********In Try*******
03-01 12:14:30.324: INFO/System.out(197): getfullresiconnnnnnnnnnnnnnnn
03-01 12:14:30.334: DEBUG/IconCache(197): getFullResIcon : info ResolveInfo{410b09f8 com.android.settings.Settings p=0 o=0 m=0x0}
03-01 12:14:30.334: DEBUG/IconCache(197): getFullResIcon :try settingsContext android.app.ContextImpl#4108b660
03-01 12:14:30.354: DEBUG/IconCache(197): getFullResIcon : currentThemePackage Default Theme
03-01 12:14:30.354: INFO/System.out(197): current theme package :Default Theme
03-01 12:14:30.374: DEBUG/IconCache(197): if currenttheme!=default
03-01 12:14:30.374: INFO/System.out(197): Icon file :/data/data/com.android.settings/app_themes/settings.png
03-01 12:14:30.424: DEBUG/IconCache(197): getFullResIcon : iconFile /data/data/com.android.settings/app_themes/settings.png
03-01 12:14:30.424: DEBUG/IconCache(197): if iconFile!=null
03-01 12:14:30.434: DEBUG/IconCache(197): if iconFile!=null : ico val /data/data/com.android.settings/app_themes/settings.png
03-01 12:14:30.483: WARN/System.err(197): java.io.FileNotFoundException: /data/data/com.android.settings/app_themes/settings.png: open failed: EACCES (Permission denied)
03-01 12:14:30.493: WARN/System.err(197): at libcore.io.IoBridge.open(IoBridge.java:406)
03-01 12:14:30.533: DEBUG/dalvikvm(76): GC_CONCURRENT freed 1570K, 24% free 12477K/16263K, paused 5ms+81ms
03-01 12:14:30.583: WARN/ActivityManager(76): Activity idle timeout for ActivityRecord{410e4510 com.android.launcher/com.android.launcher2.Launcher}
03-01 12:14:30.703: WARN/System.err(197): at java.io.FileInputStream.<init>(FileInputStream.java:78)
03-01 12:14:30.703: WARN/System.err(197): at com.android.launcher2.IconCache.getFullResIcon(IconCache.java:142)
03-01 12:14:30.723: WARN/System.err(197): at com.android.launcher2.IconCache.cacheLocked(IconCache.java:282)
03-01 12:14:30.723: WARN/System.err(197): at com.android.launcher2.IconCache.getIcon(IconCache.java:250)
03-01 12:14:30.746: WARN/System.err(197): at com.android.launcher2.LauncherModel.getShortcutInfo(LauncherModel.java:1641)
03-01 12:14:30.746: WARN/System.err(197): at com.android.launcher2.LauncherModel$LoaderTask.loadWorkspace(LauncherModel.java:1041)
03-01 12:14:30.755: WARN/System.err(197): at com.android.launcher2.LauncherModel$LoaderTask.loadAndBindWorkspace(LauncherModel.java:756)
03-01 12:14:30.763: WARN/System.err(197): at com.android.launcher2.LauncherModel$LoaderTask.run(LauncherModel.java:821)
03-01 12:14:30.763: WARN/System.err(197): at android.os.Handler.handleCallback(Handler.java:605)
03-01 12:14:30.763: WARN/System.err(197): at android.os.Handler.dispatchMessage(Handler.java:92)
03-01 12:14:30.773: DEBUG/StrictMode(271): StrictMode policy violation; ~duration=249 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=2711 violation=2
03-01 12:14:30.773: DEBUG/StrictMode(271): at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1074)
03-01 12:14:30.773: DEBUG/StrictMode(271): at android.app.SharedPreferencesImpl.awaitLoadedLocked(SharedPreferencesImpl.java:184)
03-01 12:14:30.773: DEBUG/StrictMode(271): at android.app.SharedPreferencesImpl.getBoolean(SharedPreferencesImpl.java:241)
03-01 12:14:30.773: DEBUG/StrictMode(271): at com.android.calendar.Utils.getHideDeclinedEvents(Utils.java:464)
03-01 12:14:30.773: DEBUG/StrictMode(271): at com.android.calendar.widget.CalendarAppWidgetService$CalendarFactory.initLoader(CalendarAppWidgetService.java:356)
03-01 12:14:30.773: DEBUG/StrictMode(271): at com.android.calendar.widget.CalendarAppWidgetService$CalendarFactory.onReceive(CalendarAppWidgetService.java:525)
03-01 12:14:30.773: DEBUG/StrictMode(271): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2118)
03-01 12:14:30.773: DEBUG/StrictMode(271): at android.app.ActivityThread.access$1500(ActivityThread.java:122)
03-01 12:14:30.773: DEBUG/StrictMode(271): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
03-01 12:14:30.773: DEBUG/StrictMode(271): at android.os.Handler.dispatchMessage(Handler.java:99)
03-01 12:14:30.773: DEBUG/StrictMode(271): at android.os.Looper.loop(Looper.java:137)
03-01 12:14:30.773: DEBUG/StrictMode(271): at android.app.ActivityThread.main(ActivityThread.java:4340)
03-01 12:14:30.773: DEBUG/StrictMode(271): at java.lang.reflect.Method.invokeNative(Native Method)
03-01 12:14:30.773: DEBUG/StrictMode(271): at java.lang.reflect.Method.invoke(Method.java:511)
03-01 12:14:30.773: DEBUG/StrictMode(271): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-01 12:14:30.773: DEBUG/StrictMode(271): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-01 12:14:30.773: DEBUG/StrictMode(271): at dalvik.system.NativeStart.main(Native Method)
03-01 12:14:30.783: WARN/System.err(197): at android.os.Looper.loop(Looper.java:137)
03-01 12:14:30.803: WARN/System.err(197): at android.os.HandlerThread.run(HandlerThread.java:60)
03-01 12:14:30.863: WARN/System.err(197): Caused by: libcore.io.ErrnoException: open failed: EACCES (Permission denied)
03-01 12:14:30.863: WARN/System.err(197): at libcore.io.Posix.open(Native Method)
03-01 12:14:30.902: WARN/System.err(197): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:98)
03-01 12:14:30.902: WARN/System.err(197): at libcore.io.IoBridge.open(IoBridge.java:390)
03-01 12:14:30.913: DEBUG/dalvikvm(152): GC_CONCURRENT freed 4820K, 41% free 7254K/12231K, paused 4ms+270ms
03-01 12:14:30.954: INFO/ActivityManager(76): Start proc com.android.providers.calendar for content provider com.android.providers.calendar/.CalendarProvider2: pid=310 uid=10009 gids={3003, 1015}
03-01 12:14:31.044: WARN/System.err(197): ... 12 more
03-01 12:14:31.044: DEBUG/Launcher.IconCache(197): getFullResIcon
03-01 12:14:31.074: INFO/System.out(197): *********Executed******
03-01 12:14:31.103: DEBUG/PowerManagerService(76): bootCompleted
03-01 12:14:31.173: VERBOSE/DevicePolicyManagerService(76): Sending password expiration notifications for action android.intent.action.BOOT_COMPLETED
03-01 12:14:31.204: INFO/SurfaceFlinger(33): Boot is finished (32818 ms)
03-01 12:14:31.204: INFO/SurfaceFlinger(33):
03-01 12:14:31.334 76:0x75 F/NetworkStats ]
03-01 12:14:31.204: INFO/SurfaceFlinger(33): problem reading network stats
03-01 12:14:31.204: INFO/SurfaceFlinger(33): java.lang.IllegalStateException: problem parsing line: null
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at com.android.server.NetworkManagementService.getNetworkStatsUidDetail(NetworkManagementService.java:1234)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at com.android.server.net.NetworkStatsService.performPollLocked(NetworkStatsService.java:810)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at com.android.server.net.NetworkStatsService.updateIfacesLocked(NetworkStatsService.java:721)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at com.android.server.net.NetworkStatsService.updateIfaces(NetworkStatsService.java:699)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at com.android.server.net.NetworkStatsService.access$000(NetworkStatsService.java:128)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at com.android.server.net.NetworkStatsService$8.handleMessage(NetworkStatsService.java:1546)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at android.os.Handler.dispatchMessage(Handler.java:95)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at android.os.Looper.loop(Looper.java:137)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at android.os.HandlerThread.run(HandlerThread.java:60)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): Caused by: java.io.FileNotFoundException: /proc/net/xt_qtaguid/stats: open failed: ENOENT (No such file or directory)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at libcore.io.IoBridge.open(IoBridge.java:406)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at java.io.FileInputStream.<init>(FileInputStream.java:78)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at java.io.FileReader.<init>(FileReader.java:42)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at com.android.internal.net.NetworkStatsFactory.readNetworkStatsDetail(NetworkStatsFactory.java:272)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): ... 9 more
03-01 12:14:31.204: INFO/SurfaceFlinger(33): Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at libcore.io.Posix.open(Native Method)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:98)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): at libcore.io.IoBridge.open(IoBridge.java:390)
03-01 12:14:31.204: INFO/SurfaceFlinger(33): ... 12 more
03-01 12:14:31.384: INFO/System.out(197): CN: ComponentInfo{com.android.contacts/com.android.contacts.activities.DialtactsActivity}
03-01 12:14:31.663: DEBUG/dalvikvm(34): GC_EXPLICIT freed 33K, 4% free 6825K/7107K, paused 3ms+4ms
03-01 12:14:31.803: INFO/System.out(197): *********In Try*******
03-01 12:14:31.803: INFO/System.out(197): getfullresiconnnnnnnnnnnnnnnn
03-01 12:14:31.843: DEBUG/IconCache(197): getFullResIcon : info ResolveInfo{410f0068 com.android.contacts.activities.DialtactsActivity p=0 o=0 m=0x0}
03-01 12:14:31.843: DEBUG/IconCache(197): getFullResIcon :try settingsContext android.app.ContextImpl#410f69a8
03-01 12:14:31.884: DEBUG/IconCache(197): getFullResIcon : currentThemePackage Default Theme
03-01 12:14:31.884: INFO/System.out(197): current theme package :Default Theme
03-01 12:14:31.894: DEBUG/IconCache(197): if currenttheme!=default
03-01 12:14:31.894: INFO/System.out(197): Icon file :/data/data/com.android.settings/app_themes/contacts.png
03-01 12:14:31.894: DEBUG/IconCache(197): getFullResIcon : iconFile /data/data/com.android.settings/app_themes/contacts.png
03-01 12:14:31.894: DEBUG/IconCache(197): if iconFile!=null
03-01 12:14:31.894: DEBUG/IconCache(197): if iconFile!=null : ico val /data/data/com.android.settings/app_themes/contacts.png
03-01 12:14:31.924: WARN/System.err(197): java.io.FileNotFoundException: /data/data/com.android.settings/app_themes/contacts.png: open failed: EACCES (Permission denied)
03-01 12:14:31.924: WARN/System.err(197): at libcore.io.IoBridge.open(IoBridge.java:406)
03-01 12:14:31.964: WARN/System.err(197): at java.io.FileInputStream.<init>(FileInputStream.java:78)
03-01 12:14:31.964: WARN/System.err(197): at com.android.launcher2.IconCache.getFullResIcon(IconCache.java:142)
03-01 12:14:31.973: WARN/System.err(197): at com.android.launcher2.IconCache.cacheLocked(IconCache.java:282)
03-01 12:14:31.973: WARN/System.err(197): at com.android.launcher2.IconCache.getIcon(IconCache.java:250)
03-01 12:14:32.004: WARN/System.err(197): at com.android.launcher2.LauncherModel.getShortcutInfo(LauncherModel.java:1641)
03-01 12:14:32.004: WARN/System.err(197): at com.android.launcher2.LauncherModel$LoaderTask.loadWorkspace(LauncherModel.java:1041)
03-01 12:14:32.014: WARN/System.err(197): at com.android.launcher2.LauncherModel$LoaderTask.loadAndBindWorkspace(LauncherModel.java:756)
03-01 12:14:32.014: WARN/System.err(197): at com.android.launcher2.LauncherModel$LoaderTask.run(LauncherModel.java:821)
03-01 12:14:32.024: WARN/System.err(197): at android.os.Handler.handleCallback(Handler.java:605)
03-01 12:14:32.024: WARN/System.err(197): at android.os.Handler.dispatchMessage(Handler.java:92)
03-01 12:14:32.034: WARN/System.err(197): at android.os.Looper.loop(Looper.java:137)
03-01 12:14:32.044: WARN/System.err(197): at android.os.HandlerThread.run(HandlerThread.java:60)
03-01 12:14:32.044: WARN/System.err(197): Caused by: libcore.io.ErrnoException: open failed: EACCES (Permission denied)
03-01 12:14:32.064: WARN/System.err(197): at libcore.io.Posix.open(Native Method)
03-01 12:14:32.064: WARN/System.err(197): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:98)
03-01 12:14:32.114: WARN/System.err(197): at libcore.io.IoBridge.open(IoBridge.java:390)
03-01 12:14:32.114: WARN/System.err(197): ... 12 more
03-01 12:14:32.124: DEBUG/Launcher.IconCache(197): getFullResIcon
03-01 12:14:32.154: INFO/System.out(197): *********Executed******

Categories

Resources