umair13adil / simple_beacons_flutter

A flutter plugin project to range & monitor iBeacons.
Apache License 2.0
35 stars 42 forks source link

Unable to run (or build) the application on Android #35

Closed kmigntw closed 3 years ago

kmigntw commented 3 years ago

Hi, I have the following error and it is impossible for me to run the app on Android. On iOS (where I have tested so far) it is working like a charm.

e: /Users/Home/Documents/SDKs/flutter/.pub-cache/hosted/pub.dartlang.org/beacons_plugin-1.0.19/android/src/main/kotlin/com/umair/beacons_plugin/BeaconHelper.kt: (155, 24): Type mismatch: inferred type is String? but String was expected

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':beacons_plugin:compileDebugKotlin'.
> Compilation error. See log for more details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 43s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
Building plugin beacons_plugin...
e: /Users/Home/Documents/SDKs/flutter/.pub-cache/hosted/pub.dartlang.org/beacons_plugin-1.0.19/android/src/main/kotlin/com/umair/beacons_plugin/AppUtils.kt: (14, 17): Unresolved reference: core
e: /Users/Home/Documents/SDKs/flutter/.pub-cache/hosted/pub.dartlang.org/beacons_plugin-1.0.19/android/src/main/kotlin/com/umair/beacons_plugin/AppUtils.kt: (66, 24): Unresolved reference: NotificationCompat
e: /Users/Home/Documents/SDKs/flutter/.pub-cache/hosted/pub.dartlang.org/beacons_plugin-1.0.19/android/src/main/kotlin/com/umair/beacons_plugin/AppUtils.kt: (73, 26): Unresolved reference: NotificationCompat
e: /Users/Home/Documents/SDKs/flutter/.pub-cache/hosted/pub.dartlang.org/beacons_plugin-1.0.19/android/src/main/kotlin/com/umair/beacons_plugin/BeaconsPlugin.kt: (11, 17): Unresolved reference: core
e: /Users/Home/Documents/SDKs/flutter/.pub-cache/hosted/pub.dartlang.org/beacons_plugin-1.0.19/android/src/main/kotlin/com/umair/beacons_plugin/BeaconsPlugin.kt: (12, 17): Unresolved reference: core
e: /Users/Home/Documents/SDKs/flutter/.pub-cache/hosted/pub.dartlang.org/beacons_plugin-1.0.19/android/src/main/kotlin/com/umair/beacons_plugin/BeaconsPlugin.kt: (168, 20): Unresolved reference: ContextCompat
e: /Users/Home/Documents/SDKs/flutter/.pub-cache/hosted/pub.dartlang.org/beacons_plugin-1.0.19/android/src/main/kotlin/com/umair/beacons_plugin/BeaconsPlugin.kt: (169, 21): Unresolved reference: ContextCompat
e: /Users/Home/Documents/SDKs/flutter/.pub-cache/hosted/pub.dartlang.org/beacons_plugin-1.0.19/android/src/main/kotlin/com/umair/beacons_plugin/BeaconsPlugin.kt: (200, 29): Unresolved reference: ActivityCompat
e: /Users/Home/Documents/SDKs/flutter/.pub-cache/hosted/pub.dartlang.org/beacons_plugin-1.0.19/android/src/main/kotlin/com/umair/beacons_plugin/BeaconsPlugin.kt: (204, 29): Unresolved reference: ActivityCompat
e: /Users/Home/Documents/SDKs/flutter/.pub-cache/hosted/pub.dartlang.org/beacons_plugin-1.0.19/android/src/main/kotlin/com/umair/beacons_plugin/BeaconsPlugin.kt: (253, 24): Unresolved reference: ContextCompat
e: /Users/Home/Documents/SDKs/flutter/.pub-cache/hosted/pub.dartlang.org/beacons_plugin-1.0.19/android/src/main/kotlin/com/umair/beacons_plugin/BeaconsPlugin.kt: (254, 25): Unresolved reference: ContextCompat
e: /Users/Home/Documents/SDKs/flutter/.pub-cache/hosted/pub.dartlang.org/beacons_plugin-1.0.19/android/src/main/kotlin/com/umair/beacons_plugin/BeaconsPlugin.kt: (263, 21): Unresolved reference: ContextCompat

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileReleaseKotlin'.
> Compilation error. See log for more details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 59s

Exception: The plugin beacons_plugin could not be built due to the issue above.

Any advice will be highly appreciated!

bambinoua commented 3 years ago

Something wrong with the fix. I still see this row

LOG.e(tag, e.message)

instead of

LOG.e(tag, e.message.ToString())

P.S. I removed package from cache and install pacakge again.

kmigntw commented 3 years ago

Something wrong with the fix. I still see this row

LOG.e(tag, e.message)

instead of

LOG.e(tag, e.message.ToString())

P.S. I removed pacakge from cache and install pacakge again.

The PR #36 is not include in the pub.dev version of the library. In other words the current version (1.0.19) does not have the fix. You can do it by yourself. Just go to the library source and edit it. For example where you call the library -> ctrl+click (cmd+click) on BeaconPlugin, then go to android -> app -> src -> main -> kotlin -> com.umair.beacons_plugin.BeaconHelper.kt and edit line 155

Screenshot 2021-01-15 at 15 50 35
bambinoua commented 3 years ago

I understand but the question why? ;) I did so in packages.yaml:

beacons_plugin:
  git:
    url: https://github.com/umair13adil/simple_beacons_flutter.git
    ref: master