带有AndroidAnnotations NoClassDefFoundError的Android Studio

时间:2015-05-27 19:18:31

标签: java android android-studio android-gradle android-annotations

我有一个带有Android注释的应用程序,当我尝试运行它时,它会给我一个NoClassDefFoundError。

java.lang.NoClassDefFoundError: br.socialcondo.app.rest.services.UserService_

在注释日志中,我可以看到生成了这个类:

Note: Generating class: br.socialcondo.app.rest.services.UserService_

我在这里做错了什么?

修改

分享build.gradle

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        maven { url "http://dl.bintray.com/populov/maven" }
        mavenCentral()
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
    maven { url "http://dl.bintray.com/populov/maven" }
    maven { url "https://repo.commonsware.com.s3.amazonaws.com" }
    mavenCentral()
}

configurations {
    apt
}


android {
    compileSdkVersion 22
    buildToolsVersion '22.0.1'

    dexOptions {
        javaMaxHeapSize "4g"
    }

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 30

        versionName "2.0.0"
        multiDexEnabled true
    }

    signingConfigs {
        release {
            storeFile file("xxx")
            storePassword "xxx"
            keyAlias "xxx"
            keyPassword "xxx"
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_6
        targetCompatibility JavaVersion.VERSION_1_6
    }

    buildTypes {
        release {
            ext.betaDistributionGroupAliases = "devs"
            minifyEnabled false
            signingConfig signingConfigs.release
        }
    }

    productFlavors {
        production {
            applicationId "br.socialcondo.app"
        }

        development {
            applicationId "br.socialcondo.app"
        }
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/notice.txt'
    }
}

apt {
    arguments {
        androidManifestFile variant.outputs[0].processResources.manifestFile
        resourcePackageName 'br.socialcondo.app'
    }
}

dependencies {
    compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
    compile group: 'com.google.guava', name: 'guava', version: '11.0.2'
    // You must install or update the Google Repository through the SDK manager to use this dependency.
    // The Google Repository (separate from the corresponding library) can be found in the Extras category.
    // compile 'com.google.android.gms:play-services:4.2.42'
    // You must install or update the Google Repository through the SDK manager to use this dependency.
    // The Google Repository (separate from the corresponding library) can be found in the Extras category.
    //
    apt 'org.androidannotations:androidannotations:3.2'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':libraries:facebook')
    compile project(':libraries:caldroid')
    compile 'org.codehaus.jackson:jackson-jaxrs:1.9.13'
    compile 'org.androidannotations:androidannotations-api:3.2'
    compile 'com.google.android.gms:play-services:6.1.+'
    compile 'com.android.support:support-v4:22.1.1'
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile 'com.android.support:recyclerview-v7:22.1.1'
    compile 'com.android.support:gridlayout-v7:22.1.1'
    compile 'de.greenrobot:greendao:1.3.7'
    compile 'com.koushikdutta.urlimageviewhelper:urlimageviewhelper:1.0.4'
    compile('com.crashlytics.sdk.android:crashlytics:2.2.4@aar') {
        transitive = true
    }
    compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
    compile 'com.makeramen:roundedimageview:1.5.0'
    compile 'com.squareup.picasso:picasso:2.4.0'
    compile 'com.kbeanie:image-chooser-library:1.4.02@aar'
    compile 'com.github.chrisbanes.photoview:library:1.2.3'
    compile 'com.commonsware.cwac:endless:1.2.3'
    compile 'com.malinskiy:superrecyclerview:1.1.0'
}

编辑2

Root build.gradle

buildscript {

    repositories {
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}

1 个答案:

答案 0 :(得分:3)

问题在于

UISearchBar

仅在Android 5本机上支持。所以我需要一个库 在旧版本中运行。我找到了解决办法。