Note : 新建项目所需插件及版本号统一管理
2016-07-28 本文已影响274人
乘风破浪的程序员
统一修改版本号:
根 build.gradle
ext{
//SDK tools
minSdkVersion = 15
targetSdkVersion = 24
compileSdkVersion = 24
buildToolsVersion = '24.0.1'
// app dependence
supportLibraryVersion = '23.4.0'
butterknife = '8.2.1'
guava = '19.0'
}
app build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.example.hante.newnetpas"
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.jakewharton:butterknife:$rootProject.ext.butterknife"
compile "com.google.guava:guava:$rootProject.ext.guava"
}
1.自动生成注解:
https://github.com/JakeWharton/butterknife
http://jakewharton.github.io/butterknife/
Alt+insert 注解 Generate Butter Knife
or Gradle:
compile 'com.jakewharton:butterknife:7.0.1'
最新版本8.01 会报空指针异常
官方说明下面有这么一段:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
apply plugin: 'com.neenbedankt.android-apt'dependencies {
compile 'com.jakewharton:butterknife:8.0.1'
apt 'com.jakewharton:butterknife-compiler:8.0.1'
}
build.gradle文件更改了一下:
运行时发生:
Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2340Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72340Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2311Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72311Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42340Library UP-TO-DATE
:app:prepareComAndroidSupportSupportVectorDrawable2340Library UP-TO-DATE
:app:prepareComJakewhartonButterknife821Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:app:compileDebugJavaWithJavac
F:\AndroidStudioProjects\android-architecture\NewNetPas\app\build\generated\source\apt\debug\com\example\hante\newnetpas\home\HomePageActivity$$ViewBinder.java
Error:(18, 27) 错误: 无法将枚举 Finder中的方法 castView应用到给定类型;
需要: View,int,String,Class<T>
找到: View,int,String
原因: 无法推断类型变量 T
(实际参数列表和形式参数列表长度不同)
其中, T是类型变量:
T扩展已在方法 <T>castView(View,int,String,Class<T>)中声明的Object
Error:(20, 23) 错误: 无法将枚举 Finder中的方法 castView应用到给定类型;
需要: View,int,String,Class<T>
找到: View,int,String
原因: 无法推断类型变量 T
(实际参数列表和形式参数列表长度不同)
其中, T是类型变量:
T扩展已在方法 <T>castView(View,int,String,Class<T>)中声明的Object
Error:(22, 33) 错误: 无法将枚举 Finder中的方法 castView应用到给定类型;
需要: View,int,String,Class<T>
找到: View,int,String
原因: 无法推断类型变量 T
(实际参数列表和形式参数列表长度不同)
其中, T是类型变量:
T扩展已在方法 <T>castView(View,int,String,Class<T>)中声明的Object
注: F:\AndroidStudioProjects\android-architecture\NewNetPas\app\build\generated\source\apt\debug\com\example\hante\newnetpas\home\HomePageActivity$$ViewBinder.java使用了未经检查或不安全的操作。
注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。
3 个错误
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Information:BUILD FAILED
Information:Total time: 2.529 secs
Information:4 errors
Information:0 warnings
Information:See complete output in console
暂时没找到解决办法,只能先用7.01了
2.Guava: Google Core Libraries for Java
https://github.com/google/guava
dependencies {
compile 'com.google.guava:guava:19.0'
}