android studio项目嵌入到Android系统源码
16lz
2021-01-23
目录
- 基本环境
- 修改演示
基本环境
- 开发板:hikey960
- 代码:aosp,android-10.0.0_r33
- 开发环境:Windows 10 Pro,Android Studio 3.4,64bit ubuntu 16.04
修改演示
参考我的github源码的修改提交commit c45c72caf如下所示。
注意:第50行的sdk_version: "current",
如果去掉注释,会限制该APP不得引用系统API,譬如HIDL HAL接口。
commit c45c72caf8b779c5a87b90927ade8e59013a2f63 (HEAD -> master)Author: lucifer <[email protected].com>Date: Sat May 23 02:44:58 2020 +0800 fixup android studio's project integrated into aosp.diff --git a/LedControl/Android.bp b/LedControl/Android.bpnew file mode 100644index 0000000..ec66010--- /dev/null+++ b/LedControl/Android.bp@@ -0,0 +1,42 @@+//+// Copyright (C) 2008 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.+//++// This makefile shows how to build a shared library and an activity that+// bundles the shared library and calls it using JNI.++android_app {+ name: "LedControl",+ certificate: "platform",+ //product_specific: true,+ srcs: ["app/src/main/java/**/*.java"],++ resource_dirs: ["app/src/main/res"],+ manifest: "app/src/main/AndroidManifest.xml",++ jni_libs: ["libled_jni"],+ static_libs: [+ "androidx-constraintlayout_constraintlayout",+ "androidx-constraintlayout_constraintlayout-solver",+ ],++ optimize: {+ enabled: false,+ },+ //sdk_version: "current",+ dex_preopt: {+ enabled: false,+ },+}diff --git a/LedControl/app/src/main/java/com/example/ledcontrol/MainActivity.java b/LedControl/app/src/main/java/com/example/ledcontrol/MainActivity.javaindex 384589c..666c2fd 100644--- a/LedControl/app/src/main/java/com/example/ledcontrol/MainActivity.java+++ b/LedControl/app/src/main/java/com/example/ledcontrol/MainActivity.java@@ -1,6 +1,6 @@ package com.example.ledcontrol; -import android.support.v7.app.AppCompatActivity;+import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.view.View;@@ -8,7 +8,7 @@ import android.widget.Button; import com.example.lowlevel.LedNative; -public class MainActivity extends AppCompatActivity {+public class MainActivity extends Activity { private final String TAG = "LedControl"; private Button btn_led = null; LedNative ledNative = null;diff --git a/LedControl/app/src/main/res/layout/activity_main.xml b/LedControl/app/src/main/res/layout/activity_main.xmlindex 956d2d8..794882e 100644--- a/LedControl/app/src/main/res/layout/activity_main.xml+++ b/LedControl/app/src/main/res/layout/activity_main.xml@@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?>-<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"@@ -18,4 +18,4 @@ app:layout_constraintTop_toTopOf="parent" android:onClick="onClickLed"/> -</android.support.constraint.ConstraintLayout>\ No newline at end of file+</androidx.constraintlayout.widget.ConstraintLayout>diff --git a/LedControl/app/src/main/res/values/styles.xml b/LedControl/app/src/main/res/values/styles.xmlindex 6f19b47..cf391e0 100644--- a/LedControl/app/src/main/res/values/styles.xml+++ b/LedControl/app/src/main/res/values/styles.xml@@ -1,11 +1,8 @@ <resources> - <!-- Base application theme. -->- <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">- <!-- Customize your theme here. -->- <item name="colorPrimary">@color/colorPrimary</item>- <item name="colorPrimaryDark">@color/colorPrimaryDark</item>- <item name="colorAccent">@color/colorAccent</item>+ <style name="AppBaseTheme" parent="android:Theme.Light">+ </style>+ <style name="AppTheme" parent="AppBaseTheme"> </style> </resources>
更多相关文章
- Android系统基础(02) 系统源码环境搭建
- myeclipse8.5+win7 配置android 开发环境(非在线集成)
- Eclipse(Windowns XP)下搭建Android开发环境——简介
- 在Windows上搭建Android的JAVA开发环境图文教程(Eclipse版本)
- 在Windows7下构建Android的开发环境
- 《Android》Lesson01-环境配置
- Mac配置环境变量支持Android adb命令及常用命令