android studio项目嵌入到Android系统源码

目录

    • 基本环境
    • 修改演示

基本环境

  • 开发板: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 <xiangdong@trustkernel.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.bp
new file mode 100644
index 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.java
index 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.xml
index 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.xml
index 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)