2
votes

I'm trying call DrawImage() on my code, I'm following this tutorial Jetpack Tutorial,

But I'm getting this error.:

Unresolved reference: DrawImage

I tried implement on build.gradle, this lib.: implementation 'androidx.ui:ui-foundation:0.1.0-dev04'

But I getting this error.:

Executing tasks: [clean, :app:assembleDebug] in project C:\Users\samue\Desktop\Projetos Kotlin\first-jetpack

Task :clean Task :app:clean Task :app:preBuild UP-TO-DATE Task :app:preDebugBuild UP-TO-DATE Task :app:compileDebugAidl NO-SOURCE Task :app:generateDebugBuildConfig Task :app:compileDebugRenderscript NO-SOURCE Task :app:prepareDebugKotlinCompileTask Task :app:generateDebugResValues Task :app:generateDebugResources Task :app:createDebugCompatibleScreenManifests Task :app:extractDeepLinksDebug Task :app:processDebugManifest Task :app:mergeDebugResources Task :app:processDebugResources

Task :app:compileDebugKotlin FAILED w: ATTENTION! This build uses unsafe internal compiler arguments:

-XXLanguage:+NonParenthesizedAnnotationsOnFunctionalTypes

This mode is not recommended for production use, as no stability/compatibility guarantees are given on compiler or generated code. Use it at your own risk!

e: java.lang.IllegalStateException: Backend Internal error: Exception during code generation Element is unknownThe root cause java.util.NoSuchElementException was thrown at: androidx.compose.plugins.kotlin.compiler.lower.ComposableCallTransformer.irComposableExpr(ComposableCallTransformer.kt:1362) at org.jetbrains.kotlin.codegen.CompilationErrorHandler.lambda$static$0(CompilationErrorHandler.java:35) at org.jetbrains.kotlin.backend.jvm.JvmBackendFacade.doGenerateFilesInternal$backend_jvm(JvmBackendFacade.kt:93) at org.jetbrains.kotlin.backend.jvm.JvmBackendFacade.doGenerateFilesInternal$backend_jvm$default(JvmBackendFacade.kt:64) at org.jetbrains.kotlin.backend.jvm.JvmBackendFacade.doGenerateFilesInternal$backend_jvm(JvmBackendFacade.kt:52) at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateModule(JvmIrCodegenFactory.kt:36) at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.doGenerateFiles(KotlinCodegenFacade.java:47) at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:39) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:638) at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:198) at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:172) at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:56) at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:85) at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:43) at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:104) at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:349) at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:105) at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:237) at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.access$compileIncrementally(IncrementalCompilerRunner.kt:37) at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner$compile$2.invoke(IncrementalCompilerRunner.kt:79) at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:91) at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:606) at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:99) at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1645) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357) at sun.rmi.transport.Transport$1.run(Transport.java:200) at sun.rmi.transport.Transport$1.run(Transport.java:197) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:196) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.util.NoSuchElementException: Collection contains no element matching the predicate. at androidx.compose.plugins.kotlin.compiler.lower.ComposableCallTransformer.irComposableExpr(ComposableCallTransformer.kt:1362) at androidx.compose.plugins.kotlin.compiler.lower.ComposableCallTransformer.visitBlock(ComposableCallTransformer.kt:252) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBlock(IrElementTransformerVoid.kt:128) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBlock(IrElementTransformerVoid.kt:24) at org.jetbrains.kotlin.ir.expressions.impl.IrBlockImpl.accept(IrBlockImpl.kt:52) at org.jetbrains.kotlin.ir.expressions.IrExpression$DefaultImpls.transform(IrExpression.kt:28) at org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBase.transform(IrExpressionBase.kt:24) at org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl.transformChildren(IrVariableImpl.kt:93) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoidKt.transformChildrenVoid(IrElementTransformerVoid.kt:288) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.transformChildrenVoid(IrElementTransformerVoid.kt:283) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.transformChildren(IrElementTransformerVoid.kt:25) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitDeclaration(IrElementTransformerVoid.kt:46) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitVariable(IrElementTransformerVoid.kt:87) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitVariable(IrElementTransformerVoid.kt:88) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitVariable(IrElementTransformerVoid.kt:24) at org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl.accept(IrVariableImpl.kt:86) at org.jetbrains.kotlin.ir.declarations.IrDeclaration$DefaultImpls.transform(IrDeclaration.kt:42) at org.jetbrains.kotlin.ir.declarations.impl.IrDeclarationBase.transform(IrDeclarationBase.kt:27) at org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl.transformChildren(IrBlockBodyImpl.kt:49) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoidKt.transformChildrenVoid(IrElementTransformerVoid.kt:288) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.transformChildrenVoid(IrElementTransformerVoid.kt:283) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.transformChildren(IrElementTransformerVoid.kt:25) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBody(IrElementTransformerVoid.kt:93) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBlockBody(IrElementTransformerVoid.kt:99) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBlockBody(IrElementTransformerVoid.kt:100) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBlockBody(IrElementTransformerVoid.kt:24) at org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl.accept(IrBlockBodyImpl.kt:40) at org.jetbrains.kotlin.ir.expressions.IrBody$DefaultImpls.transform(IrBody.kt:24) at org.jetbrains.kotlin.ir.expressions.IrBlockBody$DefaultImpls.transform(IrBody.kt) at org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl.transform(IrBlockBodyImpl.kt:26) at org.jetbrains.kotlin.ir.declarations.impl.IrFunctionBase.transformChildren(IrFunctionBase.kt:77) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoidKt.transformChildrenVoid(IrElementTransformerVoid.kt:288) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.transformChildrenVoid(IrElementTransformerVoid.kt:283) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.transformChildren(IrElementTransformerVoid.kt:25) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitDeclaration(IrElementTransformerVoid.kt:46) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFunction(IrElementTransformerVoid.kt:55) at androidx.compose.plugins.kotlin.compiler.lower.ComposableCallTransformer.visitFunction(ComposableCallTransformer.kt:205) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitSimpleFunction(IrElementTransformerVoid.kt:58) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitSimpleFunction(IrElementTransformerVoid.kt:59) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitSimpleFunction(IrElementTransformerVoid.kt:24) at org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl.accept(IrFunctionImpl.kt:89) at org.jetbrains.kotlin.ir.declarations.IrDeclaration$DefaultImpls.transform(IrDeclaration.kt:42) at org.jetbrains.kotlin.ir.declarations.impl.IrDeclarationBase.transform(IrDeclarationBase.kt:27) at org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl.transformChildren(IrFileImpl.kt:71) at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoidKt.transformChildrenVoid(IrElementTransformerVoid.kt:288) at androidx.compose.plugins.kotlin.compiler.lower.ComposableCallTransformer.lower(ComposableCallTransformer.kt:197) at org.jetbrains.kotlin.backend.common.LowerKt.lower(Lower.kt:66) at org.jetbrains.kotlin.backend.common.phaser.PhaseBuildersKt$makeIrModulePhase$1.invoke(PhaseBuilders.kt:235) at org.jetbrains.kotlin.backend.common.phaser.PhaseBuildersKt$makeIrModulePhase$1.invoke(PhaseBuilders.kt:228) at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedPhaseWrapper$runBody$1.invoke(CompilerPhase.kt:128) at org.jetbrains.kotlin.backend.common.phaser.CompilerPhaseKt.downlevel(CompilerPhase.kt:24) at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedPhaseWrapper.runBody(CompilerPhase.kt:127) at org.jetbrains.kotlin.backend.common.phaser.AbstractNamedPhaseWrapper.invoke(CompilerPhase.kt:105) at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:29) at org.jetbrains.kotlin.backend.common.phaser.CompilerPhaseKt.invokeToplevel(CompilerPhase.kt:42) at org.jetbrains.kotlin.backend.jvm.JvmLower.lower(JvmLower.kt:288) at org.jetbrains.kotlin.backend.jvm.JvmBackendFacade.doGenerateFilesInternal$backend_jvm(JvmBackendFacade.kt:91) ... 38 more

Task :app:javaPreCompileDebug

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:compileDebugKotlin'.

    Internal compiler 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 15s 12 actionable tasks: 12 executed

Can someone help me with this issue?

3

3 Answers

5
votes

In your module's build.gradle file, make sure that you have this in your android closure:

  buildFeatures {
    compose true
  }

  composeOptions {
    kotlinCompilerVersion "1.3.61-dev-withExperimentalGoogleExtensions-20200129"
    kotlinCompilerExtensionVersion "0.1.0-dev04"
  }

My guess is that you are missing the composeOptions.

3
votes

DrawImage() is part of androidx.ui:ui-foundation.

Open the build.gradle (Module: app) file and add the following line to the list of dependencies:

dependencies {
    ...
    implementation 'androidx.ui:ui-foundation:0.1.0-dev03'
}

I would recommend following Jetpack Compose Basics - Codelab, a more comprehensive tutorial by Google.

2
votes

You can see the latest composeOptions for the correct build here.

But keep in mind that the library API can vary greatly from version to version, and it would be better to take a look at the official example to examine the use of the Compose library.

Don't forget to switch the repository to the right branch corresponding to the latest version of the library (for example, at the time of the answer it's dev05 branch).