Mac*_*ich 3 android gradle android-ndk android-studio gradle-experimental
我刚刚将Android Studio设置更新为1.3(截至2015年8月31日的最新版本),我需要使用最新的NDK集成.我以前的Android Studio版本是1.2.1(稳定).
在Google Migration to Gradle实验指南之后,我设法轻松调整了各种gradle脚本.
但是,Gradle Sync失败并出现以下错误:
Error:No such property: android for class: com.android.build.gradle.managed.ProductFlavor
Run Code Online (Sandbox Code Playgroud)
[更新1 - >见下文,更新错误]
当我尝试Make这个项目时,我得到了一个更详细的错误:
Error:(17, 1) A problem occurred configuring project ':app'.
> Exception thrown while executing model rule: model.android
> No such property: android for class: com.android.build.gradle.managed.ProductFlavor
Run Code Online (Sandbox Code Playgroud)
App指的是主要的应用程序代码(带有活动和其他).
使用该功能F4 > Jumping to Source,它将build.gradle从我的app项目中打开我的脚本.
这是上述脚本的内容:
apply plugin: 'com.android.model.application' // experimental
model {
android {
compileSdkVersion = 21
buildToolsVersion = '22.0.1'
defaultConfig.with {
applicationId = "company.com.myapplication"
minSdkVersion.apiLevel = 10
targetSdkVersion.apiLevel = 21
versionCode = 1
versionName = "1.0"
// NDK
android.ndk {
moduleName = "MyAwesomeJNILib"
cFlags "-std=c99"
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.pro')
}
}
android.productFlavors {
// for detailed abiFilter descriptions, refer to "Supported ABIs" @
// https://developer.android.com/ndk/guides/abis.html#sa
create("arm") {
ndk.abiFilters += "armeabi"
}
create("arm7") {
ndk.abiFilters += "armeabi-v7a"
}
create("arm8") {
ndk.abiFilters += "arm64-v8a"
}
create("x86") {
ndk.abiFilters += "x86"
}
create("x86-64") {
ndk.abiFilters += "x86_64"
}
create("mips") {
ndk.abiFilters += "mips"
}
create("mips-64") {
ndk.abiFilters += "mips64"
}
// To include all cpu architectures, leaves abiFilters empty
create("all")
}
packagingOptions {
exclude 'LICENSE.txt'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.squareup.okhttp:okhttp-android-support:2.4.0'
compile project(':bluetoothmanager')
compile 'joda-time:joda-time:2.8.1'
// Units Testing
//androidTestCompile 'junit:junit:4.12'
compile 'junit:junit:4.12' // experimental
}
Run Code Online (Sandbox Code Playgroud)
如你所见,这里没有什么特别的东西.但您可能会注意到有一些单元测试设置:
// Units Testing
//androidTestCompile 'junit:junit:4.12'
compile 'junit:junit:4.12' // experimental
Run Code Online (Sandbox Code Playgroud)
androidTestCompile迁移到GradleExperimental时无法解决,所以我修改了一个我无法再找到的解决方案(对不起)我将简单地compile代替androidTestCompile.这是错误:
Error:(71, 0) Gradle DSL method not found: 'androidTestCompile()'
Run Code Online (Sandbox Code Playgroud)
我试图比较谷歌的NDK样品(其中一个hello-jini为aforemention指南中提供,例如)可以在这里找到.
除了packagingOptions我找不到任何可能导致我的错误的差异.我试图删除,packagingOptions但根本没有做出任何改变.
[更新1]
您会注意到更详细的错误消息指出它在第17行,这是我声明我的本机构建设置.我修复了cFlags必须更改的错误,并按照新版Gradle的要求CFlags添加了=.这确实有帮助,错误不再出现,但更改为:
Error:No such property: android for class: com.android.build.gradle.managed.AndroidConfig
Run Code Online (Sandbox Code Playgroud)
Gab*_*tti 10
第一部分.
BuildType,flavors ......在android块之外,但在模块内.
apply plugin: 'com.android.model.application' // experimental
model {
android {
defaultConfig.with {
}
}
android.ndk {
}
android.buildTypes {
release {
}
}
android.productFlavors {
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4554 次 |
| 最近记录: |