当前位置: 首页 > 知识库问答 >
问题:

使用CodenameOneCamerakit.cn1lib构建问题

岳曦
2023-03-14
enter code here



package com.test;


import static com.codename1.ui.CN.*;

import com.codename1.camerakit.CameraEvent;
import com.codename1.camerakit.CameraKit;
import com.codename1.camerakit.CameraListener;
import com.codename1.components.FloatingActionButton;
import com.codename1.components.SpanLabel;
import com.codename1.components.ToastBar;
import com.codename1.ui.*;
import com.codename1.ui.layouts.BorderLayout;
import com.codename1.ui.layouts.LayeredLayout;
import com.codename1.ui.plaf.UIManager;
import com.codename1.ui.util.Resources;
import com.codename1.io.Log;

import java.io.IOException;
import com.codename1.ui.layouts.BoxLayout;
import com.codename1.io.NetworkEvent;

/**
 * This file was generated by <a href="https://www.codenameone.com/">Codename One</a> for the purpose 
 * of building native mobile applications using Java.
 */
public class CameraDemo3 {

    private Form current;
    private Resources theme;
    private CameraKit ck;


    public void init(Object context) {
        ck = CameraKit.create();

        // use two network threads instead of one
        updateNetworkThreadCount(2);

        theme = UIManager.initFirstTheme("/theme");

        // Enable Toolbar on all Forms by default
        Toolbar.setGlobalToolbar(true);

        // Pro only feature
        Log.bindCrashProtection(true);

        addNetworkErrorListener(err -> {
            // prevent the event from propagating
            err.consume();
            if(err.getError() != null) {
                Log.e(err.getError());
            }
            Log.sendLogAsync();
            Dialog.show("Connection Error", "There was a networking error in the connection to " + err.getConnectionRequest().getUrl(), "OK", null);
        });        
    }

    public void start() {
        if(ck != null && !ck.isStarted()) {
            ck.start();
        }
        if(current != null){
            current.show();
            return;
        }
        Form hi = new Form("Native Camera", new LayeredLayout());
        hi.setScrollableY(false);
        if(ck != null) {
            ck.addCameraListener(new CameraListener() {
                @Override
                public void onError(CameraEvent ev) {
                    // We currently get some errors on Android
                    Log.p(ev.getMessage() + " : " + ev.getExceptionMessage());
                }

                @Override
                public void onImage(CameraEvent ev) {
                    ToastBar.showInfoMessage("Captured image bytes");
                }

                @Override
                public void onVideo(CameraEvent ev) {
                    ToastBar.showInfoMessage("Captured video: " + ev.getFile());
                }
            });
            hi.add(ck.getView());
            Button video = new Button();
            FontImage.setMaterialIcon(video, FontImage.MATERIAL_VIDEOCAM);
            video.addActionListener(e -> {
                Boolean b = (Boolean)video.getClientProperty("capturing");
                if(b == null) {
                    video.putClientProperty("capturing", Boolean.TRUE);
                    ck.captureVideo();
                    FontImage.setMaterialIcon(video, FontImage.MATERIAL_VIDEOCAM_OFF);
                } else {
                    video.putClientProperty("capturing", null);
                    ck.stopVideo();
                    FontImage.setMaterialIcon(video, FontImage.MATERIAL_VIDEOCAM);
                }
            });
            FloatingActionButton fab = FloatingActionButton.createFAB(FontImage.MATERIAL_CAMERA);
            fab.bindFabToContainer(hi, CENTER, BOTTOM);
            fab.addActionListener(e -> ck.captureImage());

            Button toggleCamera = new Button();
            FontImage.setMaterialIcon(toggleCamera, FontImage.MATERIAL_CAMERA_FRONT);
            Button toggleFlash = new Button();
            FontImage.setMaterialIcon(toggleFlash, FontImage.MATERIAL_FLASH_ON);
            toggleCamera.addActionListener(e -> ck.toggleFacing());
            toggleFlash.addActionListener(e -> ck.toggleFlash());
            Container buttons = BoxLayout.encloseY(video, toggleCamera, toggleFlash);
            buttons.setScrollableY(true);
            hi.add(BorderLayout.east(buttons));
        } else {
            hi.add(BorderLayout.north(new SpanLabel("Loading native camera view")));
        }
        hi.show();
    }

    public void stop() {
        current = getCurrentForm();
        if(current instanceof Dialog) {
            ((Dialog)current).dispose();
            current = getCurrentForm();
        }
    }

    public void destroy() {
    }

}

生成服务器输出:

User-level: 1000
Request Args: 
-----------------
java.version=8
ios.NSCameraUsageDescription=We need camera access to grab pictures and videos
ios.newStorageLocation=true
-------------------
Executing: /home/ec2-user/android-sdk/tools/android create project --target android-23 --name CameraDemo3 --path /tmp/build9109673224646903413xxx/CameraDemo3 --activity CameraDemo3Stub --package com.test --gradle --gradle-version 2.0.0 Created directory /tmp/build9109673224646903413xxx/CameraDemo3/src/main/java
Created directory /tmp/build9109673224646903413xxx/CameraDemo3/src/main/java/com/test

...... cut to reduce length .....

Compiling with JDK Java compiler API.
/tmp/build9109673224646903413xxx/CameraDemo3/src/main/java/com/codename1/camerakit/impl/CameraNativeAccessImpl.java:3: error: package com.wonderkiln.camerakit does not exist
import com.wonderkiln.camerakit.*;
^
/tmp/build9109673224646903413xxx/CameraDemo3/src/main/java/com/codename1/camerakit/impl/CameraNativeAccessImpl.java:9: error: cannot find symbol
    private CameraView view;
            ^
  symbol:   class CameraView
  location: class CameraNativeAccessImpl
/tmp/build9109673224646903413xxx/CameraDemo3/src/main/java/com/codename1/camerakit/impl/CameraNativeAccessImpl.java:10: error: cannot find symbol
    private CameraKitEventListener listener = new CameraKitEventListener() {
            ^
  symbol:   class CameraKitEventListener
  location: class CameraNativeAccessImpl
/tmp/build9109673224646903413xxx/CameraDemo3/src/main/java/com/codename1/camerakit/impl/CameraNativeAccessImpl.java:10: error: cannot find symbol
    private CameraKitEventListener listener = new CameraKitEventListener() {
                                                  ^
  symbol:   class CameraKitEventListener
  location: class CameraNativeAccessImpl
/tmp/build9109673224646903413xxx/CameraDemo3/src/main/java/com/codename1/camerakit/impl/CameraNativeAccessImpl.java:35: error: cannot find symbol
                    view = new CameraView(AndroidNativeUtil.getContext());
                               ^
  symbol: class CameraView
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
5 errors
:compileDebugJavaWithJavac FAILED
:compileDebugJavaWithJavac (Thread[Daemon worker,5,main]) completed. Took 7.792 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileDebugJavaWithJavac'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
    at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
    at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:154)
    at org.gradle.internal.Factories$1.create(Factories.java:22)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:151)
    at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
    at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99)
    at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
    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:43)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
    at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)
    at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:45)
    at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:52)
    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:37)
    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.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:40)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:66)
    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.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41)
    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:246)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; see the compiler error output for details.
    at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:47)
    at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:33)
    at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:103)
    at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:52)
    at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:38)
    at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:34)
    at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:25)
    at org.gradle.api.internal.tasks.compile.incremental.IncrementalCompilationFinalizer.execute(IncrementalCompilationFinalizer.java:38)
    at org.gradle.api.internal.tasks.compile.incremental.IncrementalCompilationFinalizer.execute(IncrementalCompilationFinalizer.java:24)
    at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:157)
    at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:127)
    at com.android.build.gradle.tasks.factory.AndroidJavaCompile.compile(AndroidJavaCompile.java:49)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:244)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:220)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:231)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:209)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    ... 68 more


BUILD FAILED

Total time: 18.103 secs
Stopped 0 compiler daemon(s).
Received result Failure[value=org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':compileDebugJavaWithJavac'.] from daemon DaemonInfo{pid=11167, address=[46019278-8ed8-4606-8f74-3c03030b4a25 port:44179, addresses:[/0:0:0:0:0:0:0:1%lo, /127.0.0.1]], idle=false, context=DefaultDaemonContext[uid=1240b5d8-39f4-4710-ac85-f3cf1a99af7f,javaHome=/home/ec2-user/jdk1.8.0_45,daemonRegistryDir=/home/ec2-user/.gradle/daemon,pid=11167,idleTimeout=120000,daemonOpts=-XX:MaxPermSize=512m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx2048m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]} (build should be done).
Process return code is 1

共有1个答案

钱焕
2023-03-14

看起来您使用了cn1lib,并试图使用代码,而不是使用Codename One设置中的扩展管理器安装cn1lib。

我建议安装分机。

如果您仍然希望使用代码,请注意,您还需要复制更改以构建缺少的提示。它们位于作为cn1lib一部分的属性文件中。

 类似资料:
  • DockerFile: 在之后,GPG行显示为红色,图像创建失败。为什么?

  • 我从中查看了axis2的最新版本http://svn.apache.org/repos/asf/axis/axis2/java/core/trunk/安装了最新的maven。 在执行mvn安装后,我得到了以下信息。请帮帮我,我做错了什么? 这是pom的部分,因为整个东西太大了

  • 我是maven的新手,并用hello World创建了一个简单的maven项目。当我尝试运行Maven项目时,它会说:- [错误]尚未为此生成指定目标。必须指定有效的生命周期阶段或格式为:或:[:]:的目标。可用的生命周期阶段有:验证、初始化、生成源、过程源、生成资源、过程资源、编译、过程类、生成测试源、过程测试源、生成测试资源、过程测试资源、测试编译、过程测试类、测试、准备包、包、集成前测试、集

  • 请帮我解决Spring和Eclipse的问题。我试过解决其他一些问题,但这个问题很奇怪,我解决不了。 我试图使用Spring和Eclipse构建一个web应用程序,但它在pom.xml文件上显示了一个错误。我已经附加了pom.xml文件。

  • 在我的xamarin Android应用程序上得到以下错误。请帮助我解决这个问题。 C:\程序文件(x86)\msbuild\xamarin\android\xamarin.android.common.targets(5,5):错误MSB4018:“LinkAssemblies”任务意外失败。xamarin.android.xamarinandroidException:错误XA2006:无法解

  • 我试图使用cx_Oracle从AWS Lambda函数(python3.7)内部连接到RDS(Oracle)数据库。此外,Lambda函数本身是使用buildspec.yml文件从AWS CodeBuild自动构建的。CodeBuild本身通过配置AWS CodePipeline来运行,这样,每当我将代码放入的存储库(在本例中是AWS CodeCommit)更新时,它都会自动构建这些东西。 我所做