Gradle ClassNotFoundException

时间:2016-08-22 17:27:43

标签: android gradle dependencies

我创建了一个Android Library,并将其作为Android Application中的依赖项。

Gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        mavenLocal()
        maven {
            url "/Users/my.name/.m2/repository/"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        mavenLocal()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

应用Gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"

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

dependencies {
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'com.android.support:cardview-v7:24.1.1'
    compile 'SDK:library:unspecified'
    compile group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.5.1'
}

问题

运行应用程序时,出现以下错误:

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.some.library.view.InteractableWebView" on path: DexPathList[[zip file "/data/app/android.some.id.com.demo-2/base.apk"],nativeLibraryDirectories=[/data/app/android.some.id.com.demo-2/lib/x86, /vendor/lib, /system/lib]]

在Android Studio中,当我点击Project View并展开External Libraries时,我可以看到我创建的库及其所有类。所以它被引入,但它显然不会在运行时工作。

它可以编译,但它在运行时崩溃。有什么想法吗?

0 个答案:

没有答案