java.lang.ClassNotFoundException:没有从AAR中找到类

时间:2016-05-09 07:23:40

标签: android android-studio android-gradle build.gradle

我有一个android库项目,我从中创建了AAR文件。我已将AAR文件添加到我的应用程序项目中,而在运行时我得到以下异常:

Caused by: java.lang.ClassNotFoundException: Didn't find class
"com.creatrixone.customcomponents.LoadMoreListView" on path:
DexPathList[[zip file "/data/app/com.creatrixcampus-1.apk"],
nativeLibraryDirectories=[/data/app-lib/com.creatrixcampus-1, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
    at android.view.LayoutInflater.createView(LayoutInflater.java:559)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
    at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 

我在访问以下链接后更新了Library和Application项目gradle文件,

Android Library AAR depending on another library

但没有用, 这是我更新的库build.gradle 文件:

buildscript {
    repositories {
        mavenCentral()
    }

dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
    }
}

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'

version '1.1.1'

repositories {
    mavenCentral()
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.koushikdutta.ion:ion:2.1.7'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.android.support:recyclerview-v7:23.3.0'
    compile 'com.android.support:design:23.3.0'
    compile 'com.android.support:appcompat-v7:23.3.0'

    //session handelling using JWT
    compile 'io.jsonwebtoken:jjwt:0.6.0'

    compile 'com.nhaarman.listviewanimations:lib-core:3.1.0@aar'
    compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0@aar'
    compile 'com.nhaarman.listviewanimations:lib-core-slh:3.1.0@aar'
}


android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    useLibrary 'org.apache.http.legacy'

defaultConfig {
    //applicationId "com.creatrixone"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.1.1"
    multiDexEnabled true
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}

packagingOptions {
    exclude 'META-INF/LICENSE.txt'
}

productFlavors {
}

dexOptions {
    incremental true
}
}

这是我更新的项目build.gradle 文件:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
    }
}

apply plugin: 'com.android.application'

repositories {
    mavenCentral()
    maven { url "${System.env.HOME}/.m2/repository" }
    flatDir {
        dirs 'libs'
    }
}

android {

compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'

defaultConfig {
    applicationId 'com.creatrixcampus'
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 20160504
    versionName "1.5.0"
    multiDexEnabled true
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),       'proguard-rules.pro'
    }
}

productFlavors {
}

dexOptions {
    javaMaxHeapSize "4g"
    preDexLibraries = false
}

lintOptions {
        checkReleaseBuilds false
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:multidex:1.0.1'
    compile project(':photoViewerLibrary')
    compile project(':multipleImagePick')
    compile 'com.android.support:cardview-v7:23.3.0'
    compile 'com.android.support:recyclerview-v7:23.3.0'
    compile 'com.android.support:design:23.3.0'
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile ':creatrixone1_1@aar'
    compile 'com.google.code.gson:gson:2.4'
    compile 'com.github.alamkanak:android-week-view:1.2.1'
    compile 'com.google.zxing.client.android:barcode_1.0:1.1.0@aar'
    compile 'com.google.zxing:android-integration:3.2.0'
    compile 'com.google.android.gms:play-services-analytics:8.4.0'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.google.android.gms:play-services-gcm:8.4.0'
    compile 'xyz.danoz:recyclerviewfastscroller:0.1.3'
    //session handelling using JWT
    compile 'io.jsonwebtoken:jjwt:0.6.0'
    compile 'com.koushikdutta.ion:ion:2.1.7'
}

0 个答案:

没有答案