My application will debug and run perfectly fine on my target device (HTC Desire HD) when the application is installed via USB from Eclipse.
However, when I export to .APK and then install this .APK on my Desire HD (having first manually uninstalled the previous installation of my application), it crashes.
Having inspected the error in Logcat I can see that a custom extended View
of mine, that is referenced using its fully-qualified name in a layout XML file, apparently cannot be found and leads to a .classNotFoundException
.
The two lines of interest from the Logcat error trace are:
04-09 21:29:01.101: E/AndroidRuntime(2157): Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class com.trevp.myAppName.DashboardLayout
And further below:
04-09 21:29:01.101: E/AndroidRuntime(2157): Caused by: java.lang.ClassNotFoundException: com.trevp.myAppName.DashboardLayout in loader dalvik.system.PathClassLoader[/data/app/com.trevp.myAppName-1.apk
This crash does not occur when the application is installed from Eclipse, only when installed from an exported .APK.
In case this could be a Proguard issue, here is my Proguard configuration file. I haven't really touched it from default, as I'm new to using Proguard. My Proguard version is 4.7.
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
The XML file that is being inflated. (Merge
tags are used because the elements within are added as children to the parent FrameLayout
.)
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top|left"
android:scaleType="centerCrop"
android:id="@+id/dashLayoutImage"
android:src="@drawable/background2" android:drawingCacheQuality="high"/>
<com.trevp.myAppName.DashboardLayout
android:clipChildren="false"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/dashLayout"
android:layout_gravity="top|left" />
<include
android:layout_gravity="top|left"
layout="@layout/status_bar"
android:id="@+id/statusBar" />
<TextView
android:layout_gravity="bottom|left"
android:id="@+id/pollRate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
</TextView>
</merge>
Thanks in advance for any tips on this. Please shout if there are any other extracts or configuration information required.