flutter_lamp icon indicating copy to clipboard operation
flutter_lamp copied to clipboard

Not working on Android

Open agreensh opened this issue 7 years ago • 11 comments

Android Version 7.0 Samsung Galaxy S6 (model SM-G920F)

Error when using the plugin in my app

E/MethodChannel#github.com/clovisnicolas/flutter_lamp(14908): Failed to handle method call E/MethodChannel#github.com/clovisnicolas/flutter_lamp(14908): java.lang.RuntimeException: getParameters failed (empty parameters) E/MethodChannel#github.com/clovisnicolas/flutter_lamp(14908): at android.hardware.Camera.native_getParameters(Native Method) E/MethodChannel#github.com/clovisnicolas/flutter_lamp(14908): at android.hardware.Camera.getParameters(Camera.java:1952) E/MethodChannel#github.com/clovisnicolas/flutter_lamp(14908): at plugins.flutter.lamp.lamp.LampPlugin.turn(LampPlugin.java:63) E/MethodChannel#github.com/clovisnicolas/flutter_lamp(14908): at plugins.flutter.lamp.lamp.LampPlugin.onMethodCall(LampPlugin.java:34) E/MethodChannel#github.com/clovisnicolas/flutter_lamp(14908): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:200) E/MethodChannel#github.com/clovisnicolas/flutter_lamp(14908): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163) E/MethodChannel#github.com/clovisnicolas/flutter_lamp(14908): at android.os.MessageQueue.nativePollOnce(Native Method) E/MethodChannel#github.com/clovisnicolas/flutter_lamp(14908): at android.os.MessageQueue.next(MessageQueue.java:323) E/MethodChannel#github.com/clovisnicolas/flutter_lamp(14908): at android.os.Looper.loop(Looper.java:136) E/MethodChannel#github.com/clovisnicolas/flutter_lamp(14908): at android.app.ActivityThread.main(ActivityThread.java:6682) E/MethodChannel#github.com/clovisnicolas/flutter_lamp(14908): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#github.com/clovisnicolas/flutter_lamp(14908): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) E/MethodChannel#github.com/clovisnicolas/flutter_lamp(14908): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

Another error when building your example:

E/BoostFramework(24970): BoostFramework() : Exception_1 = java.lang.ClassNotFoundException: Didn't find class "com.qualcomm.qti.Performance" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib64, /vendor/lib64]]

agreensh avatar Dec 03 '18 10:12 agreensh

https://github.com/clovisnicolas/flutter_lamp/issues/5#issuecomment-440597092

the problem is, that for android this library uses the deprecated android.hardware.Camera, which is only supported up to android sdk version 20 for higher versions using android.hardware.camera2 is recommendet on my side I tried to change the LampPlugin, and it compiles without errors, sadly the light still wont turn on

remijeas avatar Dec 03 '18 22:12 remijeas

I wrote my own plugin which works.

agreensh avatar Dec 03 '18 22:12 agreensh

I wrote my own plugin which works.

Care to share?

HectorV12 avatar Dec 12 '18 18:12 HectorV12

Care to share?

I've incorporated the lamp functionality in my "utils" plugin (so it has lots of other stuff), but I can share the code for the lamp/torch if you want. To be honest, it's very similar to the code in this plugin (except the iOS code is in Swift) - I think this plugin just needs re-creating with the latest version of Flutter (and republish), as it looks like there are issues in the Android project files, not the actual code.

agreensh avatar Dec 14 '18 11:12 agreensh

Care to share?

I've incorporated the lamp functionality in my "utils" plugin (so it has lots of other stuff), but I can share the code for the lamp/torch if you want. To be honest, it's very similar to the code in this plugin (except the iOS code is in Swift) - I think this plugin just needs re-creating with the latest version of Flutter (and republish), as it looks like there are issues in the Android project files, not the actual code.

Please share.

Seedorf161 avatar Dec 16 '18 09:12 Seedorf161

I've tested this plugin on iOS 10.0.0 up to 12.1.1 and Android up to Oreo (on a Samsung) and Nougat (on a Motorola). Works for me.

torch.zip

agreensh avatar Dec 16 '18 13:12 agreensh

I've tested this plugin on iOS 10.0.0 up to 12.1.1 and Android up to Oreo (on a Samsung) and Nougat (on a Motorola). Works for me.

torch.zip

Guide us on usage please. I'm used to installing packages from dart pub.

Seedorf161 avatar Dec 16 '18 13:12 Seedorf161

Put the 'torch' directory at the same level as your project, then in pubspec.yaml (of your project) add

  torch:
    path: ../torch

then in dart file where you want to use it

import 'package:torch/torch.dart';

agreensh avatar Dec 16 '18 13:12 agreensh

Put the 'torch' directory at the same level as your project, then in pubspec.yaml (of your project) add

  torch:
    path: ../torch

then in dart file where you want to use it

import 'package:torch/torch.dart';

@agreensh thanks for the contribution, for me the plugins works ok for android but in IOS I got this error:

Xcode build done. 2.2s Failed to build iOS app Error output from Xcode build: ↳ ** BUILD FAILED ** Xcode's output: ↳ === BUILD TARGET torch OF PROJECT Pods WITH CONFIGURATION Debug === /Users/alks/Projects/torch/ios/Classes/TorchPlugin.m:2:9: fatal error: 'torch/torch-Swift.h' file not found #import <torch/torch-Swift.h>

When i change the name of the file to torch.swift but the same error happen:

↳ ** BUILD FAILED ** Xcode's output: ↳ === BUILD TARGET torch OF PROJECT Pods WITH CONFIGURATION Debug === /Users/alks/Projects/torch/ios/Classes/TorchPlugin.m:2:9: fatal error: 'SwiftTorchPlugin-Swift.h' file not found #import <SwiftTorchPlugin-Swift.h> ^~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated.

Help appreciated ... Regards

admerzeau avatar Dec 19 '18 04:12 admerzeau

@agreensh thanks again for your help! maybe you can help with this issue: https://github.com/rmtmckenzie/flutter_qr_mobile_vision/issues/55#issuecomment-448816074 your package works and turns on the flashlight but I get errors that possibly conflicts with another package. Any help is appreciated, thanks!

HectorV12 avatar Dec 20 '18 01:12 HectorV12

@agreensh does your plugin works with the camera opened?

jovinho avatar Nov 12 '19 02:11 jovinho