2***@qq.com
2***@qq.com
  • 发布:2023-11-17 17:31
  • 更新:2023-11-19 08:58
  • 阅读:1025

打包uts自定义基座报错

分类:uts

报错:
Appid: UNIA4BB50E
e: file://[PackagePath]/wgtRoot/UNIA4BB50E/uni_modules/ns-miniServer/utssdk/app-android/src/index.kt:32:95 Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public operator fun Number.plus(other: Number): Number defined in io.dcloud.uts
public operator fun Number.plus(other: String): String defined in io.dcloud.uts
e: file://[PackagePath]/wgtRoot/UNIA4BB50E/uni_modules/ns-miniServer/utssdk/app-android/src/index.kt:34:90 Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public operator fun Number.plus(other: Number): Number defined in io.dcloud.uts
public operator fun Number.plus(other: String): String defined in io.dcloud.uts

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':uni_modules:ns-miniServer:compileReleaseKotlin'.

    A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
    Compilation 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 1m 26s
Error code = -5000
Error message:
UTS plugin @ uni_modules ns-miniServer compile error!

import { UTSAndroid } from "io.dcloud.uts";  
import JsCallback from "com.example.miniserver.JsCallback"  
import MiniServer from "com.example.miniserver.MiniServer"  
import File from "java.io.File"  
type opt = {  
        msg : string,  
        port : number,  
        onSaved : (result : string,time:string) => void;  
    }  

export class Server {  
    private server : MiniServer;  
    constructor(options :opt ) {  
        class OtherCallback implements JsCallback {  
            public override  onEnd(result : string, time: string):void {  
                options.onSaved(result,time)  
            }  
        }  
        this.server = new MiniServer();  
        this.server.get("/", UTSAndroid.getResourcePath("uni_modules/ns-miniServer/static/index.html"))  
        this.server.post("/postBook", options.msg, UTSAndroid?.getAppContext()?.getCacheDir()+File.separator, new OtherCallback())  
        this.server.listen(4567)  
        console.log("/postBook", options.msg, UTSAndroid?.getAppContext()?.getCacheDir()+File.separator, new OtherCallback());  
    }  

    stop():void{  
        this.server.stop()  
    }  

}  

代码:
2023-11-17 17:31 负责人:无 分享
已邀请:
2***@qq.com

2***@qq.com (作者)

完全不知道哪里是错的

2***@qq.com

2***@qq.com (作者)

破案,UTSAndroid?.getAppContext()?.getCacheDir()+File.separator这一句导致的问题

  • 2***@qq.com (作者)

    getCacheDir返回的是File对象,没有加运算

    2023-11-22 23:28

该问题目前已经被锁定, 无法添加新回复