2015-10-15 16 views
4

我已经尝试过两次让android-apt工作,因为它是我想要使用的第三方库(AndroidAnnotations和PermissionsDispatcher)所必需的,而且这两次我都抨击我直到我厌倦了听到squ sound声。无法使用android-apt工作

问题? Android Studio中根本无法找到或获取相关性:

Error:Could not find com.neenbedankt.gradle:plugins:android-apt. 
Searched in the following locations: 
    file:/Applications/Android Studio.app/Contents/gradle/m2repository/com/neenbedankt/gradle/plugins/android-apt/plugins-android-apt.pom 
    file:/Applications/Android Studio.app/Contents/gradle/m2repository/com/neenbedankt/gradle/plugins/android-apt/plugins-android-apt-1.8.jar 
    https://jcenter.bintray.com/com/neenbedankt/gradle/plugins/android-apt/plugins-android-apt.pom 
    https://jcenter.bintray.com/com/neenbedankt/gradle/plugins/android-apt/plugins-android-apt-1.8.jar 
    https://repo1.maven.org/maven2/com/neenbedankt/gradle/plugins/android-apt/plugins-android-apt.pom 
    https://repo1.maven.org/maven2/com/neenbedankt/gradle/plugins/android-apt/plugins-android-apt-1.8.jar 
Required by: 
    :MaterialQuoter:unspecified 

我可能做出某种可笑的错误的(?我的意思是,这些库将不会看到任何其它方式使用,正确的),但我可以” t看看我做错了什么。

我正在运行Android Studio 1.4,以防万一它有某种相关性。

这是项目的gradle这个文件:

buildscript { 
    repositories { 
     jcenter() 
     mavenCentral() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:1.3.0' 
     classpath 'com.neenbedankt.gradle:plugins:android-apt:1.8' 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
     mavenCentral() 
     mavenLocal() 
    } 
} 

apply plugin: 'com.android.application' 
apply plugin: 'com.neenbedankt.android-apt' 

dependencies { 
    compile 'com.github.hotchemi:permissionsdispatcher:1.2.1' 
    apt 'com.github.hotchemi:permissionsdispatcher-processor:1.2.1' 
} 

这是我主要工作的模块文件的gradle:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.1" 

    defaultConfig { 
     applicationId "com.callisto.materialquoter" 
     multiDexEnabled true 
     minSdkVersion 21 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
    packagingOptions { 
     exclude 'META-INF/license.txt' 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/notice.txt' 
     exclude 'META-INF/NOTICE' 
     exclude 'META-INF/ASL2.0' 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1' 
    compile 'com.android.support:appcompat-v7:23.0.1' 
    compile 'com.android.support:recyclerview-v7:23.0.1' 
    compile 'com.android.support:cardview-v7:23.0.1' 
    compile 'com.android.support:design:23.0.1' 
    compile 'com.google.code.findbugs:jsr305:1.3.9' 
    compile 'com.google.android.gms:play-services:8.1.0' 
    compile 'com.github.hotchemi:permissionsdispatcher:1.2.1' 
    compile 'org.roboguice:roboguice:3.+' 
    provided 'org.roboguice:roboblender:3.+' 
    compile 'org.codepond:wizardroid:1.3.0' 
    compile ('com.octo.android.robospice:robospice:1.4.14') { 
     exclude group: 'org.apache.commons', module: 'commons-io' 
    } 
    compile ('com.octo.android.robospice:robospice-cache:1.4.14') { 
     exclude group: 'org.apache.commons', module: 'commons-io' 
    } 
    compile ('com.octo.android.robospice:robospice-spring-android:1.4.14') { 
     exclude group: 'org.apache.commons', module: 'commons-io' 
    } 
    compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13' 
    compile 'de.greenrobot:greendao:2.0.0' 
} 
+1

请添加一些显示错误 –

+0

看起来一见钟情。你有没有复制依赖,'apt'和'apply'行?尝试手动输入这些内容,因为它发生了复制粘贴引入了不可见的空间,从而破坏了配置。 – botteaap

+0

我只是尝试评论一切,然后再次手动输入。没有什么改变......我先添加了'classpath'行,尝试同步,再次得到错误,然后添加剩下的部分,并再次尝试同步 - 最后出现另一个错误。 有没有办法手动将这些依赖项导入到'm2repository'中?说,我手动下载所有东西并将其粘贴到Gradle的某个地方找到它? –

回答

5

我有同样的问题。这帮助我弄清楚了。

在应用程序模块本身,添加这些行(顺序很重要):

buildscript { 
    repositories { 
     mavenCentral() 
    } 

    dependencies { 
     classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' 
    } 
} 

apply plugin: 'com.android.application' 
apply plugin: 'android-apt' 


dependencies { 
    compile 'com.github.hotchemi:permissionsdispatcher:[email protected]' 
    apt 'com.github.hotchemi:permissionsdispatcher-processor:1.2.1' 
} 
+0

事实证明,我将这些行放在整个项目的Gradle文件上。在这个和android-apt-example项目之间寻找帮助可以解决问题。非常感谢......你刚刚找到了一个让我折磨了好几个月头痛的问题。现在我可以测试AndroidAnnotations是否比RoboGuice更好。 :P –

+0

在'repositories'中,我有'maven {url'https://maven.fabric.io/public'}''。当我在该行后面添加'mavenCentral()'时,它工作正常。 –

2

由于Android的摇篮插件2.2版本,以前由Android的易提供的所有功能现在可在Android插件中。这意味着Android的易正式过时;)

因此,

  1. 确保您更新摇篮插件为> = 2.2
  2. 代替apt使用annotationProcessor

Ref:https://bitbucket.org/hvisser/android-apt/wiki/Migration

+0

我不认为这真的回答了这个问题。 OP使用的第三方库需要android-apt,因此删除它可能不是一个选项。 –

0

我想通过这种方式在Android St音频2.2.1:

这让我可以在主项目上同时在库上使用Butterknife。

请注意,在图书馆使用Butterknife注释时,请使用R2 .id.blah而不是R.id.blah。

希望适用于所有人。

同时检查this link

1)项目文件的gradle:

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.2.1' 
     classpath 'com.jakewharton:butterknife-gradle-plugin:8.4.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 
} 

2)的应用程序文件graddle

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.0" 

    defaultConfig { 
     minSdkVersion 21 
     targetSdkVersion 25 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 

    ... 


} 

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' 
    }) 
    testCompile 'junit:junit:4.12' 

    ... 

    //Butterknife https://github.com/JakeWharton/butterknife#library-projects 
    compile 'com.jakewharton:butterknife:8.4.0' 
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0' 

    ... 
} 

3)库graddle文件

apply plugin: 'com.android.library' 
apply plugin: 'com.jakewharton.butterknife' 

android { 
    compileSdkVersion 24 
    buildToolsVersion "25.0.0" 

    defaultConfig { 
     minSdkVersion 21 
     targetSdkVersion 24 
     versionCode 1 
     versionName "1.0" 

     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' 
    }) 

    //Butterknife 
    compile 'com.jakewharton:butterknife-annotations:8.4.0' 
    compile 'com.jakewharton:butterknife:8.4.0' 
    ... 
}