我在嘗試將我的項目更新爲使用Android Studio 3.0 Beta 2,並在我的Kotlin擴展功能中出現錯誤。我有一個模塊sdk
其包括提供擴展功能的幾個科特林文件,一個例子:Android Studio 3.0 kotlin擴展功能'未解決的參考'
fun Context.hasPermission(permission: String): Boolean =
ContextCompat.checkSelfPermission(this, permission) == PackageManager.PERMISSION_GRANTED
我使用在其他2個模塊此功能我已經從compile project(':sdk')
變爲implementation project(':sdk')
。當我編譯時,我得到的錯誤:
Unresolved error: hasPermission
當更新獲取這些擴展功能跨模塊時,我應該做什麼嗎?
UPDATE
我改變函數簽名不再是一個擴展功能,而是看起來像:
fun hasPermission(context: Context, permission: String): Boolean
ContextCompat.checkSelftPermission(context, permission) == PackageManager.PERMISSION_GRANTED
我仍然得到同樣的錯誤,如果我不是把它包裝類或內部它的工作對象。
object ContextUtils {
fun hasPermission(context: Context, permission: String): Boolean
ContextCompat.checkSelftPermission(context, permission) == PackageManager.PERMISSION_GRANTED
}
UPDATE
我與--info --stacktrace
標誌跑了構建和這裏的輸出(還有更多的事情,但是這似乎是相關部分):
:sdk:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug (Thread[Daemon worker,5,main]) completed. Took 0.231 secs.
:experience:dataBindingExportBuildInfoDebug (Thread[Daemon worker,5,main]) started.
:experience:dataBindingExportBuildInfoDebug
Putting task artifact state for task ':experience:dataBindingExportBuildInfoDebug' into context took 0.002 secs.
file or directory '/home/yperess/workspace/Metaverse/experience/src/debug/java', not found
Executing task ':experience:dataBindingExportBuildInfoDebug' (up-to-date check took 0.024 secs) due to:
Output property 'output' file /home/yperess/workspace/Metaverse/experience/build/generated/source/dataBinding/debug has changed.
Output property 'output' file /home/yperess/workspace/Metaverse/experience/build/generated/source/dataBinding/debug/android has been removed.
Output property 'output' file /home/yperess/workspace/Metaverse/experience/build/generated/source/dataBinding/debug/android/databinding has been removed.
All input files are considered out-of-date for incremental task ':experience:dataBindingExportBuildInfoDebug'.
:experience:dataBindingExportBuildInfoDebug (Thread[Daemon worker,5,main]) completed. Took 0.033 secs.
:experience:kaptGenerateStubsDebugKotlin (Thread[Task worker for ':',5,main]) started.
:experience:kaptGenerateStubsDebugKotlin
Putting task artifact state for task ':experience:kaptGenerateStubsDebugKotlin' into context took 0.0 secs.
Executing task ':experience:kaptGenerateStubsDebugKotlin' (up-to-date check took 0.009 secs) due to:
Output property 'destinationDir' file /home/yperess/workspace/Metaverse/experience/build/tmp/kapt3/incrementalData/debug has changed.
Output property 'destinationDir' file /home/yperess/workspace/Metaverse/experience/build/tmp/kapt3/incrementalData/debug/com has been removed.
Output property 'destinationDir' file /home/yperess/workspace/Metaverse/experience/build/tmp/kapt3/incrementalData/debug/com/gometa has been removed.
All input files are considered out-of-date for incremental task ':experience:kaptGenerateStubsDebugKotlin'.
file or directory '/home/yperess/workspace/Metaverse/experience/src/debug/kotlin', not found
file or directory '/home/yperess/workspace/Metaverse/experience/src/debug/kotlin', not found
Using kotlin incremental compilation
:experience:kaptGenerateStubsDebugKotlin (Thread[Task worker for ':',5,main]) completed. Took 3.386 secs.
:experience:kaptDebugKotlin (Thread[Task worker for ':' Thread 3,5,main]) started.
:experience:kaptDebugKotlin
Putting task artifact state for task ':experience:kaptDebugKotlin' into context took 0.0 secs.
file or directory '/home/yperess/workspace/Metaverse/experience/src/debug/kotlin', not found
Executing task ':experience:kaptDebugKotlin' (up-to-date check took 0.012 secs) due to:
Output property 'destinationDir' file /home/yperess/workspace/Metaverse/experience/build/generated/source/kapt/debug/com has been removed.
Output property 'destinationDir' file /home/yperess/workspace/Metaverse/experience/build/generated/source/kapt/debug/com/gometa has been removed.
Output property 'destinationDir' file /home/yperess/workspace/Metaverse/experience/build/generated/source/kapt/debug/com/gometa/metaverse has been removed.
file or directory '/home/yperess/workspace/Metaverse/experience/src/debug/kotlin', not found
file or directory '/home/yperess/workspace/Metaverse/experience/src/debug/kotlin', not found
w: warning: Supported source version 'RELEASE_7' from annotation processor 'android.arch.lifecycle.LifecycleProcessor' less than -source '1.8'
w:
:experience:kaptDebugKotlin (Thread[Task worker for ':' Thread 3,5,main]) completed. Took 3.489 secs.
:experience:compileDebugKotlin (Thread[Task worker for ':' Thread 3,5,main]) started.
:experience:compileDebugKotlin
Putting task artifact state for task ':experience:compileDebugKotlin' into context took 0.001 secs.
file or directory '/home/yperess/workspace/Metaverse/experience/src/debug/kotlin', not found
Executing task ':experience:compileDebugKotlin' (up-to-date check took 0.035 secs) due to:
Task.upToDateWhen is false.
All input files are considered out-of-date for incremental task ':experience:compileDebugKotlin'.
file or directory '/home/yperess/workspace/Metaverse/experience/src/debug/kotlin', not found
file or directory '/home/yperess/workspace/Metaverse/experience/src/debug/kotlin', not found
Using kotlin incremental compilation
e: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
class com.gometa.metaverse.sdk.utils.MediaUploader, unresolved supertypes: com.amazonaws.mobileconnectors.s3.transferutility.TransferListener
e: /home/yperess/workspace/Metaverse/experience/src/main/java/com/gometa/metaverse/experience/camera/CameraSceneViewModel.kt: (15, 39): Unresolved reference: toFile
e: /home/yperess/workspace/Metaverse/experience/src/main/java/com/gometa/metaverse/experience/camera/CameraSceneViewModel.kt: (47, 77): Unresolved reference: toFile
e: /home/yperess/workspace/Metaverse/experience/src/main/java/com/gometa/metaverse/experience/character/CharacterSceneViewModel.kt: (15, 39): Unresolved reference: toFile
e: /home/yperess/workspace/Metaverse/experience/src/main/java/com/gometa/metaverse/experience/character/CharacterSceneViewModel.kt: (41, 58): Unresolved reference: toFile
e: /home/yperess/workspace/Metaverse/experience/src/main/kotlin/com/gometa/metaverse/experience/RotationMatrix.kt: (15, 39): Unresolved reference: toString
e: /home/yperess/workspace/Metaverse/experience/src/main/kotlin/com/gometa/metaverse/experience/RotationMatrix.kt: (161, 107): Too many arguments for public open fun toString(): String defined in kotlin.Float
e: /home/yperess/workspace/Metaverse/experience/src/main/kotlin/com/gometa/metaverse/experience/login/LightLoginActivity.kt: (24, 40): Unresolved reference: hasPermission
e: /home/yperess/workspace/Metaverse/experience/src/main/kotlin/com/gometa/metaverse/experience/login/LightLoginActivity.kt: (437, 36): Unresolved reference: hasPermission
e: /home/yperess/workspace/Metaverse/experience/src/main/kotlin/com/gometa/metaverse/experience/login/LightLoginActivity.kt: (438, 38): Unresolved reference: hasPermission
e: /home/yperess/workspace/Metaverse/experience/src/main/kotlin/com/gometa/metaverse/experience/login/component/LoginChoice.kt: (10, 34): Unresolved reference: ankoComponent
e: /home/yperess/workspace/Metaverse/experience/src/main/kotlin/com/gometa/metaverse/experience/login/component/LoginChoice.kt: (30, 9): Unresolved reference: ankoComponent
e: /home/yperess/workspace/Metaverse/experience/src/main/kotlin/com/gometa/metaverse/experience/login/component/LoginChoice.kt: (30, 38): Unresolved reference: it
e: /home/yperess/workspace/Metaverse/experience/src/main/kotlin/com/gometa/metaverse/experience/login/util/Layouts.kt: (9, 32): Unresolved reference: textInputEditText
e: /home/yperess/workspace/Metaverse/experience/src/main/kotlin/com/gometa/metaverse/experience/login/util/Layouts.kt: (18, 5): Unresolved reference: textInputEditText
e: /home/yperess/workspace/Metaverse/experience/src/main/kotlin/com/gometa/metaverse/experience/login/util/Layouts.kt: (19, 9): Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public var TextView.hintResource: Int defined in org.jetbrains.anko
e: /home/yperess/workspace/Metaverse/experience/src/main/kotlin/com/gometa/metaverse/experience/login/util/Layouts.kt: (20, 9): Unresolved reference: inputType
e: /home/yperess/workspace/Metaverse/experience/src/main/kotlin/com/gometa/metaverse/experience/login/util/Layouts.kt: (21, 9): Unresolved reference: maxLines
e: /home/yperess/workspace/Metaverse/experience/src/main/kotlin/com/gometa/metaverse/experience/login/util/Layouts.kt: (22, 9): Unresolved reference: filters
e: /home/yperess/workspace/Metaverse/experience/src/main/kotlin/com/gometa/metaverse/experience/login/util/Layouts.kt: (23, 9): Unresolved reference: addTextChangedListener
e: /home/yperess/workspace/Metaverse/experience/src/main/kotlin/com/gometa/metaverse/experience/login/util/Layouts.kt: (34, 13): Unresolved reference: textInputEditText
e: /home/yperess/workspace/Metaverse/experience/src/main/kotlin/com/gometa/metaverse/experience/login/util/Layouts.kt: (35, 17): Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public var TextView.hintResource: Int defined in org.jetbrains.anko
e: /home/yperess/workspace/Metaverse/experience/src/main/kotlin/com/gometa/metaverse/experience/login/util/Layouts.kt: (36, 17): Unresolved reference: inputType
e: /home/yperess/workspace/Metaverse/experience/src/main/kotlin/com/gometa/metaverse/experience/login/util/Layouts.kt: (37, 17): Unresolved reference: maxLines
e: /home/yperess/workspace/Metaverse/experience/src/main/kotlin/com/gometa/metaverse/experience/login/util/Layouts.kt: (38, 17): Unresolved reference: addTextChangedListener
e: /home/yperess/workspace/Metaverse/experience/src/main/kotlin/com/gometa/metaverse/experience/view/CameraControlView.kt: (32, 39): Unresolved reference: clamp
e: /home/yperess/workspace/Metaverse/experience/src/main/kotlin/com/gometa/metaverse/experience/view/CameraControlView.kt: (305, 26): Unresolved reference: clamp
[KOTLIN] deleting /home/yperess/workspace/Metaverse/experience/build/tmp/kotlin-classes/debug on error
[KOTLIN] deleting /home/yperess/workspace/Metaverse/experience/build/tmp/kotlin-classes/debug on error
:experience:compileDebugKotlin FAILED
:experience:compileDebugKotlin (Thread[Task worker for ':' Thread 3,5,main]) completed. Took 8.489 secs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':experience:compileDebugKotlin'.
> Compilation error. See log for more details
* Try:
Run with --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':experience:compileDebugKotlin'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.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:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.api.GradleException: Compilation error. See log for more details
at org.jetbrains.kotlin.gradle.tasks.TasksUtilsKt.throwGradleExceptionIfError(tasksUtils.kt:8)
at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.processCompilerExitCode(Tasks.kt:326)
at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:300)
at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:203)
at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute(Tasks.kt:182)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 27 more
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 55s
88 actionable tasks: 88 executed
UPDATE
刪除testCoverageEnabled = true
修復了缺少全局函數的問題。現在我只剩下亞馬遜S3的錯誤了,我認爲這屬於另一個問題。
嘗試'API項目(「:SDK」)'' – Bob
api'沒有工作,要麼:( – TheHebrewHammer
我想不通爲什麼'TransferListener'沒有解決,它只是一個接口和編輯ISN」我可以通過代碼檢查或類搜索跳轉到它 – TheHebrewHammer