[笔记分享] [Build] Android编译系统源代码之product.mk

介绍

源代码在build下,主要是在build/core下,下面是几个相对比较重要的文件。
main.mk: 主控Makefile, 如找到top目录下的所有Android.mk文件等。
base_rules.mk: 对Makefile的一些变量规则化。
binary.mk: 获取所有目标文件。
clear_vars.mk: 清楚编译系统中用到的临时变量。
config.mk: 包含编译目标程序所需的源文件及头文件等。
definitions.mk: 定义了系统用到的很多宏,相当于函数库。
envsetup.mk: 检查执行环境,决定主机、目标编译系统、结构等。
product_config.mk: 获取目标product。


product.mk

关于 product 的相关设定,则是由build/core/product_config.mk所处理,使用 build/core/product.mk提供宏载入。根据AndroidProducts.mk的內容,product_config.mk确定product目标。
这里写图片描述
通过上述代码找到了我们需要的TARGET_PRODUCT、TARGET_BUILD_VARIENT。然后再转换成TARGET_DEVICE。
有了这个TARGET_DEVICE,就能找到BoardConfig.mk。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的 Android 记事本应用的源代码,你可以参考一下: MainActivity.java: ```java import android.os.Bundle; import android.view.View; import android.widget.EditText; import androidx.appcompat.app.AppCompatActivity; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class MainActivity extends AppCompatActivity { private EditText mEditText; private static final String FILE_NAME = "note.txt"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mEditText = findViewById(R.id.edit_text); loadNote(); } private void loadNote() { FileInputStream fis = null; try { fis = openFileInput(FILE_NAME); byte[] data = new byte[fis.available()]; fis.read(data); String note = new String(data); mEditText.setText(note); } catch (IOException e) { e.printStackTrace(); } finally { if (fis != null) { try { fis.close(); } catch (IOException e) { e.printStackTrace(); } } } } private void saveNote() { FileOutputStream fos = null; try { fos = openFileOutput(FILE_NAME, MODE_PRIVATE); String note = mEditText.getText().toString(); fos.write(note.getBytes()); } catch (IOException e) { e.printStackTrace(); } finally { if (fos != null) { try { fos.close(); } catch (IOException e) { e.printStackTrace(); } } } } public void onSaveButtonClick(View view) { saveNote(); } } ``` activity_main.xml: ```xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <EditText android:id="@+id/edit_text" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:hint="@string/note_hint" android:gravity="top|start" android:padding="16dp" android:textAppearance="@style/TextAppearance.AppCompat.Body1" /> <Button android:id="@+id/save_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="end" android:layout_margin="16dp" android:text="@string/save_button_text" android:onClick="onSaveButtonClick" /> </LinearLayout> ``` strings.xml: ```xml <resources> <string name="app_name">Simple Note</string> <string name="note_hint">Type your note here...</string> <string name="save_button_text">Save</string> </resources> ``` 请注意:这只是一个简单的示例应用,没有实现任何其他功能(如读取和编辑笔记、添加标题等)。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值