Closed leahtrt closed 6 years ago
Hi @leahtrt . Thanks for raising an issue. I don't have much experience with ionic but I will try and help. Earlier when I tested with ionic to solve issue #17 it worked perfectly. I will try again and see if I run into issues. In the meantime what android version are you using ? For Android O and above you need to add an additional line in config.xml as mentioned in the readme.
Also try the solutions here and see if they help.
Hi @ChrisTomAlx . I tested on Huiwei with Android 8.0 and I added
Thanks, Leah
I just tested it all again in android Oreo, Unfortunately I am unable to recreate this issue on my side. Everything seems to be working in order for me. Could you try creating a blank project from scratch with just this plugin on a different device? That might help narrow down the problem.
Oh that's strange. Here is the blank project with this plugin. You can unzip it and run 'npm install'. blankProject.zip
Thanks, Leah
From a quick review of the code I see you haven't used the function properly. Instead of just scan.scanDoc()
under platform ready function you need to use the entire function right below platform ready as follows :-
scan.scanDoc(1, onSuccess, onFail);
function onSuccess(imageURI) {
//var image = document.getElementById('myImage');
//image.src = imageURI;
}
function onFail(message) {
alert('Failed because: ' + message);
}
In the function 1 represents that you want to use camera and 0 represents that you want to use gallery. I commented out the section that takes the imageURI and displays it in HTML(It was meant to be used in cordova), but I think you should be able to handle that part. Please change the function as above and let me know if you still have problems. Recreate this in a new blank project when you try it, else it might not work.
Initially I was getting the same error you were getting. After changing the function and removing platform android and re-adding it, the code worked. So I am closing this issue for now. Do let me know if you still are running into problems. If this helped please let me know as well. It might be useful to future users.
Hi @ChrisTomAlx, I tried again with above code in a new blank project. However, I still got the same error. But then I upgrade the version of Cordova Android with the following scripts, 'ionic cordova platform remove android' 'ionic cordova platform add android@7.0.0', it works perfect. It seems like this plugin isn’t compatible with cordova-android@6.3.0 I think. In the meantime, can you check and tell me what cordova-android version are you using in your project? Please correct me if i got something wrong.
Thanks, Leah
Oh I see what the issue is now. You are exactly right (tested this out on my end with android 6.3.0 and ran into the same problem as you did) and I apologize for jumping to conclusions. I am using android 7.0.0
as well.
The scan library is using implementation instead of compile now (since compile is deprecated). This is most likely the cause of the issue. I should have expected that change to break something :) .
Anyhow I am glad you got it to work. I am not sure if there is a way to provide backward compatibility with older versions of android without changing implementation back into compile, but I will look into it. For now I will change the documentation, package.json and plugin.xml to reflect the need for android 7.0.0.
I installed this plugin with script: ionic cordova plugin add cordova-plugin-document-scanner
Here is output from build: Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence. java.lang.IllegalStateException: buildToolsVersion is not specified. at com.google.common.base.Preconditions.checkState(Preconditions.java:173) at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.java:645) at com.android.build.gradle.BasePlugin$10.call(BasePlugin.java:608) at com.android.build.gradle.BasePlugin$10.call(BasePlugin.java:605) at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:156) at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:120) at com.android.build.gradle.BasePlugin.lambda$createTasks$1(BasePlugin.java:603) at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:93) at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:82)
BUILD FAILED
Total time: 4.537 secs
FAILURE: Build failed with an exception.
Where: Script 'C:\Users\Rachel\Reao\ReaoApp\Unsued\test\cDemo\platforms\android\cordova-plugin-document-scanner\starter-build.gradle' line: 10
What went wrong: A problem occurred evaluating script.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Error: cmd: Command failed with exit code 1 Error output: Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence. java.lang.IllegalStateException: buildToolsVersion is not specified. at com.google.common.base.Preconditions.checkState(Preconditions.java:173) at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.java:645) at com.android.build.gradle.BasePlugin$10.call(BasePlugin.java:608) at com.android.build.gradle.BasePlugin$10.call(BasePlugin.java:605) at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:156) at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:120) at com.android.build.gradle.BasePlugin.lambda$createTasks$1(BasePlugin.java:603) at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:93) at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:82) at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:44) at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:79) at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:30) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) at com.sun.proxy.$Proxy16.afterEvaluate(Unknown Source) at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:82) at org.gradle.configuration.project.LifecycleProjectEvaluator.doConfigure(LifecycleProjectEvaluator.java:76) at org.gradle.configuration.project.LifecycleProjectEvaluator.access$000(LifecycleProjectEvaluator.java:33) at org.gradle.configuration.project.LifecycleProjectEvaluator$1.execute(LifecycleProjectEvaluator.java:53) at org.gradle.configuration.project.LifecycleProjectEvaluator$1.execute(LifecycleProjectEvaluator.java:50) at org.gradle.internal.Transformers$4.transform(Transformers.java:169) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61) at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:50) at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:628) at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:129) at org.gradle.execution.TaskPathProjectEvaluator.configure(TaskPathProjectEvaluator.java:35) at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:60) at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:38) at org.gradle.initialization.DefaultGradleLauncher$1.execute(DefaultGradleLauncher.java:161) at org.gradle.initialization.DefaultGradleLauncher$1.execute(DefaultGradleLauncher.java:158) at org.gradle.internal.Transformers$4.transform(Transformers.java:169) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56) at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:158) at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:119) at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:102) at org.gradle.launcher.exec.GradleBuildController.run(GradleBuildController.java:71) at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28) at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26) at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75) at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:49) at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:44) at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:29) at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:47) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74) at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72) at org.gradle.util.Swapper.swap(Swapper.java:38) at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50) at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54) at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)
FAILURE: Build failed with an exception.
Where: Script 'C:\Users\Rachel\Reao\ReaoApp\Unsued\test\cDemo\platforms\android\cordova-plugin-document-scanner\starter-build.gradle' line: 10
What went wrong: A problem occurred evaluating script.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Here is my ionic and system info: @ionic/cli-utils : 1.19.0 ionic (Ionic CLI) : 3.19.0
global packages: cordova (Cordova CLI) : 7.1.0 local packages: @ionic/app-scripts : 3.1.9 Cordova Platforms : android 6.3.0 Ionic Framework : ionic-angular 3.9.2 System: Android SDK Tools : 25.2.3 Node : v6.11.3 npm : 5.5.1 OS : Windows 10