问题
I'm trying to use the Android L Developer Preview SDK, specifically the Bluetooth Low Energy classes. I set compileSdkVersion 'android-L'
, minSdkVersion 'L'
, and targetSdkVersion 'L'
. I can see the L platform SDK under "External Libraries", but when I go to see what is inside the android.jar, the android.bluetooth.le package is missing. Thus, I cannot use any of the Bluetooth LE classes such as BluetoothLeScanner and ScanCallback. Does anyone know how to fix this?
回答1:
I would guess this is a bug in Android Studio (there are some other APIs for which this has been reported too)...
If you write something like:
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
android.bluetooth.le.BluetoothLeScanner scanner = adapter.getBluetoothLeScanner();
then this is indeed reported as an error in Android Studio. However, it does build ok when using gradlew build
.
In short, you can use it, but it's really awkward. I hope this will be fixed soon.
回答2:
It must've been an Android Studio bug, I updated to 0.8.2 and the problem went away!
来源:https://stackoverflow.com/questions/24643083/android-l-developer-preview-packages-missing