Note that there are some explanatory texts on larger screens.

plurals
  1. POerror in testing service class
    text
    copied!<pre><code>java.lang.NullPointerException at com.android.deviceintelligence1.test.Testappdata.testappd(Testappdata.java:29) at java.lang.reflect.Method.invokeNative(Native Method) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154) at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448) </code></pre> <p>this is error after running my test class.in error log.</p> <pre><code>public class Testappdata extends ServiceTestCase&lt;MainService&gt; { public Testappdata() { super(MainService.class); } protected void setUp() throws Exception { try { super.setUp(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } MainService main; public void testappd() { main = getService(); String Package = "com.android"; Assert.assertNotNull(main.appData(Package)); } </code></pre> <p>this is my test class.to test service to get data value.</p> <pre><code>public class MainService extends Service { private final static String TAG = "Device Intelligence"; double lat = 0.0; double lng = 0.0; List&lt;Address&gt; addresses = null; String addre; Handler mHandler = new Handler(); String lPackAgeName, packAgeName = ""; public static DataHelper dh; public String appData(String pName) { PackageManager pm = getPackageManager(); try { Method getPackageSizeInfo = pm.getClass().getMethod( "getPackageSizeInfo", String.class, IPackageStatsObserver.class); getPackageSizeInfo.invoke(pm, pName, new IPackageStatsObserver.Stub() { public void onGetStatsCompleted(PackageStats pStats, boolean succeeded) throws RemoteException { data_value = String.valueOf(pStats.dataSize / 1024) + "kb"; Log.d("bugs", "datavalue: " + data_value); } }); } catch (Exception e) { e.printStackTrace(); } return data_value; } </code></pre> <p>this is my service class.so how can I clear my error.is ther any changes needed in test class to get out of the error .thanks for help in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload