gpt4 book ai didi

android - Gradle 多项目构建因 UnsupportedNotationException 而失败

转载 作者:搜寻专家 更新时间:2023-11-01 08:54:07 27 4
gpt4 key购买 nike

我正在尝试将 Eclipse/ANT 项目转换为 Android Studio 和 Gradle。我已经从 Eclipse 导出了 gradle 构建脚本,将一些第三方库翻译成 Maven 中央存储库引用,并将项目导入到 Android Studio。

我正在尝试设置多项目构建。我目前的结构是:

Root     
-- AndroidLibraryProject
-- build.gradle
-- AndroidAppProject
-- build.gradle
-- settings.gradle

相关构建文件内容如下:

AndroidLibraryProject/build.gradle

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android-library'

repositories {
mavenCentral()
maven {
url "https://github.com/dahlgren/vpi-aar/raw/master"
}
}

dependencies {
compile 'com.android.support:appcompat-v7:18.0.+'
compile 'com.viewpagerindicator:library:2.4.2-SNAPSHOT'
compile files('libs/crashlytics.jar')
compile files('libs/gson-2.0.jar')
}

android {
compileSdkVersion "Google Inc.:Google APIs:19"
buildToolsVersion "18.1.1"

defaultConfig {
minSdkVersion 10
targetSdkVersion 17
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}

instrumentTest.setRoot('tests')
}
}

AndroidAppProject/build.gradle

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}

evaluationDependsOn(':AndroidLibraryProject')

apply plugin: 'android'

dependencies {
compile project()
}

android {
compileSdkVersion 18
buildToolsVersion "19"

defaultConfig {
minSdkVersion 10
targetSdkVersion 18
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src2']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}

AndroidAppProject/settings.gradle

include ':AndroidLibraryProject'
project(':AndroidLibraryProject').projectDir = new File(settingsDir, '../AndroidLibraryProject')

LibraryProject 可以自行清理和构建。

A problem occurred evaluating root project 'AndroidAppProject'.
> org.gradle.api.internal.notations.api.UnsupportedNotationException (no error message)

堆栈跟踪是:

* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'AndroidAppProject'.
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:54)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:132)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:38)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:25)
at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:468)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:76)
at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:31)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:142)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
at org.gradle.api.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:46)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.Main.main(Main.java:37)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:127)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:58)
Caused by: org.gradle.api.internal.notations.api.UnsupportedNotationException
at org.gradle.api.internal.notations.parsers.TypedNotationParser.parseNotation(TypedNotationParser.java:45)
at org.gradle.api.internal.notations.ProjectDependencyFactory.createFromMap(ProjectDependencyFactory.java:37)
at org.gradle.api.internal.artifacts.DefaultDependencyFactory.createProjectDependencyFromMap(DefaultDependencyFactory.java:59)
at org.gradle.api.internal.artifacts.dsl.dependencies.DependencyFactory$createProjectDependencyFromMap.call(Unknown Source)
at org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.project(DefaultDependencyHandler.groovy:75)
at build_61tpm2tlp3rmsq0660pqjvv93o$_run_closure1.doCall(/Users/seth/Documents/Development/Android/AndroidAppProject/build.gradle:15)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:58)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:130)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:91)
at org.gradle.api.internal.project.AbstractProject.dependencies(AbstractProject.java:883)
at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:246)
at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:134)
at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)
at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:79)
at build_61tpm2tlp3rmsq0660pqjvv93o.run(/Users/seth/Documents/Development/Android/AndroidAppProject/build.gradle:14)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
... 33 more

如有任何指导,我们将不胜感激。我是不是把这个项目配置都弄错了?我什至不确定它与我的构建配置有什么关系。

最佳答案

settings.gradle 文件向上移动一级到根目录。然后你应该能够像这样指定它:

include ':AndroidLibraryProject', ':AndroidAppProject'

应用构建文件中的 evaluationDependsOn 可能比您需要的更复杂。让应用程序依赖于库项目的正常方法是:

dependencies {
compile project(':AndroidLibraryProject')
}

目前 Android Studio 不支持在项目根目录 ( https://code.google.com/p/android/issues/detail?id=56367 ) 之外使用库或模块,我认为您的原始设置可能符合条件,因为它可能将包含 settings.gradle 的目录视为根。像我描述的那样设置的东西会更快乐。

关于android - Gradle 多项目构建因 UnsupportedNotationException 而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20434297/

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