gpt4 book ai didi

java - Android Studio 中缺少注解处理

转载 作者:行者123 更新时间:2023-11-30 10:35:34 25 4
gpt4 key购买 nike

我正在使用 Android Studio 2.2.3 和构建工具 24.0.2。

包括 Butterknife 在内的几个库在我尝试编译的应用程序的 build.gradle 中使用注释。一开始我收到这个错误:

Gradle 同步失败:找不到参数的方法 annotationProcessor() [com.jakewharton:butterknife-compiler:8.4.0]

在 AS 启动窗口中,我编辑了首选项并勾选了注释处理。我清除了缓存并重新启动了 Android。仍然收到该错误。

应用级build.gradle:

buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.github.triplet.gradle:play-publisher:1.1.4'
//noinspection GradleDynamicVersion
classpath 'io.fabric.tools:gradle:1.+'
}
}

allprojects {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
}

task wrapper(type: Wrapper) {
gradleVersion = '3.1'
distributionUrl = distributionUrl.replace("bin", "all")
}

模组级build.gradle:

apply plugin: 'com.android.application'
apply from: '../config/quality/quality.gradle'
apply plugin: 'com.github.triplet.play'
//TODO uncomment line below after adding fabric api secret and key to fabric.properties
//apply plugin: 'io.fabric'

android {
compileSdkVersion 24
buildToolsVersion '24.0.2'
defaultConfig {
applicationId 'com.murphysw.rosie'
minSdkVersion 16
targetSdkVersion 24
testInstrumentationRunner "${applicationId}.runner.RxAndroidJUnitRunner"
versionCode 1000
// Major -> Millions, Minor -> Thousands, Bugfix -> Hundreds. E.g 1.3.72 == 1,003,072
versionName '0.1.0'
}
signingConfigs {
// You must set up an environment var before release signing
// Run: export APP_KEY={password}
// TODO Add your release keystore in /keystore folder
release {
storeFile file('keystore/release.keystore')
keyAlias 'alias'
storePassword "$System.env.APP_KEY"
keyPassword "$System.env.APP_KEY"
}

debug {
storeFile file('keystore/debug.keystore')
keyAlias 'androiddebugkey'
storePassword 'android'
keyPassword 'android'
}
}
buildTypes {
release {
signingConfig signingConfigs.release

minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

ext.betaDistributionReleaseNotesFilePath =
file('../crashlytics_release_notes.txt').absolutePath
}

debug {
versionNameSuffix " Debug"
debuggable true
}
}
sourceSets {
def commonTestDir = 'src/commonTest/java'
test {
java.srcDir commonTestDir
}
androidTest {
java.srcDir commonTestDir
}
}
//Needed because of this https://github.com/square/okio/issues/58
lintOptions {
warning 'InvalidPackage'
}
productFlavors {
}
}

play {
serviceAccountEmail = 'your-service-account-email'
pk12File = file('key.p12')
// By default publishes to Alpha channel
track = 'alpha'
}

dependencies {
final PLAY_SERVICES_VERSION = '9.6.1'
// final SUPPORT_LIBRARY_VERSION = '25.0.1'
final SUPPORT_LIBRARY_VERSION = '24.0.2'
final RETROFIT_VERSION = '2.1.0'
final DAGGER_VERSION = '2.5'
final DEXMAKER_VERSION = '1.4'
final HAMCREST_VERSION = '1.3'
final ESPRESSO_VERSION = '2.2.1'
final RUNNER_VERSION = '0.4'
final BUTTERKNIFE_VERSION = '8.4.0'
final AUTO_VALUE_VERSION = '1.3'
final AUTO_VALUE_GSON_VERSION = '0.4.2'
def daggerCompiler = "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
def jUnit = "junit:junit:4.12"
def mockito = "org.mockito:mockito-core:1.10.19"
// App Dependencies
compile "com.google.android.gms:play-services-gcm:$PLAY_SERVICES_VERSION"
compile "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:cardview-v7:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:support-annotations:$SUPPORT_LIBRARY_VERSION"
compile('com.squareup.sqlbrite:sqlbrite:0.8.0')
{
exclude group: 'com.android.support', module: 'support-annotations'
}
compile "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION"
compile "com.squareup.retrofit2:converter-gson:$RETROFIT_VERSION"
compile "com.squareup.retrofit2:adapter-rxjava:$RETROFIT_VERSION"
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.1.6'
compile('com.crashlytics.sdk.android:crashlytics:2.5.7@aar') {
transitive = true;
}
compile 'com.jakewharton.timber:timber:4.1.2'
compile "com.jakewharton:butterknife:$BUTTERKNIFE_VERSION" annotationProcessor "com.jakewharton:butterknife-compiler:$BUTTERKNIFE_VERSION"
// Replace provided dependency below with official AutoValue once this issue is fixed

// https://github.com/google/auto/issues/268
provided "com.jakewharton.auto.value:auto-value-annotations:$AUTO_VALUE_VERSION" provided "com.ryanharter.auto.value:auto-value-gson:$AUTO_VALUE_GSON_VERSION" annotationProcessor "com.google.auto.value:auto-value:$AUTO_VALUE_VERSION" annotationProcessor 'com.ryanharter.auto.value:auto-value-parcel:0.2.4-rc2'
annotationProcessor "com.ryanharter.auto.value:auto-value-gson:$AUTO_VALUE_GSON_VERSION" annotationProcessor 'com.squareup:javapoet:1.7.0'
// https://github.com/rharter/auto-value-parcel/issues/64
compile "com.google.dagger:dagger:$DAGGER_VERSION" provided 'org.glassfish:javax.annotation:10.0-b28'
//Required by Dagger2
annotationProcessor daggerCompiler testAnnotationProcessor daggerCompiler androidTestAnnotationProcessor daggerCompiler
// Instrumentation test dependencies
androidTestCompile jUnit
androidTestCompile mockito
androidTestCompile "com.android.support:support-annotations:$SUPPORT_LIBRARY_VERSION"
androidTestCompile("com.android.support.test.espresso:espresso-contrib:$ESPRESSO_VERSION")
{
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'recyclerview-v7'
}
androidTestCompile "com.android.support.test.espresso:espresso-core:$ESPRESSO_VERSION"
androidTestCompile "com.android.support.test:runner:$RUNNER_VERSION"
androidTestCompile "com.android.support.test:rules:$RUNNER_VERSION"
androidTestCompile "com.crittercism.dexmaker:dexmaker:$DEXMAKER_VERSION"
androidTestCompile "com.crittercism.dexmaker:dexmaker-dx:$DEXMAKER_VERSION"
androidTestCompile "com.crittercism.dexmaker:dexmaker-mockito:$DEXMAKER_VERSION"
// Unit tests dependencies
testCompile jUnit testCompile mockito testCompile "org.hamcrest:hamcrest-core:$HAMCREST_VERSION" testCompile "org.hamcrest:hamcrest-library:$HAMCREST_VERSION" testCompile "org.hamcrest:hamcrest-integration:$HAMCREST_VERSION" testCompile 'org.robolectric:robolectric:3.1'
}

// Log out test results to console
tasks.matching {it instanceof Test}.all {
testLogging.events = ["failed", "passed", "skipped"]
}

最佳答案

butterknife 页面要求包含这一行:

annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'

您是否将其包含在您的应用级 gradle 中?

关于java - Android Studio 中缺少注解处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41082707/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com