Android studio带有实验gradle 0.2.0
我正在尝试用最新版本的android studio建立一个基本的ndk构建。试图跟随 这是我的渐变包装器。属性Android studio带有实验gradle 0.2.0,android,android-studio,gradle,android-gradle-plugin,build.gradle,Android,Android Studio,Gradle,Android Gradle Plugin,Build.gradle,我正在尝试用最新版本的android studio建立一个基本的ndk构建。试图跟随 这是我的渐变包装器。属性 #Thu Sep 17 14:22:34 CST 2015 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.
#Thu Sep 17 14:22:34 CST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip
这是项目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-experimental:0.2.0'
// 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
}
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.1"
defaultConfig.with {
applicationId = "me.blubee.testnative_exp"
minSdkVersion = 10
targetSdkVersion = 23
versionCode = 1
versionName = "1.0"
}
buildConfigFields.with {
create() {
type = "int"
name = "VALUE"
value = "1"
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.pro')
}
}
android.productFlavors {
create("flavor1") {
applicationId = 'com.app'
}
}
android.sources {
main {
java {
source {
srcDir 'src'
}
}
}
}
}
}
这是我的模块的构建
// 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-experimental:0.2.0'
// 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
}
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.1"
defaultConfig.with {
applicationId = "me.blubee.testnative_exp"
minSdkVersion = 10
targetSdkVersion = 23
versionCode = 1
versionName = "1.0"
}
buildConfigFields.with {
create() {
type = "int"
name = "VALUE"
value = "1"
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.pro')
}
}
android.productFlavors {
create("flavor1") {
applicationId = 'com.app'
}
}
android.sources {
main {
java {
source {
srcDir 'src'
}
}
}
}
}
}
我的项目结构如下所示:
APP
Java/
Java/android.support
Java/com.test.test_experimental
Java/com.test.test_experimental/R
Java/com.test.test_experimental
Java/com.test.test_experimentalBuildConfig
Java/com.test.test_experimental
Java/com.test.test_experimental/MainActivity
tests/
tests/com.test.test_experimental
tests/com.test.test_experimental/ApplicationTest.java
tests/com.test.test_experimental
tests/com.test.test_experimental/BuildConfig.java
resources/
test-resources
gradle/scripts/
minSdkVersion.apiLevel = 15
targetSdkVersion.apiLevel = 22
我发现以下错误:
2:51:31 PM Gradle sync started
2:51:34 PM Gradle sync failed: Unable to load class 'com.android.build.gradle.managed.ProductFlavor_Impl'.
Consult IDE log for more details (Help | Show Log)
Error:Unable to load class 'com.android.build.gradle.managed.ProductFlavor_Impl'.
Possible causes for this unexpected error include:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
<a href="syncProject">Re-download dependencies and sync project (requires network)</a></li><li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
<a href="stopGradleDaemons">Stop Gradle build processes (requires restart)</a></li><li>Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.</li></ul>In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
Brother:TestNative_exp blubee$ ./gradlew clean --stacktrack
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/bb/TestNative_exp/app/build.gradle' line: 10
* What went wrong:
A problem occurred configuring project ':app'.
> Exception thrown while executing model rule: model.android
> Cannot set readonly property: minSdkVersion for class: com.android.build.gradle.managed.ProductFlavor_Impl
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 2.619 secs
我也试过了,我得到了这个错误:
* What went wrong:
A problem occurred configuring project ':app'.
> Exception thrown while executing model rule: model.android
> No such property: buildConfigFields for class: com.android.build.gradle.managed.AndroidConfig
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
我做错了什么?你必须把这些块放在
android
块之外
android.buildTypes
android.sources
android.productFlavors
另外,buildConfigFields.with
应位于defaultConfig
或buildTypes
或productFlavors
内:
比如:
model {
android {
compileSdkVersion = 22
buildToolsVersion = "22.0.1"
defaultConfig.with {
//----
minSdkVersion.apiLevel = 10
targetSdkVersion.apiLevel = 23
buildConfigFields.with {
create() {
//....
}
}
}
}
android.buildTypes {
release {
//
}
}
android.productFlavors {
//
}
// Configures source set directory.
android.sources {
//
}
}
另外,最新版本是0.2.1
classpath 'com.android.tools.build:gradle-experimental:0.2.1'
有教程吗?哦,那个。链接在哪里 当前版本为0.2.0 还是约会 在添加以下内容后,我用谷歌搜索了每一个丢失的文件(可能有3打!):
classpath 'com.android.tools.build:gradle-experimental:0.2.1'
我也尝试了alpha版本,但是我没有找到它的一些依赖项
首先,我得到了一些依赖关系,我可能会被这些依赖关系困扰:
> Error:Could not find com.android.tools.build:gradle-experimental:0.2.1.
Searched in the following locations:
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle-experimental/0.2.1/gradle-experimental-0.2.1.pom
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle-experimental/0.2.1/gradle-experimental-0.2.1.jar
一旦每一个都被添加到给定的路径中,就会有七个新的路径出现在它的位置上。如果有人能发布如何自动更新这些(他们仍然不在最新的1.4RC1 Android Studio中),这将非常有用。我从马文那里得到了大部分东西
我有所有的文件来阻止Gradle的抱怨你知道上面说了什么吗
Error:(34, 1) A problem occurred evaluating project ':app'.
> Error: NDK integration is deprecated in the current plugin. Consider trying the new experimental plugin. For details, see http://tools.android.com/tech-docs/new-build-system/gradle-experimental. Set "android.useDeprecatedNdk=true" in gradle.properties to continue using the current NDK integration.
这正是导致我迁移到实验性的错误,并不比AS附带的1.3.0版本更好(尽管它默认为1.2.3)
我为什么要麻烦?我想调试NDK,但除了不使用实验构建之外,我看不出还有什么没有做
这场追逐只是在浪费时间。我又开始使用了
android.useDeprecatedNdk=true
毫无疑问,我可以在其他地方修复它,但这只是对追求实验依赖性的其他人的一个警告;它们是独角兽。@jonagon
本回购协议中有一些例子:可能可以尝试:
- 使用最新的插件版本。请访问:
- 检查产品口味
- sourceset.main.jni.srcDirs=[]
或者干脆将该jni文件夹重命名为其他文件夹:如果您想在将来构建android studio cmake/ndk,则会造成更多麻烦,重命名更好。谢谢!吸引我的是变化:minSdkVersion=>minSdkVersion.apiLevel和targetSdkVersion=>targetSdkVersion.apiLevel