Bundle two apk into a single apk?

前端 未结 2 744
北荒
北荒 2020-12-19 10:15

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 downlo

相关标签:
2条回答
  • 2020-12-19 10:32

    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.

    0 讨论(0)
  • 2020-12-19 10:34

    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.

    0 讨论(0)
提交回复
热议问题