非全局替换,重打包修改apk包名
本帖最后由 choson 于 2020-7-29 20:50 编辑有些人想app多开,或者想同时安装几个一样的app在手机上,除了用多开工具之外,还有一个办法就是修改包名,让多个包名不冲突,这样就可以安装多个一样功能的包到手机上。
目前,在网上大部分的apk重打包修改包名方法都是全局查找包名进行字符串替换。这样有个问题,就是当app上有native方法时,如果进行了全局替换,有些native方法将无法访问。最近有个需求我尝试研究非全局替换的方式修改包名,竟然成功了,过程给有需要的朋友参考一下。
实验apk:菜谱大全(非加固的app,加固的app本方法无效)原包名:net.meishi360.app修改后包名:net11.meishi360.app
重打包工具:Android Killer
apktool版本:2.4.1
一、先把apk拖进Android Killer反编译,然后不作任何修改重打包一次,在手机上可以顺利安装和使用。
二、打开AndroidManifest.xml,首先修改包名package="net.meishi360.app" 为package="net11.meishi360.app",再次重打包,竟然可以顺利成功重打包。
三、在手机安装打包后的apk,在没有卸载原来的apk时,发现安装过程中出错,新apk安装不进去。查看adb logcat,发现有些provider、intent名称已经被原apk注册进系统,q名称有冲突所以apk安装被中止。
四、继续修改provider、intent等名称。再次重打包,可以成功安装,并可以正常使用。修改包名成功。
附:
修改前AndroidManifest.xml
<?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="net.meishi360.app" platformBuildVersionCode="27" platformBuildVersionName="8.1.0">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.zhht.mcms.app.permission.JPUSH_MESSAGE"/>
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
<permission android:name="net.meishi360.app.permission.JPUSH_MESSAGE" android:protectionLevel="signature"/>
<uses-permission android:name="net.meishi360.app.permission.JPUSH_MESSAGE"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.GET_TASKS"/>
<application android:allowBackup="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:name="net.meishi360.app.CookApplication" android:roundIcon="@mipmap/icon" android:supportsRtl="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true">
<meta-data android:name="UMENG_CHANNEL" android:value="oppo"/>
<meta-data android:name="UMENG_APPKEY" android:value="5a7538158f4a9d1f8500038e"/>
<activity android:configChanges="keyboardHidden|orientation|screenSize" android:launchMode="singleTask" android:name="net.meishi360.app.ui.activity.HomeFragmentActivity" android:screenOrientation="portrait" android:windowSoftInputMode="adjustResize|stateHidden"/>
<activity android:name="net.meishi360.app.splash.Splash2Activity" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="net.meishi360.app.ui.activity.FoodCollectOrHistoryActivity"/>
<activity android:name="net.meishi360.app.ui.activity.FoodDetailActivity"/>
<activity android:launchMode="singleTask" android:name="net.meishi360.app.ui.activity.FoodSearchActivity"/>
<activity android:name="net.meishi360.app.ui.activity.FoodsResultActivity"/>
<activity android:name="net.meishi360.app.ui.activity.SettingActivity"/>
<activity android:name="net.meishi360.app.ui.activity.WebViewActivity"/>
<activity android:configChanges="keyboardHidden|orientation|screenSize" android:exported="true" android:name="net.meishi360.app.wxapi.WXEntryActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
<activity android:launchMode="singleTask" android:name="com.tencent.tauth.AuthActivity" android:noHistory="true">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="tencent100424468"/>
</intent-filter>
</activity>
<activity android:configChanges="keyboardHidden|orientation|screenSize" android:name="com.tencent.connect.common.AssistActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
<service android:exported="false" android:name="com.qq.e.comm.DownloadService"/>
<activity android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:name="com.qq.e.ads.ADActivity"/>
<service android:enabled="true" android:exported="false" android:name="net.meishi360.app.push.PushService" android:process=":pushcore">
<intent-filter>
<action android:name="cn.jiguang.user.service.action"/>
</intent-filter>
</service>
<receiver android:enabled="true" android:exported="false" android:name="net.meishi360.app.push.PushReceiver">
<intent-filter>
<action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE"/>
<category android:name="net.meishi360.app"/>
</intent-filter>
</receiver>
<meta-data android:name="JPUSH_CHANNEL" android:value="developer-default"/>
<meta-data android:name="JPUSH_APPKEY" android:value="aef01ff368df27cbe30ebb34"/>
<provider android:authorities="net.meishi360.app.AgentWebFileProvider" android:exported="false" android:grantUriPermissions="true" android:name="com.just.agentweb.AgentWebFileProvider">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/web_files_public"/>
</provider>
<activity android:configChanges="keyboardHidden|orientation|screenSize" android:exported="false" android:launchMode="standard" android:name="com.just.agentweb.ActionActivity" android:theme="@style/actionActivity" android:windowSoftInputMode="stateAlwaysHidden"/>
<provider android:authorities="net.meishi360.app.DownloadFileProvider" android:exported="false" android:grantUriPermissions="true" android:name="com.download.library.DownloadFileProvider">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/download_files_public"/>
</provider>
<receiver android:exported="false" android:name="com.download.library.NotificationCancelReceiver"/>
<meta-data android:name="com.tencent.rdm.uuid" android:value="3f34c50c-1bd6-44cf-9f47-c5d6adf9bee7"/>
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
<activity android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:name="com.qq.e.ads.PortraitADActivity" android:screenOrientation="portrait"/>
<activity android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:name="com.qq.e.ads.LandscapeADActivity" android:screenOrientation="landscape"/>
<activity android:exported="false" android:name="cn.jpush.android.ui.PopWinActivity" android:theme="@style/MyDialogStyle"/>
<activity android:configChanges="keyboardHidden|orientation" android:exported="false" android:name="cn.jpush.android.ui.PushActivity" android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="cn.jpush.android.ui.PushActivity"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="net.meishi360.app"/>
</intent-filter>
</activity>
<service android:enabled="true" android:exported="false" android:name="cn.jpush.android.service.PushService" android:process=":pushcore">
<intent-filter>
<action android:name="cn.jpush.android.intent.REGISTER"/>
<action android:name="cn.jpush.android.intent.REPORT"/>
<action android:name="cn.jpush.android.intent.PushService"/>
<action android:name="cn.jpush.android.intent.PUSH_TIME"/>
</intent-filter>
</service>
<service android:enabled="true" android:exported="true" android:name="cn.jpush.android.service.DaemonService">
<intent-filter>
<action android:name="cn.jpush.android.intent.DaemonService"/>
<category android:name="net.meishi360.app"/>
</intent-filter>
</service>
<receiver android:enabled="true" android:exported="false" android:name="cn.jpush.android.service.PushReceiver">
<intent-filter android:priority="1000">
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY"/>
<category android:name="net.meishi360.app"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.USER_PRESENT"/>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED"/>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
<data android:scheme="package"/>
</intent-filter>
</receiver>
<receiver android:exported="false" android:name="cn.jpush.android.service.AlarmReceiver"/>
<provider android:authorities="net.meishi360.app.DataProvider" android:exported="false" android:name="cn.jpush.android.service.DataProvider" android:process=":pushcore"/>
<provider android:authorities="net.meishi360.app.DownloadProvider" android:exported="true" android:name="cn.jpush.android.service.DownloadProvider"/>
<activity android:exported="true" android:name="cn.jpush.android.service.JNotifyActivity" android:taskAffinity="jpush.custom" android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="cn.jpush.android.intent.JNotifyActivity"/>
<category android:name="net.meishi360.app"/>
</intent-filter>
</activity>
</application>
</manifest>
修改后AndroidManifest.xml
<?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="net11.meishi360.app" platformBuildVersionCode="27" platformBuildVersionName="8.1.0">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.zhht.mcms.app.permission.JPUSH_MESSAGE"/>
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
<permission android:name="net11.meishi360.app.permission.JPUSH_MESSAGE" android:protectionLevel="signature"/>
<uses-permission android:name="net11.meishi360.app.permission.JPUSH_MESSAGE"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.GET_TASKS"/>
<application android:allowBackup="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:name="net.meishi360.app.CookApplication" android:roundIcon="@mipmap/icon" android:supportsRtl="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true">
<meta-data android:name="UMENG_CHANNEL" android:value="oppo"/>
<meta-data android:name="UMENG_APPKEY" android:value="5a7538158f4a9d1f8500038e"/>
<activity android:configChanges="keyboardHidden|orientation|screenSize" android:launchMode="singleTask" android:name="net.meishi360.app.ui.activity.HomeFragmentActivity" android:screenOrientation="portrait" android:windowSoftInputMode="adjustResize|stateHidden"/>
<activity android:name="net.meishi360.app.splash.Splash2Activity" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="net.meishi360.app.ui.activity.FoodCollectOrHistoryActivity"/>
<activity android:name="net.meishi360.app.ui.activity.FoodDetailActivity"/>
<activity android:launchMode="singleTask" android:name="net.meishi360.app.ui.activity.FoodSearchActivity"/>
<activity android:name="net.meishi360.app.ui.activity.FoodsResultActivity"/>
<activity android:name="net.meishi360.app.ui.activity.SettingActivity"/>
<activity android:name="net.meishi360.app.ui.activity.WebViewActivity"/>
<activity android:configChanges="keyboardHidden|orientation|screenSize" android:exported="true" android:name="net.meishi360.app.wxapi.WXEntryActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
<activity android:launchMode="singleTask" android:name="com.tencent.tauth.AuthActivity" android:noHistory="true">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="tencent100424468"/>
</intent-filter>
</activity>
<activity android:configChanges="keyboardHidden|orientation|screenSize" android:name="com.tencent.connect.common.AssistActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
<service android:exported="false" android:name="com.qq.e.comm.DownloadService"/>
<activity android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:name="com.qq.e.ads.ADActivity"/>
<service android:enabled="true" android:exported="false" android:name="net.meishi360.app.push.PushService" android:process=":pushcore">
<intent-filter>
<action android:name="cn.jiguang.user.service.action"/>
</intent-filter>
</service>
<receiver android:enabled="true" android:exported="false" android:name="net.meishi360.app.push.PushReceiver">
<intent-filter>
<action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE"/>
</intent-filter>
</receiver>
<meta-data android:name="JPUSH_CHANNEL" android:value="developer-default"/>
<meta-data android:name="JPUSH_APPKEY" android:value="aef01ff368df27cbe30ebb34"/>
<provider android:authorities="net11.meishi360.app.AgentWebFileProvider" android:exported="false" android:grantUriPermissions="true" android:name="com.just.agentweb.AgentWebFileProvider">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/web_files_public"/>
</provider>
<activity android:configChanges="keyboardHidden|orientation|screenSize" android:exported="false" android:launchMode="standard" android:name="com.just.agentweb.ActionActivity" android:theme="@style/actionActivity" android:windowSoftInputMode="stateAlwaysHidden"/>
<provider android:authorities="net11.meishi360.app.DownloadFileProvider" android:exported="false" android:grantUriPermissions="true" android:name="com.download.library.DownloadFileProvider">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/download_files_public"/>
</provider>
<receiver android:exported="false" android:name="com.download.library.NotificationCancelReceiver"/>
<meta-data android:name="com.tencent.rdm.uuid" android:value="3f34c50c-1bd6-44cf-9f47-c5d6adf9bee7"/>
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
<activity android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:name="com.qq.e.ads.PortraitADActivity" android:screenOrientation="portrait"/>
<activity android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:name="com.qq.e.ads.LandscapeADActivity" android:screenOrientation="landscape"/>
<activity android:exported="false" android:name="cn.jpush.android.ui.PopWinActivity" android:theme="@style/MyDialogStyle"/>
<activity android:configChanges="keyboardHidden|orientation" android:exported="false" android:name="cn.jpush.android.ui.PushActivity" android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="cn.jpush.android.ui.PushActivity"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<service android:enabled="true" android:exported="false" android:name="cn.jpush.android.service.PushService" android:process=":pushcore">
<intent-filter>
<action android:name="cn.jpush.android.intent.REGISTER"/>
<action android:name="cn.jpush.android.intent.REPORT"/>
<action android:name="cn.jpush.android.intent.PushService"/>
<action android:name="cn.jpush.android.intent.PUSH_TIME"/>
</intent-filter>
</service>
<service android:enabled="true" android:exported="true" android:name="cn.jpush.android.service.DaemonService">
<intent-filter>
<action android:name="cn.jpush.android.intent.DaemonService"/>
</intent-filter>
</service>
<receiver android:enabled="true" android:exported="false" android:name="cn.jpush.android.service.PushReceiver">
<intent-filter android:priority="1000">
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.USER_PRESENT"/>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED"/>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
<data android:scheme="package"/>
</intent-filter>
</receiver>
<receiver android:exported="false" android:name="cn.jpush.android.service.AlarmReceiver"/>
<provider android:authorities="net11.meishi360.app.DataProvider" android:exported="false" android:name="cn.jpush.android.service.DataProvider" android:process=":pushcore"/>
<provider android:authorities="net11.meishi360.app.DownloadProvider" android:exported="true" android:name="cn.jpush.android.service.DownloadProvider"/>
<activity android:exported="true" android:name="cn.jpush.android.service.JNotifyActivity" android:taskAffinity="jpush.custom" android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="cn.jpush.android.intent.JNotifyActivity"/>
</intent-filter>
</activity>
</application>
</manifest>
重点就是包名:package="net.meishi360.app"
和
<provider android:authorities="net.meishi360.app.DataProvider" android:exported="false" android:name="cn.jpush.android.service.DataProvider" android:process=":pushcore"/>
<provider android:authorities="net.meishi360.app.DownloadProvider" android:exported="true" android:name="cn.jpush.android.service.DownloadProvider"/>
AndroidManifest.xml内除了<activity>的别的全部替换即可
普通软件应用可以,稍微复杂一点的就不行了, 收藏 支持 学习 一下 看起来头大。。。? 这也是个办法,针对部分APK能用。 感谢楼主指导回头练下手 学习了,谢谢 小白表示代码部分看了有点头大{:301_998:} 整个项目所有文件搜索替换不就完了? 不知道操作了什么,做个代码高亮对比一下都好