Raf*_*dez 10 android android-studio butterknife
我需要安装插件Butter Knife.我在哪里可以下载?我下载一个.jar插件(但如果该文件是一个我需要的),我已经安装了,但是当我点击选择"生成"不使用出现butterknife的选项.在视频教程之后我修改了文件Gradle build:我现在有以下内容:
apply plugin: 'android-apt'
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "calcursoedxleccion0.cal"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile "com.android.support:appcompat-v7:$rootProject.ext.supportLibraryVersion"
compile "com.android.support:recyclerview-v7:$rootProject.ext.supportLibraryVersion"
compile "com.android.support:support-v4:$rootProject.ext.supportLibraryVersion"
compile "com.android.support:design:$rootProject.ext.supportLibraryVersion"
// compile "com.jakewharton:butterknife:$rootProject.ext.butterKnifeVersion"
compile "com.jakewharton:butterknife:$rootProject.ext.butterKnifeVersion"
apt "com.jakewharton:butterknife-compiler:8.0.1"
}
Run Code Online (Sandbox Code Playgroud)
和
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// 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
}
ext{
minSdkVersion = 16
targetSdkVersion = 23
compileSdkVersion = 23
buildToolsVersion = '23.0.3'
supportLibraryVersion = '23.3.0'
butterKnifeVersion = '8.0.1'
}
Run Code Online (Sandbox Code Playgroud)
Gradle to synchronize我收到此错误:
"android android-library或插件必须应用于项目"错误(1.0)
我究竟做错了什么?
Een*_*ble 45
使用ButterKnife库的最简单方法是将此单行添加到模块级build.gradle依赖项列表中:
dependencies {
implementation 'com.jakewharton:butterknife:7.0.1'
}
Run Code Online (Sandbox Code Playgroud)
然后,您可以同步您的项目!
更新1
我刚刚注意到自从上次我使用它以来,沃顿已经更新了库!现在,您似乎必须添加到两个单独的位置:
在您的项目级 build.gradle文件中:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
Run Code Online (Sandbox Code Playgroud)
最后,在您的模块级 build.gradle文件中:
apply plugin: 'android-apt'
android {
...
}
dependencies {
implementation 'com.jakewharton:butterknife:8.0.1'
apt 'com.jakewharton:butterknife-compiler:8.0.1'
}
Run Code Online (Sandbox Code Playgroud)
添加apply plugin: 'android-apt'到module-level build.gradle文件顶部非常重要; 最有可能低于第一行,如下所示:
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
Run Code Online (Sandbox Code Playgroud)
我刚刚测试了这个并且适合我.祝好运!
更新2
Jake Wharton刚刚发布了对库的更新,以下是您需要做的事情:
因此,在您的内部build.gradle (app-level),将以下内容添加到您的依赖项中!
dependencies {
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
}
Run Code Online (Sandbox Code Playgroud)
更新3:
以下是迄今为止发布的版本,以防您与其他库发生冲突并希望它能够在较旧的API级别上运行
通过尝试,如果你想要它至少达到SDK级别15到现在你将需要使用版本来使它在我的情况下工作这些集合是目前为止最小的SDK 15兼容.
这个案例我只把它们放在模块应用程序级别build.gradle.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:24.2.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
implementation group: 'com.squareup.retrofit2', name: 'converter-gson', version: '2.3.0'
implementation 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
implementation 'io.reactivex:rxjava:1.1.6'
implementation 'io.reactivex:rxandroid:1.2.1'
implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
implementation 'com.android.support:recyclerview-v7:24.2.1'
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21226 次 |
| 最近记录: |