[英]Android studio with experimental gradle 0.2.0
我正在嘗試用最新版本的android studio設置一個基本的ndk版本。 試着按照本教程
這是我的gradle-wrapper.properties
#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
}
這是我的模塊的build.gradle
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/
我收到這些錯誤:
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
第10行是:minSdkVersion = 10您可以在我上面的build.gradle
中看到整個文件。
編輯
正如@unbekant在他的評論和這篇文章的鏈接中指出的那樣
min和target sdk值應該設置如下:
minSdkVersion.apiLevel = 15
targetSdkVersion.apiLevel = 22
我也試過了,我收到了這個錯誤:
* 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中),那將非常有用。 我從maven獲得了大部分內容,例如http://mvnrepository.com/artifact/com.android.tools.lint/lint-checks/24.3.1
我得到了所有文件來關閉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這個回購中有一些例子:
https://github.com/googlesamples/android-ndk
可能會嘗試:
jni文件夾問題:
它是gradle實驗插件的默認設置,也適用於較舊的c ++支持,不使用gradle-experimental插件(android插件)
如果您有該文件夾而不使用實驗性插件,Gradle認為該應用程序正在使用較舊的android studio c ++支持。 它給出了警告“NDK集成在當前插件中已棄用”,並建議您使用實驗性插件。 它可能會沉默:
或者只是將jni文件夾重命名為其他內容:如果你想在未來使用android-studio cmake / ndk-build,會導致更多麻煩,重命名更好。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.