开发者

NPE in an app with remote Service on some devices (market-specific?)

I have two apps: the first one is a remote service. It's manifest is:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.mecom.framework"
      android:versionCode="1"
      android:versionName="1.0">

    <application android:icon="@drawable/icon" android:label="@string/app_name">

            <activity android:name="SettingsActiviry"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

         <service android:name=".ParserService"
                  android:process=":remote"
                  android:enabled="true"
                  android:exported="true">
            <intent-filter>
                <action android:name="com.mecom.framework.parser.interfaces.Parser" />
                <action android:name="com.mecom.framework.PARSE" />
                <category android:name="com.mecom.framework.PARSE" />
            </intent-filter>
        </service>

    </application>

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

</manifest>

The second one binds to this service and executes a method. It's manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.mecom.berlingske"
      android:versionCode="1"
      android:versionName="1.0">

    <application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@android:style/Theme.Light">
        <activity android:name=".MainActivity"
                  android:label="@string/app_name"
                  android:theme="@style/BerlingskeMainTheme"
                  android:configChanges="keyboard|keyboardHidden|orientation">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name=".ArticleActivity"
                  android:label="@string/article"
                  android:theme="@style/BerlingskeMainTheme"
                  android:configChanges="keyboard|keyboardHidden|orientation"/>
    </application>

</manifest>

Now what is weird is these apps work perfectly fine on an emulator with Android 2.1 and on my rooted HTC Hero with Cyanogen 7 (Android 2.3.2).

BUT it throws the following exception on HTC Desire HD and Nexus S (both not rooted):

W/dalvikvm( 2990): threadid=8: thread exiting with uncaught exception (group=0x40025a70)
03-18 13:19:04.051: ERROR/AndroidRuntime(2990): FATAL EXCEPTION: AsyncTask #1
03-18 13:19:04.051: ERROR/AndroidRuntime(2990): java.lang.RuntimeException: An error occured while executing doInBackground()
03-18 13:19:04.051: ERROR/AndroidRuntime(2990):     at android.os.AsyncTask$3.done(AsyncTask.java:200)
03-18 13:19:04.051: ERROR/AndroidRuntime(2990):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
03-18 13:19:04.051: ERROR/AndroidRuntime(2990):     at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
03-18 13:19:04.051: ERROR/AndroidRuntime(2990):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
03-18 13:19:04.051: ERROR/AndroidRuntime(2990):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
03-18 13:19:04.051: ERROR/AndroidRuntime(2990):     at java.util.concurrent.Thre开发者_StackOverflow社区adPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
03-18 13:19:04.051: ERROR/AndroidRuntime(2990):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
03-18 13:19:04.051: ERROR/AndroidRuntime(2990):     at java.lang.Thread.run(Thread.java:1102)
03-18 13:19:04.051: ERROR/AndroidRuntime(2990): Caused by: java.lang.NullPointerException
03-18 13:19:04.051: ERROR/AndroidRuntime(2990):     at android.os.Parcel.readException(Parcel.java:1253)
03-18 13:19:04.051: ERROR/AndroidRuntime(2990):     at android.os.Parcel.readException(Parcel.java:1235)
03-18 13:19:04.051: ERROR/AndroidRuntime(2990):     at com.mecom.framework.parser.interfaces.Parser$Stub$Proxy.getArticlesList(Parser.java:174)
03-18 13:19:04.051: ERROR/AndroidRuntime(2990):     at com.mecom.berlingske.NewsListActivity$AsyncGetArticlesTask.doInBackground(NewsListActivity.java:139)
03-18 13:19:04.051: ERROR/AndroidRuntime(2990):     at com.mecom.berlingske.NewsListActivity$AsyncGetArticlesTask.doInBackground(NewsListActivity.java:1)
03-18 13:19:04.051: ERROR/AndroidRuntime(2990):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
03-18 13:19:04.051: ERROR/AndroidRuntime(2990):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
03-18 13:19:04.051: ERROR/AndroidRuntime(2990):     ... 4 more

I can provide more code (like that implementation of AsyncTask, for example), but the fact, that this code actually works in at least two situations makes me wonder, what can possibly be wrong here. Any ideas?

UPD: Just installed my other app, that uses IPC, on that devices, same problem. Installed it from the market -- works fine. Signed my current app, and reinstalled it. Did not help. Did the same thing for my other app -- did not help either. Is the only way to test my app on that devices is to deploy it to the market?


The NPE is caused because you are making an IPC call with missing data. This is evident by these lines in the logs:

03-18 13:19:04.051: ERROR/AndroidRuntime(2990):     at android.os.Parcel.readException(Parcel.java:1253)
03-18 13:19:04.051: ERROR/AndroidRuntime(2990):     at android.os.Parcel.readException(Parcel.java:1235)

To troubleshoot the problem, put log statements before every IPC call you make, outputting the parameters for that call to the logs. This will allow you to pinpoint when, where and hopefully why those IPC calls are being made without the proper data.

Since the phones are not rooted, you can collect the logs from the phone not connected to your PC using the app Log Collector (available from the market) which allows you to send your phone's logs to yourself via email or another means.

Good luck

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜