hi粉丝朋友大家好! 以前在android framework入门课讲解过第三方应用apk的预制相关内容,那时候是基于Android 8.1的Android.mk,但大家依旧对Android.bp的预制不知道怎么做,所以很多粉丝经常私下问我,干脆这里给大家blog分享,这里我们来使用Android.bp进行预制,因为现在高版本大部分其实都是使用Android.bp,新版本packages/apps下面android 12几乎看不到Android.mk的身影,所以当然我们也需要与时俱进。但是Android.bp相对来说资料较少,不像以前的Android.mk可以继承很多linux的makefile,所以我这边些Android.bp大部分也只能依葫芦画瓢,参考其他应用怎么写的。
下面开始正题: 源码准备等和Android.mk一样具体可以点击看这里: https://blog.csdn.net/learnframework/article/details/124222138 也可以关注看看我的b站视频,获取更多课程可以b站直接私聊我: https://www.bilibili.com/video/BV1TS4y1e7De/
下面我们其实只需要把原来的Android.mk替换成Android.bp具体Android.bp内容如下:
//
// Copyright (C) 2016 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//package {
// See: http://go/android-license-faq
// A large-scale-change added 'default_applicable_licenses' to import
// all of the 'license_kinds' from "frameworks_base_license"
// to get the below license kinds:
// SPDX-license-identifier-Apache-2.0
// default_applicable_licenses: ["Android-Apache-2.0"],
//}
android_app_import {
name: "MyApp1",
// this needs to be a privileged application
privileged: true,
// Make sure the build system doesn't try to resign the APK
dex_preopt: {
enabled: false,
},
arch: {
arm: {
apk: "MyApp1.apk",
},
arm64: {
apk: "MyApp1.apk",
},
x86: {
apk: "MyApp1.apk",
},
x86_64: {
apk: "MyApp1.apk",
},
},
certificate: "platform",
}
最后可以编译一下:make MyApp1
|