0

Using the following code, I'm trying to get the available cell information:

import android.telephony.CellInfo;

TelephonyManager telephonyManager = (TelephonyManager)context.getSystemService( context.TELEPHONY_SERVICE );
List<CellInfo> cellList = telephonyManager.getAllCellInfo();

Knowing that the method getAllCellInfo() and class CellInfo was introduced in API Level 17, I've set android:minSdkVersion="17" in the AndroidManifest.xml file.

However, in Eclipse I'm getting an errors stating: The import android.telephony.CellInfo cannot be resolved and The method getAllCellInfo() is undefined for the type TelephonyManager

I've tried cleaning, closing Eclipse and rebuilding my project, but I'm still getting these errors. I'm at a loss as to why Eclipse is not recognizing these declarations

Thanks for your help.

Edit: Permission android.permission.ACCESS_COARSE_LOCATION is also included within the AndroidManifest.xml file. But the issue still remains.

kralvarado
  • 458
  • 5
  • 13
  • Have you added the permission `ACCESS_COARSE_LOCATION` – Psypher Mar 12 '15 at 19:56
  • Yes, that is also in the Manifest. I'm able to use method telephonyManager.getNetworkOperator(); which requires that permission. – kralvarado Mar 12 '15 at 19:58
  • **Solved:** The issue was, even though I did edit the AndroidManifest.xml file. the **project.properties** file was not being updated, changing: `target=android-17` in the file resolved the issue. – kralvarado Mar 12 '15 at 20:10

1 Answers1

1

Check your project.properties file and look at the target you are building against. It should look something like this:

target=Google Inc.:Google APIs:17

This is an old project I had on hand which was building for API 17 (with Google APIs.)

You can also go into the Project properties and check the target in the UI. That setting corresponds to this file and is what Eclipse uses to build against, not the manifest. The manifest is used at runtime on the platform to know what compatibility modes to enable in the framework.

Larry Schiefer
  • 15,687
  • 2
  • 27
  • 33
  • Yes, that was what the issue was. Thank you. – kralvarado Mar 12 '15 at 20:13
  • You're very welcome. I'll toss this out there for you: if you use Android Studio, it'll actually tell you not to put the min/target SDK info in the manifest file. It uses the gradle build files to know what to build against and will autogenerate that section of your manifest for you. Helps to reduce this type of strangeness. – Larry Schiefer Mar 12 '15 at 20:19
  • Thanks for your input, I'm currently on a project where it's not feasible to switch over to Android Studio. Too much involved in build and deployment process and too close to deadlines to switch over now. – kralvarado Mar 13 '15 at 21:34