Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bundle two apk into a single apk?

Tags:

android

apk

I have two completed projects, one for showing list of books and another is viewer app to read the books. But as the user have to download the book list app and after downloading he has to download the viewer app and i want to make it downloaded and installed at the starting. When i tried including the viewer app in the book list app then both got installed but when i made the apk then using the apk only the book list app is installed. Can anybody tell me what is the issue ? And is there any way to bundle two apk into one ? or what i should do ?

like image 610
user2106413 Avatar asked Oct 04 '22 20:10

user2106413


2 Answers

You can combine them into one project.

Create a project which has a package name of a base package name. For example, if your current apps are com.package.booklist and com.package.bookreader create a project with the package com.package. Now copy all the code from the book list into the com.package.booklist sub package, and all the code from the book reader into the com.package.bookreader.

Now you need to combine the AndroidManifests. You can copy all <activity> etc. elements into the new project's manifest. Now, you'll need to prefix all classes in the reader with .bookreader and all the classes in the book list with .booklist. So you'll have a manifest that looks something like:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.package"
    android:versionCode="1"
    android:versionName="1" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity android:name=".booklist.BookListActivity" >
            <intent-filter>
                <category android:name="android.intent.category.LAUNCHER" >
                </category>

                <action android:name="android.intent.action.MAIN" >
                </action>
            </intent-filter>
        </activity>

        <activity android:name=".bookreader.BookReaderActivity" >
            <intent-filter>
                <category android:name="android.intent.category.LAUNCHER" >
                </category>

                <action android:name="android.intent.action.MAIN" >
                </action>
            </intent-filter>
        </activity>
    </application>

</manifest>

Remove the:

            <intent-filter>
                <category android:name="android.intent.category.LAUNCHER" >
                </category>

                <action android:name="android.intent.action.MAIN" >
                </action>
            </intent-filter>

intent-filter from the Activity that you don't want in the launcher.

like image 93
Raghav Sood Avatar answered Oct 10 '22 02:10

Raghav Sood


You can't have two APK in a single APK.

However, you can have two Activities with that handle intents android.intent.category.LAUNCHER in your manifest. They will both appear in the Launcher then.

See this post for more detail.

like image 34
Hartok Avatar answered Oct 10 '22 04:10

Hartok