Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/371.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/185.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
匕首2:java.lang.NoSuchMethodError_Java_Android_Dagger 2 - Fatal编程技术网

匕首2:java.lang.NoSuchMethodError

匕首2:java.lang.NoSuchMethodError,java,android,dagger-2,Java,Android,Dagger 2,无法使用Dagger 2(Android Studio 1.3)构建项目 第一步。将依赖项添加到build.gradle apt 'com.google.dagger:dagger-compiler:2.0' compile 'com.google.dagger:dagger:2.0' provided 'org.glassfish:javax.annotation:10.0-b28' apply plugin: 'com.android.application' apply plug

无法使用Dagger 2(Android Studio 1.3)构建项目

第一步。将依赖项添加到build.gradle

apt 'com.google.dagger:dagger-compiler:2.0'
compile 'com.google.dagger:dagger:2.0'    
provided 'org.glassfish:javax.annotation:10.0-b28'
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'


android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {        
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:recyclerview-v7:22.2.0'
    compile 'com.android.support:cardview-v7:21.0.+'
    compile 'com.mcxiaoke.volley:library:1.0.+'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:design:22.2.+'
    compile 'com.android.support:palette-v7:22.2.+'
    compile 'com.afollestad:material-dialogs:0.7.8.1'

    apt 'com.google.dagger:dagger-compiler:2.0'
    compile 'com.google.dagger:dagger:2.0'
    compile 'org.androidannotations:androidannotations:3.0.+'
    compile 'org.androidannotations:androidannotations-api:3.0.+'

    provided 'org.glassfish:javax.annotation:10.0-b28'

    compile files('libs/gson-2.2.jar')

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

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.1'

    apt 'com.google.dagger:dagger-compiler:2.0'
    compile 'com.google.dagger:dagger:2.0'   
    provided 'org.glassfish:javax.annotation:10.0-b28'    

    compile files('libs/gson-2.2.jar')    
}
全体格,格雷德尔

apt 'com.google.dagger:dagger-compiler:2.0'
compile 'com.google.dagger:dagger:2.0'    
provided 'org.glassfish:javax.annotation:10.0-b28'
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'


android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {        
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:recyclerview-v7:22.2.0'
    compile 'com.android.support:cardview-v7:21.0.+'
    compile 'com.mcxiaoke.volley:library:1.0.+'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:design:22.2.+'
    compile 'com.android.support:palette-v7:22.2.+'
    compile 'com.afollestad:material-dialogs:0.7.8.1'

    apt 'com.google.dagger:dagger-compiler:2.0'
    compile 'com.google.dagger:dagger:2.0'
    compile 'org.androidannotations:androidannotations:3.0.+'
    compile 'org.androidannotations:androidannotations-api:3.0.+'

    provided 'org.glassfish:javax.annotation:10.0-b28'

    compile files('libs/gson-2.2.jar')

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

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.1'

    apt 'com.google.dagger:dagger-compiler:2.0'
    compile 'com.google.dagger:dagger:2.0'   
    provided 'org.glassfish:javax.annotation:10.0-b28'    

    compile files('libs/gson-2.2.jar')    
}
第二步

只需在代码中添加注释
@Inject
@Module
,即可获得编译错误

错误:任务“:app:compiledBugJava”的执行失败

java.lang.NoSuchMethodError:com.google.common.collect.Multimaps.filterKeys(Lcom/google/common/collect/SetMultimap;Lcom/google/common/base/Predicate;)Lcom/google/common/collect/SetMultimap

有什么想法吗

更新

我正在创建一个新项目

格雷德尔先生

apt 'com.google.dagger:dagger-compiler:2.0'
compile 'com.google.dagger:dagger:2.0'    
provided 'org.glassfish:javax.annotation:10.0-b28'
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'


android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {        
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:recyclerview-v7:22.2.0'
    compile 'com.android.support:cardview-v7:21.0.+'
    compile 'com.mcxiaoke.volley:library:1.0.+'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:design:22.2.+'
    compile 'com.android.support:palette-v7:22.2.+'
    compile 'com.afollestad:material-dialogs:0.7.8.1'

    apt 'com.google.dagger:dagger-compiler:2.0'
    compile 'com.google.dagger:dagger:2.0'
    compile 'org.androidannotations:androidannotations:3.0.+'
    compile 'org.androidannotations:androidannotations-api:3.0.+'

    provided 'org.glassfish:javax.annotation:10.0-b28'

    compile files('libs/gson-2.2.jar')

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

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.1'

    apt 'com.google.dagger:dagger-compiler:2.0'
    compile 'com.google.dagger:dagger:2.0'   
    provided 'org.glassfish:javax.annotation:10.0-b28'    

    compile files('libs/gson-2.2.jar')    
}
很好。当我添加到libs
guava-r07.jar
时,我得到了类似编译错误的结果。我认为问题与番石榴有关

已解决

  • 从libs中删除
    guava-r07.jar

  • 添加到build.gradle

    apt 'com.google.dagger:dagger-compiler:2.0'
    compile 'com.google.dagger:dagger:2.0'    
    provided 'org.glassfish:javax.annotation:10.0-b28'
    
    apply plugin: 'com.android.application'
    apply plugin: 'com.neenbedankt.android-apt'
    
    
    android {
        compileSdkVersion 22
        buildToolsVersion "22.0.1"
    
        defaultConfig {        
            minSdkVersion 14
            targetSdkVersion 22
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:22.2.0'
        compile 'com.android.support:recyclerview-v7:22.2.0'
        compile 'com.android.support:cardview-v7:21.0.+'
        compile 'com.mcxiaoke.volley:library:1.0.+'
        compile 'com.squareup.picasso:picasso:2.5.2'
        compile 'com.android.support:design:22.2.+'
        compile 'com.android.support:palette-v7:22.2.+'
        compile 'com.afollestad:material-dialogs:0.7.8.1'
    
        apt 'com.google.dagger:dagger-compiler:2.0'
        compile 'com.google.dagger:dagger:2.0'
        compile 'org.androidannotations:androidannotations:3.0.+'
        compile 'org.androidannotations:androidannotations-api:3.0.+'
    
        provided 'org.glassfish:javax.annotation:10.0-b28'
    
        compile files('libs/gson-2.2.jar')
    
    }
    
    apply plugin: 'com.android.application'
    apply plugin: 'com.neenbedankt.android-apt'
    
    android {
        compileSdkVersion 22
        buildToolsVersion "22.0.1"
    
        defaultConfig {
            minSdkVersion 15
            targetSdkVersion 22
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:22.2.1'
    
        apt 'com.google.dagger:dagger-compiler:2.0'
        compile 'com.google.dagger:dagger:2.0'   
        provided 'org.glassfish:javax.annotation:10.0-b28'    
    
        compile files('libs/gson-2.2.jar')    
    }
    
    编译'com.google.guava:guava:13.0.1'


  • Guava的当前版本是18.0,有一个候选版本19.0-rc1。您确定添加的jar中存在
    Multimpas.filterKeys
    ?否则,请升级到guava的最新版本,该版本可能为18.0,因为没有编译错误。无论如何,谢谢你,我会更新番石榴的。