gpt4 book ai didi

android - 无法获取未知属性 'android'

转载 作者:太空宇宙 更新时间:2023-11-03 12:47:11 25 4
gpt4 key购买 nike

我一直在阅读本教程以了解如何为 Unity 创建 Android 服务: http://eppz.eu/blog/unity-android-plugin-tutorial-2/

那里显示了一个 Gradle 构建脚本 fragment ,所以我复制了它并稍作修改,以便它可以正确部署到我的 Unity 项目。

但是当我运行/同步 Gradle 脚本时,它似乎在提示其中的“android”变量/关键字(或其他任何内容)。我不认为这是由我的修改引起的,因为 android.libraryVariants.all { ... } 部分在教程开头:

(编辑:我将整个 build.gradle 文件放在这里,以防我遗漏任何明显的东西)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

android.libraryVariants.all { variant ->
// Task names.
String pluginName = "DemoPlugin";
String variantName = "${variant.name.capitalize()}"; // Like 'Debug'
String deployTaskGroup = "plugin";
String deployTaskName = "deploy${variantName}PluginArchive"; // Like 'deployDebugPluginArchive'
String dependencyTaskName = "assemble${variantName}"; // Like 'assembleDebug'
// Source.
String sourceAARFolder = "${buildDir.getPath()}/release-jars/";
String sourceAARName = "${project.name}-${variant.name}.jar";

// Pierre: Unity project directory
String targetProjDir = System.env.UNITY_PROJECT;

// Target.
String targetAssetFolder = "Assets/Plugins/${pluginName}";
String targetAARFolder = "${targetProjDir}/${targetAssetFolder}"; // Navigate into 'Assets'
String targetAARName = "${pluginName}.jar"; // The form you ship your plugin
// Create task.
task(deployTaskName, dependsOn: dependencyTaskName, type: Copy) {
from(sourceAARFolder)
into(targetAARFolder)
include(sourceAARName)
rename(sourceAARName, targetAARName)
}.group = deployTaskGroup;
}

知道是什么导致了这个错误吗?

Error:(25, 1) A problem occurred evaluating root project 'DemoService'. Could not get unknown property 'android' for root project 'DemoService' of type org.gradle.api.Project.

最佳答案

将代码粘贴到模块的构建文件中,而不是顶层文件中。

关于android - 无法获取未知属性 'android',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40876354/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com