Android Studio从输出应用中删除库类

时间:2015-01-25 11:28:11

标签: android gradle android-studio

我在项目中禁用了proguard:

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

我正在使用side menu库。它已在build.gradle

中得到解决
dependencies {
    ...
    compile files('libs/sidemenu.jar')
}

但是当我编译并运行我的应用程序时,它会抱怨找不到一个类(com.agimind.widget.SlideHolder$1在已编址的库中)!

E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{**.***.reader/**.***.reader.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class com.agimind.widget.SlideHolder
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1959)
        ...
        at dalvik.system.NativeStart.main(Native Method)
 Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class com.agimind.widget.SlideHolder
        at android.view.LayoutInflater.createView(LayoutInflater.java:606)
        ...
        at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
        at android.app.Activity.setContentView(Activity.java:1835)
        at **.***.reader.MainActivity.onCreate(MainActivity.java:121)
        at android.app.Activity.performCreate(Activity.java:4465)
        ...
        at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.constructNative(Native Method)
        ...
        at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
        at android.app.Activity.setContentView(Activity.java:1835)
        at **.***.reader.MainActivity.onCreate(MainActivity.java:121)
        at android.app.Activity.performCreate(Activity.java:4465)
        ...
 Caused by: java.lang.NoClassDefFoundError: com.agimind.widget.SlideHolder$1
        at com.agimind.widget.SlideHolder.<init>(SlideHolder.java:604)
        at java.lang.reflect.Constructor.constructNative(Native Method)
        ...
        at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
        at android.app.Activity.setContentView(Activity.java:1835)
        at **.***.reader.MainActivity.onCreate(MainActivity.java:121)
        at ...

注意:我也试过gradlew clean,但没有成功。

旁注:此项目使用了一些大型库,我为此启用了multi-dex

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

那是因为我没有完成multi-dex所需的步骤。我没有把它添加到AndroidManifest.xml

<application
    android:name="android.support.multidex.MultiDexApplication"
    ...

因此,应用程序无法在第二个dex文件中找到类。