不支持如何解析内部方法。此处未定义方法定义。爆炸

时间:2019-06-02 20:16:55

标签: android opencv nativescript

在将openCV模块成功导入android studio上的nativescript android应用后,不断出现启动失败错误,该错误指向应用gradle中的explodeArr

尝试迁移到androidx,仍然出现错误 尝试根据Groovy文档创建新类,仍然出现错误

task runSbg(type:JavaExec){         DependOn“ collectAllJars”         如果(!findProject(':static-binding-generator')。is(null)){             dependsOn':static-binding-generator:jar'         }

    outputs.dir("$OUTPUT_JAVA_DIR/com/tns/gen")
    inputs.dir(INPUT_JS_DIR)
    inputs.dir(extractedDependenciesDir)

    workingDir "$BUILD_TOOLS_PATH"
    main "-jar"
    args "static-binding-generator.jar"

    doFirst {
        new File("$OUTPUT_JAVA_DIR/com/tns/gen").deleteDir()
    }
}

task ensureMetadataOutDir {
    doLast {
        def outputDir = file("$METADATA_OUT_PATH")
        outputDir.mkdirs()
    }
}

        def explodeAar(File compileDependency, File outputDir) {
            logger.info("explodeAar: Extracting ${compileDependency.path} 
          -> ${outputDir.path}")

            if (compileDependency.name.endsWith(".aar")) {
                java.util.jar.JarFile jar = new 
                java.util.jar.JarFile(compileDependency)
                Enumeration enumEntries = jar.entries()
                while (enumEntries.hasMoreElements()) {
                    java.util.jar.JarEntry file = (java.util.jar.JarEntry) 
                    enumEntries.nextElement()
                    if (file.name.endsWith(".jar")) {
                        def targetFile = new File(outputDir, file.name)
                        InputStream inputStream = jar.getInputStream(file)
                        new File(targetFile.parent).mkdirs()
                        Files.copy(inputStream, targetFile.toPath(), 
                     StandardCopyOption.REPLACE_EXISTING);
                    }
                    if (file.isDirectory()) {
                        continue
                    }
                }
                jar.close()
            } else if (compileDependency.name.endsWith(".jar")) {
                copy {
                    from compileDependency.absolutePath
                    into outputDir
                }
            }
        }


def md5(String string) {
    MessageDigest digest = MessageDigest.getInstance("MD5");
    digest.update(string.bytes);
    return new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0');
}

我希望完成构建 但是,取而代之的是:启动失败: 构建文件“ ... android / app / build.gradle”:473:此处不需要方法定义。请在适当的位置定义方法,或者尝试使用块/关闭。在行:                def explodeAar(文件compileDependency,文件outputDir){                ^

0 个答案:

没有答案