android studio 导入 Launcher2 模块,并编译运行
来源:互联网 发布:找回淘宝账号密码 编辑:程序博客网 时间:2024/05/20 02:25
AS 版本:2.3.3
aosp 版本: 4.4 (已经编译过)
launcher 目录: .../packages/apps/ 下的 Launcher2 文件夹
详细步骤:
1. 在 AS 中 新建一个项目:LauncherTest
2.在 项目中 新增一个 Module : launcher22
3. 将 源码 Launcher2 文件夹 中的 AndroidManifest.xml 复制并替换掉 launcher22 中的 AndroidManifest.xml.
4.将 源码 res 目录 复制 并 替换掉 launcher22 中的 res 目录.
5.复制 源码 src 目录下的 所有文件 放到 launcher22 中的 java 目录下.
操作完上述步骤后 AS 结构如下:
6.修改 API 版本为 19:
7.点击 build -> Clean Project 或者 会出现一些错误信息,解决掉错误信息就可以运行了:
1).错误1:
Error:Execution failed for task ':launcher33:mergeDebugResources'.
> D:...src\main\res\values\strings.xml: Error: Unsupported type 'add-resource'
解决办法:
将strings文件中 :
<add-resource type="string" name="default_folder_name" />
替换为
<string name="default_folder_name" />
dimens文件中 :
<add-resource type="dimen" name="custom_cling_margin_top" />
<add-resource type="dimen" name="custom_cling_margin_right" />
<add-resource type="dimen" name="custom_cling_margin_left" />
替换为
<dimen name="custom_cling_margin_top">0dp</dimen>
<dimen name="custom_cling_margin_right">0dp</dimen>
<dimen name="custom_cling_margin_left">0dp</dimen>
2).错误2:
D:...\src\main\AndroidManifest.xml:25:5-47 Error:
Invalid value for attribute permission#com.android.launcher3.permission.PRELOAD_WORKSPACE@protectionLevel at AndroidManifest.xml:25:5-47, value=(system|signature), acceptable values are (normal,dangerous,signature,signatureOrSystem)
解决办法:
将 文件中:
android:protectionLevel="system|signature"
修改为 :
android:protectionLevel="signature"
3).错误3:
D:...\build\intermediates\res\merged\debug\values\values.xml
Error:(156) Attribute "title" already defined with incompatible format.
Error:(6) Original attribute defined here.
Error:(156) Attribute "title" already defined with incompatible format.
Error:(6) Original attribute defined here.
解决办法:
打开 launcher22 中的 build.gradle 文件,
删除 compile 'com.android.support:appcompat-v7:26.+'
4).错误4:
D:...\LauncherTest\launcher22\src\main\java\com\android\launcher2\Launcher.java
Error:(96, 26) 错误: 程序包com.android.common不存在
Error:(1625, 37) 错误: 找不到符号
符号: 变量 Search
位置: 类 Launcher
解决办法:
进入 编译过的源码目录:/out/target/common/obj/JAVA_LIBRARIES/android-common_intermediates/
将 classes.jar 文件 复制到 AS 的 libs 文件夹下(如果没有就创建一个)
并将其名称修改为 android_common.jar .
5).错误5:
AAPT err(Facade for 1848697531): libpng error: Not a PNG file
解决办法:
在 模块的 build.gradle 中 添加 :
android {
...
aaptOptions {
cruncherEnabled = false
}
...
}
6).错误6:
解决办法:
将 xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
替换为 :
xmlns:launcher="http://schemas.android.com/apk/res-auto"
8.不出意外的话,现在重新 点击 build -> Clean Project 或者 就可以编译成功了.
9.现在点击运行可能会显示如下错误:
解决办法:
找到 模块的 AndroidManifest.xml 文件,
<activity
android:name="com.android.launcher2.Launcher"
android:clearTaskOnLaunch="true"
android:launchMode="singleTask"
android:screenOrientation="nosensor"
android:stateNotNeeded="true"
android:theme="@style/Theme"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> // 加上这句
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.MONKEY" />
</intent-filter>
</activity>
10.安装APK时可能会出现如下错误:
解决办法:
找到 模块的 AndroidManifest.xml 文件,
修改其对应的报错的权限的名称即可,
图上是 com.android.launcher.permission.WRITE_SETTINGS 报错,
修改为:
<permission
android:name="com.android.launcher.permission.WRITE_SETTINGS_22"
android:description="@string/permdesc_write_settings"
android:label="@string/permlab_write_settings"
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
android:protectionLevel="normal" />
- android studio 导入 Launcher2 模块,并编译运行
- Android编译并运行launcher2
- 将android launcher2导入eclipse中运行
- 将android launcher2导入eclipse中运行
- 将android launcher2导入eclipse中运行
- 将android launcher2导入eclipse中运行
- Android Studio中导入Launcher2遇到的问题以及解决方案
- Android Studio中导入Launcher2遇到的问题以及解决方案
- Android studio 导入工程里面的模块不知怎样运行
- Android studio导入项目里面的模块无法运行
- 如何编译运行Android体系自带桌面Launcher2源码
- 如何编译运行Android系统自带桌面Launcher2源码
- ijkplayer在windows下编译并导入Android Studio
- 如何编译 netty 源码并导入android studio
- 将ijkplayer导入android studio并运行(附导入工程和导入module的方法)
- 总结:关于android4.2.2源码中launcher2导入Eclipse并运行
- 将系统自带的Launcher2源码导入eclipse中编译运行
- 将系统自带的Launcher2源码导入eclipse中编译运行
- 前端PM必须知道的用户心理那些事儿
- HDU
- Treats for the Cows---区间dp--逆序推
- js特效之下星星
- 局部变量和成员变量(全局变量)
- android studio 导入 Launcher2 模块,并编译运行
- Flask——表单类
- HDU 2604-Queuing(矩阵快速幂)
- centos上配置tomcat服务器
- HDU 5834 树形DP
- poj3278 Catch That Cow
- B 树笔记
- BZOJ 2464: 中山市选[2009]小明的游戏 简单搜索
- 字符串模式匹配算法