Estimote / Android-Fleet-Management-SDK

Estimote Fleet Management SDK for Android
https://developer.estimote.com
MIT License
836 stars 451 forks source link

AndroidManifest.xml does not contain android.permission.BLUETOOTH or android.permission.BLUETOOTH_ADMIN #80

Closed anvk closed 10 years ago

anvk commented 10 years ago

Nexus 4 device + Android Studio

Hi, I created a tiny app based on the demo example. Running it on my Nexus4 USB attached device. But application constantly fails with the error:

E/EstimoteSDK﹕ com.estimote.sdk.BeaconManager.isBluetoothEnabled:182 AndroidManifest.xml does not contain android.permission.BLUETOOTH or android.permission.BLUETOOTH_ADMIN permissions. BeaconService may be also not declared in AndroidManifest.xml.

beaconManager.isBluetoothEnabled() constantly returns false

I double checked that my AndroidManifest.xml contains the following lines:

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<service android:name="com.estimote.sdk.service.BeaconService"
    android:exported="false"/>

<!-- Declaration that this app is usable on phones with Bluetooth Low Energy. -->
<uses-feature android:name="android.hardware.bluetooth_le"
    android:required="true"/>

I tried to rebuild the app multiple times but no success. Disabled and enabled bluetooth on my phone multiple times. Maybe I'm missing something stupid...

wiktor commented 10 years ago

See examples. You probably placed that in wrong element of AndroidManifest.xml

On Tue, Sep 23, 2014 at 10:17 PM, Alexey Novak notifications@github.com wrote:

Nexus 4 device + Android Studio Hi, I created a tiny app based on the demo example. Running it on my Nexus4 USB attached device. But application constantly fails with the error: E/EstimoteSDK﹕ com.estimote.sdk.BeaconManager.isBluetoothEnabled:182 AndroidManifest.xml does not contain android.permission.BLUETOOTH or android.permission.BLUETOOTH_ADMIN permissions. BeaconService may be also not declared in AndroidManifest.xml. beaconManager.isBluetoothEnabled() constantly returns false I double checked that my AndroidManifest.xml contains the following lines:

<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<service android:name="com.estimote.sdk.service.BeaconService"
    android:exported="false"/>
<!-- Declaration that this app is usable on phones with Bluetooth Low Energy. -->
<uses-feature android:name="android.hardware.bluetooth_le"
    android:required="true"/>

I tried to rebuild the app multiple times but no success. Disabled and enabled bluetooth on my phone multiple times.

Maybe I'm missing something stupid...

Reply to this email directly or view it on GitHub: https://github.com/Estimote/Android-SDK/issues/80

anvk commented 10 years ago

I tried to replicate AndroidManifest.xml given in the example but it gives the same error.

Here is my file which is almost identical to what is in Demos

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

<uses-sdk
    android:minSdkVersion="18"
    android:targetSdkVersion="18"/>

<!-- Needed permissions in order to scan for beacons. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.INTERNET" />

<!-- Declaration that this app is usable on phones with Bluetooth Low Energy. -->
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".LoginActivity"
        android:exported="true"
        android:label="@string/app_name"
        android:windowSoftInputMode="adjustResize|stateVisible" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

    <activity
        android:name=".Beacons"
        android:label="@string/title_activity_beacons" >
    </activity>
</application>

<!-- Estimote service responsible for scanning beacons. -->
<service android:name="com.estimote.sdk.service.BeaconService"
    android:exported="false"/>

anvk commented 10 years ago

I also added code to onCreate of my LoginActivity. (based on http://stackoverflow.com/questions/7672334/how-to-check-if-bluetooth-is-enabled-programmatically) and it seems that app HAS bluetooth permissions

BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
        if (mBluetoothAdapter == null) {
            Toast.makeText(getApplicationContext(), "Device does not support Bluetooth", Toast.LENGTH_LONG).show();
        } else {
            if (!mBluetoothAdapter.isEnabled()) {
                Toast.makeText(getApplicationContext(), "Bluetooth is not enabled", Toast.LENGTH_LONG).show();
            } else {
                Toast.makeText(getApplicationContext(), "Bluetooth is enabled", Toast.LENGTH_LONG).show();
            }
        }

Now if I remove permissions

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

then my code above would crash with error java.lang.SecurityException: Need BLUETOOTH permission: Neither user 10211 nor current process has android.permission.BLUETOOTH.

Which clearly indicates that my application is setup properly in terms of permissions

wiktor commented 10 years ago

Which OS version?

Did you run demos from SDK?

anvk commented 10 years ago

I tried it first on my OSX at home (Mavericks) Then tried on my Windows 7 work computer. I did run demos and they did start.

But the most weird part that the app I created is absolutely tiny and following the guidelines from README.md. Created basic Android app with Login activity, added the code listed in README to onStart, onCreate, ... added permissions, added SDK jar file. That's it and no go.

Is it possible for me to send you the zip project to look at? It is literally Android starting template with the code listed in the README.md. If we can find what is wrong we could reply in the thread for anyone else who will encounter the same issue.

wiktor commented 10 years ago

Put it on github somewhere.

On Wed, Sep 24, 2014 at 4:07 PM, Alexey Novak notifications@github.com wrote:

I tried it first on my OSX at home (Mavericks) Then tried on my Windows 7 work computer. I did run demos and they did start. But the most weird part that the app I created is absolutely tiny and following the guidelines from README.md. Created basic Android app with Login activity, added the code listed in README to onStart, onCreate, ... added permissions, added SDK jar file. That's it and no go.

Is it possible for me to send you the zip project to look at? It is literally Android starting template with the code listed in the README.md. If we can find what is wrong we could reply in the thread for anyone else who will encounter the same issue.

Reply to this email directly or view it on GitHub: https://github.com/Estimote/Android-SDK/issues/80#issuecomment-56674477

anvk commented 10 years ago

Here is repo https://github.com/anvk/EstimoteExample

Thanks!

wiktor commented 10 years ago

I cannot see problem straight away. There might be some subtle bug. Please do work on the demos to strip them to bare bones.

oskargustafsson commented 10 years ago

The "service" tag should be inside the "application" tag, which it is not in the https://github.com/anvk/EstimoteExample.

harishkalyanchakravarty commented 9 years ago

@oskargustafsson :+1: You are awesome, i was facing a similar issue on android and your reply had solved this...thanks a million

aogooe commented 8 years ago

Hi, I also met the same problem with you, I check in the whole project for a long time, the code without any problems.Do you find a solution on this issue?For help

heypiotr commented 8 years ago

Have you tried oskargustafsson's solution?