本文介绍了构建毕业生:找不到方法packageOptions()作为参数根项目“fasterDev”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在应用程序中使用单个build.gradle文件。关于1.6版,它正常工作。
,但我想使用这个位置更新与模块。
应用插件:'com.android.application'
...
依赖关系{
编译'com.google.android.gms:play-services:fp9.0.0'
}
这是我的build.gradle。
build.gradle
buildscript {
repositories {
mavenCentral()
}
依赖关系{
classpath'com.android.tools.build:gradle:2.1.0'
}
}
应用插件:'android'
依赖关系{
compile fileTree(dir:'libs',include:'* .jar')
}
android {
compileSdkVersion 15
buildToolsVersion21.1.2
sourceSets {
main {
manifest.srcFile'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = [ 'src']
aidl.srcDirs = ['s rc']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
//将测试移动到tests / java,tests / res等...
instrumentTest.setRoot('tests')
//将构建类型移动到建立类型/<类型>
//例如,build-types / debug / java,build-types / debug / AndroidManifest.xml,...
//将它们从src /< type> ; / ...这将
//与主源集合使用的src /冲突。
//添加新的构建类型或产品风格应该通过类似的自定义来附加
//。
debug.setRoot('build-types / debug')
release.setRoot('build-types / release')
}
}
packagingOptions {
exclude'META-INF / DEPENDENCIES.txt'
exclude'META-INF / LICENSE.txt'
exclude'META-INF / NOTICE.txt'
exclude'META-INF / NOTICE'
exclude'META-INF / LICENSE'
exclude'META-INF / DEPENDENCIES'
exclude'META-INF / notice.txt'
exclude'META-INF / license.txt'
exclude'META-INF / dependencies.txt'
exclude'META-INF / LGPL2.1'
}
任何教程或建议?
日志: p>
org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
导致:org.gradle.api .internal.MissingMethodException:在根项目'fastD上找不到参数[build_b54s9k8r9uto6awxmkxnu2ipo $ _run_closure3 @ 3a2d3196]的方法packageOptions() EV。
在org.gradle.api.internal.AbstractDynamicObject.methodMissingException(AbstractDynamicObject.java:68)
解决方案
您在 android
之外提供了 packageOptions
这就是Gradle认为的原因,那就是一些根项目的方法。
只需将其移动到 android
中,作为:
android {
...
packagingOptions {
exclude'META-INF / DEPENDENCIES.txt'
exclude 'META-INF / LICENSE.txt'
exclude'META-INF / NOTICE.txt'
exclude'META-INF / NOTICE'
exclude'META-INF / LICENSE'
排除'META-INF / DEPENDENCIES'
exclude'META-INF / notice.txt'
exclude'META-INF / license.txt'
exclude'META-INF / dependencies.txt '
exclude'META-INF / LGPL2.1'
}
}
I am using single build.gradle file in application.Regarding version 1.6 it's working properly.but I want to use this for location update with module.
apply plugin: 'com.android.application'
...
dependencies {
compile 'com.google.android.gms:play-services:fp9.0.0'
}
Here is my build.gradle.
build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 15
buildToolsVersion "21.1.2"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
Any tutorial or suggestion for this?
Logs:
org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: org.gradle.api.internal.MissingMethodException: Could not find method packagingOptions() for arguments [build_b54s9k8r9uto6awxmkxnu2ipo$_run_closure3@3a2d3196] on root project 'fasterDev'.
at org.gradle.api.internal.AbstractDynamicObject.methodMissingException(AbstractDynamicObject.java:68)
解决方案
You've provided the packagingOptions
outside of the android
closure, that is the reason Gradle supposes, that it's some root project's method.
Just move it into the android
closure, as:
android {
...
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
这篇关于构建毕业生:找不到方法packageOptions()作为参数根项目“fasterDev”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!