将 gradle 设置为 Android O (API 26)
Setting gradle to Android O (API 26)
Android Studio 已将以下组件自动更新至 API 26:
- ROM - SDK 到 API26
- Android SDK 构建工具 26
- Android 模拟器 26.0.3
- Android SDK 平台-工具 26.0.0
- Android SDK 工具 26.0.2
我的 gradle 2.3.3:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.0'
defaultConfig {
applicationId "com.mycompany.myapplication"
minSdkVersion 15
targetSdkVersion 26
versionCode 4
versionName "0.0.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
/////////If I change it to 26.0.0 it gives errors.///////////
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-vector-drawable:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
/////////////////////////////////////////////////////////////
testCompile 'junit:junit:4.12'
}
我有两个问题(请参阅 Gradle 中的注释行):
我怎样才能知道这些库的最新版本(我只是简单地抛出随机数并尝试向上直到找到最新版本)。
在被排除的组中有'com.android.support',如果我删除它,我需要指定那些库吗?我看到很多人以这种方式包括 'com.android.support' 库,所以我想这样做是有原因的。
我在developer.android.com中搜索,最新版本是24.2.0(太老了,我一直在使用25.3.1)。
勾选 https://developer.android.com/topic/libraries/support-library/revisions.html 并在页脚处将语言设置为英语,以查看最新版本的支持库。目前是 25.4.0(稳定版)或 26.0.0(测试版 2)
如果您真的想使用 26 版本,可以在依赖项末尾使用 + 字符。
compile 'com.android.support:appcompat-v7:26+'
这样,grade会取26开头的最新版本。?。?你的依赖。但是您会收到来自 Android Studio 的警告,因为在两个不同的版本之间,行为最终可能会发生变化,然后产生随机效果。
要了解最新版本,请看这里:https://developer.android.com/topic/libraries/support-library/revisions.html
最后,如果您包含 'com.android.support',您将包含整个库。而且您当然不需要包含所有内容。如果您只使用回收站视图,只需添加:
compile 'com.android.support:recyclerview-v7:26.0.0-beta2'
试试这个:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
感谢您报告您的 issue.upcoming 6.0.0 版本包括对 Java 8 项功能的支持,因此为了 运行 您需要升级它(或任何测试版)通过将此添加到应用程序的 gradle 文件中,您的项目将包含 Java 8 支持:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Android Studio 已将以下组件自动更新至 API 26:
- ROM - SDK 到 API26
- Android SDK 构建工具 26
- Android 模拟器 26.0.3
- Android SDK 平台-工具 26.0.0
- Android SDK 工具 26.0.2
我的 gradle 2.3.3:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.0'
defaultConfig {
applicationId "com.mycompany.myapplication"
minSdkVersion 15
targetSdkVersion 26
versionCode 4
versionName "0.0.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
/////////If I change it to 26.0.0 it gives errors.///////////
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-vector-drawable:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
/////////////////////////////////////////////////////////////
testCompile 'junit:junit:4.12'
}
我有两个问题(请参阅 Gradle 中的注释行):
我怎样才能知道这些库的最新版本(我只是简单地抛出随机数并尝试向上直到找到最新版本)。
在被排除的组中有'com.android.support',如果我删除它,我需要指定那些库吗?我看到很多人以这种方式包括 'com.android.support' 库,所以我想这样做是有原因的。
我在developer.android.com中搜索,最新版本是24.2.0(太老了,我一直在使用25.3.1)。
勾选 https://developer.android.com/topic/libraries/support-library/revisions.html 并在页脚处将语言设置为英语,以查看最新版本的支持库。目前是 25.4.0(稳定版)或 26.0.0(测试版 2)
如果您真的想使用 26 版本,可以在依赖项末尾使用 + 字符。
compile 'com.android.support:appcompat-v7:26+'
这样,grade会取26开头的最新版本。?。?你的依赖。但是您会收到来自 Android Studio 的警告,因为在两个不同的版本之间,行为最终可能会发生变化,然后产生随机效果。
要了解最新版本,请看这里:https://developer.android.com/topic/libraries/support-library/revisions.html
最后,如果您包含 'com.android.support',您将包含整个库。而且您当然不需要包含所有内容。如果您只使用回收站视图,只需添加:
compile 'com.android.support:recyclerview-v7:26.0.0-beta2'
试试这个:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
感谢您报告您的 issue.upcoming 6.0.0 版本包括对 Java 8 项功能的支持,因此为了 运行 您需要升级它(或任何测试版)通过将此添加到应用程序的 gradle 文件中,您的项目将包含 Java 8 支持:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}