Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to instantiate activity from library
    primarykey
    data
    text
    <p>I am trying to create an application that has different flavours (e.g. free, paid), by putting as much common code as I can into a library, and making projects for each flavour. At the moment, the Java class for the main activity will be the same in all versions, it is merely the layout and some constants defined in the "values" resource directory that need to change to control the behaviour. </p> <p>I have defined the activity in my "free" project's manifest file as follows:</p> <pre><code>&lt;activity android:name="librarypackagename.Foo" android:label="@string/bar" android:launchMode="singleTask" android:uiOptions="splitActionBarWhenNarrow" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; </code></pre> <p>But when testing the application, I receive the following error:</p> <p>"Unable to instantiate Activity ComponentInfo{freeapppackagename/librarypackagename.Foo}: java.lang.ClassNotFoundException: Didn't find class "librarypackagename.Foo" on path: DexPathList[[zip file "/data/app/freeapppackagename-2.apk"],nativeLibraryDirectories=[/data/app-lib/freeapppackagename-2, /vendor/lib, /system/lib]]"</p> <p>Is it not possible to use an activity from a library as the main activity? I have also tried this by extending Foo in my free app project, and using that as the main activity, but I still get the same exception.</p> <p>Edit (removed manifest files, as it turned out they weren't related to the issue):</p> <p>Also, in Eclipse, I've just noticed I am getting the following error message (although the project still builds):</p> <blockquote> <p>Found 2 versions of android-support-v4.jar in the dependency list, but not all the versions are identical (check is based on SHA-1 only at this time). All versions of the libraries must be the same at this time. Versions found are: Path: D:\Work\Eclipse\LiteApplicationName\libs\android-support-v4.jar Length: 556198 SHA-1: 4a6be13368bb64c5a0b0460632d228a1a915f58f Path: D:\Work\Eclipse\LibraryName\libs\android-support-v4.jar Length: 385685 SHA-1: 48c94ae70fa65718b382098237806a5909bb096e Jar mismatch! Fix your dependencies</p> </blockquote> <p>Strangely enough, the android-support-v4.jar file appears in "Referenced Libraries" in the application project, but in "Android Private Libraries" in the library.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload