petermetz / cordova-plugin-ibeacon

An iBeacon plugin for Phonegap / Cordova 3.x and upwards. Supports both iOS and Android (contributions are welcome)
Apache License 2.0
728 stars 372 forks source link

Android 8 IllegalArgumentException: No such service #350

Open capur16 opened 6 years ago

capur16 commented 6 years ago

Hi running this plugin on a oneplus 3t with android 8.0 I receive the following error: java.lang.IllegalArgumentException: No such service ComponentInfo{com.example.myproject/org.altbeacon.beacon.service.ScanJob}

To make it work I had to add the following lines to the AndroidManifest.xml:

<service android:permission="android.permission.BIND_JOB_SERVICE" android:name="org.altbeacon.beacon.service.ScanJob"> </service>

and

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

Please you could fix this thanks

sidPuttur commented 6 years ago

Hi., Even i have a crashing issue in android 8 and no logs printed. Can you please explain what is BIND_JOB_SERVICE and org.altbeacon.beacon.service.ScanJob? . Is this specific to your use case?

Thanks

Powerball18 commented 6 years ago

This didn't fix it for me. I'm using Ionic 3.0 and added it to the config like this. `

        <service android:name="org.altbeacon.beacon.service.ScanJob" android:permission="android.permission.BIND_JOB_SERVICE">
        </service>
    </config-file>` any other ideas?
vienom commented 6 years ago

The target of a service is the application, the target of the uses-permission is the manifest. Try it like this:

`

    </edit-config>
    <edit-config file="AndroidManifest.xml" mode="add" target="/manifest">
        <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    </edit-config>`
vienom commented 6 years ago

Actually its better to change the permissions in the plugin.xml. Faced some issues with the above solution. Here is a fork where you can see the changes: https://github.com/vienom/cordova-plugin-ibeacon

BertrandJU commented 6 years ago

Works well in config.xml with plugin "cordova-custom-config":

<platform name="android">
        <allow-intent href="market:*" />
        <!-- FIX ANDROID 8 see: https://github.com/petermetz/cordova-plugin-ibeacon/issues/350 -->
        <custom-config-file parent="/*" target="AndroidManifest.xml">
            <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
        </custom-config-file>
        <custom-config-file parent="./application" target="AndroidManifest.xml">
            <service android:name="org.altbeacon.beacon.service.ScanJob" android:permission="android.permission.BIND_JOB_SERVICE" />
        </custom-config-file>
    </platform>

(Permission RECEIVE_BOOT_COMPLETED is not required)

andersborgabiro commented 6 years ago

Anyone knows why this is needed? It wasn't in Android 7.

dopry commented 6 years ago

@andersborgabiro the beacon handling and background tasks in Android 8 changed. http://www.davidgyoungtech.com/2017/08/07/beacon-detection-with-android-8 covers some of it. You can dig up some more details starting at https://developer.android.com/about/versions/oreo/android-8.0-migration.html look into the Bluetooth and background changes.

andersborgabiro commented 6 years ago

Thanks for the info. As the plugin is using beacon library 2.12.4 I guess this should work fine now.

dopry commented 6 years ago

There are still permission and dependency issues that effect Android 8. If you have time to test #363 and #364 could use additional testing and review.

andersborgabiro commented 6 years ago

Right at this very now I don't have a phone with Android 8, but when I do I will.

lincolnberryiii commented 6 years ago

@vienom's solution worked for me: Google Pixel XL running Android P Beta.

halindrome commented 6 years ago

Seems to be working for me as well. Thanks!

dopry commented 6 years ago

@halindrome what seems to be working for you? #363 and #364 or manually adding the permissions to your manifest? On which platform?

halindrome commented 6 years ago

Manually adding the permissions (through custom-config on cordova)

On Mon, Jul 23, 2018 at 12:57 PM dopry notifications@github.com wrote:

@halindrome https://github.com/halindrome what seems to be working for you? #363 https://github.com/petermetz/cordova-plugin-ibeacon/pull/363 and #364 https://github.com/petermetz/cordova-plugin-ibeacon/pull/364 or manually adding the permissions to your manifest? On which platform?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/petermetz/cordova-plugin-ibeacon/issues/350#issuecomment-407146480, or mute the thread https://github.com/notifications/unsubscribe-auth/AAfx8Ht15zpYq4klbtMZ3GMGt-Q5_NReks5uJg6LgaJpZM4SIILz .

-- Shane McCarron halindrome@gmail.com

dopry commented 6 years ago

@halindrome, which version of cordova-android and the cordova-ibeacon-plugin are you using?

halindrome commented 6 years ago

cordova-android is 6.4.0 I think. cordova-plugin-ibeacon is at 3.6.1 I think.

On Mon, Jul 23, 2018 at 1:58 PM dopry notifications@github.com wrote:

@halindrome https://github.com/halindrome, which version of cordova-android and the cordova-ibeacon-plugin are you using?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/petermetz/cordova-plugin-ibeacon/issues/350#issuecomment-407165178, or mute the thread https://github.com/notifications/unsubscribe-auth/AAfx8DMbcjJUYMZfRaa9ePAXAQM8uY7nks5uJhzygaJpZM4SIILz .

-- Shane McCarron halindrome@gmail.com

dopry commented 6 years ago

Can you try with the latest 3.x version of the plugin directly from github and see if the permissions are still required?

On Mon, Jul 23, 2018, 3:10 PM Shane McCarron notifications@github.com wrote:

cordova-android is 6.4.0 I think. cordova-plugin-ibeacon is at 3.6.1 I think.

On Mon, Jul 23, 2018 at 1:58 PM dopry notifications@github.com wrote:

@halindrome https://github.com/halindrome, which version of cordova-android and the cordova-ibeacon-plugin are you using?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/petermetz/cordova-plugin-ibeacon/issues/350#issuecomment-407165178 , or mute the thread < https://github.com/notifications/unsubscribe-auth/AAfx8DMbcjJUYMZfRaa9ePAXAQM8uY7nks5uJhzygaJpZM4SIILz

.

-- Shane McCarron halindrome@gmail.com

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/petermetz/cordova-plugin-ibeacon/issues/350#issuecomment-407168482, or mute the thread https://github.com/notifications/unsubscribe-auth/AAXqOPAYvjW4-EC6syJIdkSceG8blI4dks5uJh-lgaJpZM4SIILz .

petermetz commented 6 years ago

I'll be releasing v3.6.2 to npm soon. Please watch out for that and give it a try.

andersborgabiro commented 6 years ago

Great! Looking forward to that.

petermetz commented 6 years ago

The new release just dropped on npm. Ended up calling it v3.7.0

halindrome commented 6 years ago

I will do some testing with it in the AM.

On Tue, Jul 24, 2018 at 7:41 PM Peter Metz notifications@github.com wrote:

The new release just dropped on npm. Ended up calling it v3.7.0

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/petermetz/cordova-plugin-ibeacon/issues/350#issuecomment-407596060, or mute the thread https://github.com/notifications/unsubscribe-auth/AAfx8FB_qspYIQCKgy3IClQxVW8ipgOfks5uJ767gaJpZM4SIILz .

-- Shane McCarron halindrome@gmail.com

andersborgabiro commented 6 years ago

Works fine on Android 6 and 7 and iOS 11.4.1.

So, is the Android 8 specific configuration not needed anymore? Anything else that's changed? (there's no release note, so I couldn't check there)

halindrome commented 6 years ago

Started testing now - I have been pulling these straight from github instead of npm for a variety of reasons. There is no tag for 3.7.0 FWIW.

petermetz commented 6 years ago

@andersborgabiro @halindrome Forgot to create the tag/release on GitHub yesterday, but here it is now: https://github.com/petermetz/cordova-plugin-ibeacon/releases/tag/3.7.0

For future reference: the CHANGELOG file always contains the release notes as well.

andersborgabiro commented 6 years ago

Great! Thanks.

The custom config is removed.

dopry commented 6 years ago

@andersborgabiro, so everything is building and working for you? Did you also do a complete uninstall on your development device to ensure there aren't any permissions hanging around from an earlier update?

andersborgabiro commented 6 years ago

Good idea. I'll test that tomorrow.

andersborgabiro commented 6 years ago

No problems so far with uninstalling, but right now done on devices lower than Android 8.

halindrome commented 6 years ago

@petermetz thanks for adding the tag. I note that it does not follow your usual pattern of starting with a 'v' however. Might confuse some people.

petermetz commented 6 years ago

@halindrome Yes! Thank you for pointing that out! We need more automation to eliminate these silly mistakes. Created a new tag, this time with the right name.