【问题标题】:NoClassDefFound error on older devices旧设备上的 NoClassDefFound 错误
【发布时间】:2015-08-01 23:59:09
【问题描述】:

几周后,我无法再在旧设备上运行我的应用了。例如,它在我的 OnePlus One 上运行良好,或者在 SGS5 上运行良好,但在我的 Galaxy S3 上运行良好。

当我通过 Android Studio 调试应用程序时,它会为刚刚创建的自定义类抛出 NoClassDefFoundError。

java.lang.NoClassDefFoundError: com.appsbv.sample.ComponentsEndpoint

你们知道怎么解决吗? 附:我在 OS X 上运行 Android Studio 1.3

在我的 gradle 文件下面:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion '22.0.0'
    defaultConfig {
        applicationId "com.appsbv.sample"
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 17
        versionName "7.0"
        multiDexEnabled true
    }
    buildTypes {
        debug {
            minifyEnabled false
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        abortOnError false
    }
    productFlavors {
    }
}

repositories {
    // for downloading polypicker dependency cwac-camera
    maven { url 'https://repo.commonsware.com.s3.amazonaws.com' }
    // Goodbye Maven Central
    maven { url 'https://jitpack.io' }
}

dependencies {
    compile project(':library')
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'org.parceler:parceler:0.2.16'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.squareup.okhttp:okhttp:2.4.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'
    compile 'in.srain.cube:grid-view-with-header-footer:1.0.11'
    compile 'com.tonicartos:stickygridheaders:1.0.1'
    compile 'com.parse.bolts:bolts-android:1.1.3'
    compile 'com.soundcloud.android:android-crop:1.0.0@aar'
    compile 'com.google.android.gms:play-services:6.5.87'
    compile files('src/main/java/com/appsbv/Parse-1.9.1.jar')
    compile 'com.github.jaydeepw:poly-picker:v1.0.14'
}

ComponentsEndpoint 类如下所示:

public class ComponentsEndpoint implements Endpoint {
    private static final String PROTOCOL = "http://";
    private static final String BASE = ".appsbv.nl/v1";
    private String url;
    private String service;
    public void setService(String serv) {
        service = serv;
        url = PROTOCOL + serv + BASE;
    }
    @Override
    public String getName() {
        return service;
    }
    @Override
    public String getUrl() {
        if (url == null) {
            throw new IllegalStateException("Illegal URL.");
        }
        return url;
    }
}

【问题讨论】:

    标签: java android macos android-studio noclassdeffounderror


    【解决方案1】:

    将此添加到您的 build.gradle 中,您会很高兴的

    dependencies {
    compile 'com.android.support:multidex:1.0.0'
    }
    

    【讨论】:

    • 这不是问题。最后通过删除 Google Play 服务依赖项来修复它
    猜你喜欢
    • 1970-01-01
    • 2013-10-08
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    • 2016-02-02
    • 1970-01-01
    • 2012-09-25
    • 1970-01-01
    相关资源
    最近更新 更多