Android Studio 从输出应用程序中删除库 类
Android Studio removes library classes from output app
我在我的项目中禁用了混淆器:
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')
}
但是当我编译 运行 我的应用程序时,它会抱怨找不到 class(com.agimind.widget.SlideHolder
,它在指定的库中)!
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
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
。
任何帮助将不胜感激。
那是因为我还没有完成 multi-dex
的必要步骤。我没有将它添加到 AndroidManifest.xml
:
<application
android:name="android.support.multidex.MultiDexApplication"
...
因此,应用无法在第二个 dex 文件中找到 类。
我在我的项目中禁用了混淆器:
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')
}
但是当我编译 运行 我的应用程序时,它会抱怨找不到 class(com.agimind.widget.SlideHolder
,它在指定的库中)!
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
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
。
任何帮助将不胜感激。
那是因为我还没有完成 multi-dex
的必要步骤。我没有将它添加到 AndroidManifest.xml
:
<application
android:name="android.support.multidex.MultiDexApplication"
...
因此,应用无法在第二个 dex 文件中找到 类。