• build.gradle


    好久没有写代码,竟然连butterknife怎么配置都配置不好了。不过,我的自信还是有的,因为我以前弄成功过,所以,我弄不出来也不怎么心急,因为我知道我一定可以弄出来的。

    今天的坑就是删除了一行代码,结果一直告诉我:

    Error:Could not find com.jakewharton:butterknife-compiler:8.0.1.
    Searched in the following locations:
        file:/D:/software/android-studio-2.1/android-studio/gradle/m2repository/com/jakewharton/butterknife-compiler/8.0.1/butterknife-compiler-8.0.1.pom
        file:/D:/software/android-studio-2.1/android-studio/gradle/m2repository/com/jakewharton/butterknife-compiler/8.0.1/butterknife-compiler-8.0.1.jar
        file:/D:/software/androidsdk20140708/android-sdk/extras/android/m2repository/com/jakewharton/butterknife-compiler/8.0.1/butterknife-compiler-8.0.1.pom
        file:/D:/software/androidsdk20140708/android-sdk/extras/android/m2repository/com/jakewharton/butterknife-compiler/8.0.1/butterknife-compiler-8.0.1.jar
        file:/D:/software/androidsdk20140708/android-sdk/extras/google/m2repository/com/jakewharton/butterknife-compiler/8.0.1/butterknife-compiler-8.0.1.pom
        file:/D:/software/androidsdk20140708/android-sdk/extras/google/m2repository/com/jakewharton/butterknife-compiler/8.0.1/butterknife-compiler-8.0.1.jar
    Required by:
        MyApplication:app:unspecified

    就是因为我的全局的gradle被我删除了这段代码:

    allprojects {
        repositories {
            jcenter()
        }
    }


    butterknife的配置应该如下:

    //butternife
    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'  
    }  

    这个应该是在自己的app.build.gradle里面配置。
    完整的来一个:

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 24
        buildToolsVersion "23.0.3"
    
        defaultConfig {
            applicationId "cebactivity.chinaceb.com.myapplication"
            minSdkVersion 11
            targetSdkVersion 24
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    //butternife
    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        }
    }
    
    apply plugin: 'com.neenbedankt.android-apt'
    
    
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
        compile 'com.jakewharton:butterknife:8.0.1'
        apt 'com.jakewharton:butterknife-compiler:8.0.1'
        compile 'com.android.support:appcompat-v7:24.0.0'
    }
    


    因为今天这个错误,我才知道jcenter是一个什么东西。原来是一个仓库。里面有所有的网上代码,如果你不写这一句代码,那么他只会在本地找,然后找不到,

    allprojects {
        repositories {
            jcenter()
        }
    }
  • 相关阅读:
    iphone, iphone4, ipad 图标和背景图片问题(转)
    ios项目icon和default图片命名规则 (转)
    ios判断设备是iphone还是ipad
    cocos2d学习(一)helloWorld
    判断设备是否是 iphone5
    字节对齐(转)
    NSArray排序
    C++复习之运算符重载,数组排序,vector
    socket编程(转)
    win32下的socket编程
  • 原文地址:https://www.cnblogs.com/caoxinyu/p/10568749.html
Copyright © 2020-2023  润新知