android studio項目嵌入到Android系統源碼

基本環境

  • 開發板:hikey960
  • 代碼:aosp,Android R
  • 開發環境:Windows 10 Pro,Android Studio 3.4,64bit ubuntu 16.04

演示場景

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.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;^M
 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 {^M
     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"^M
     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>^M
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">^M
+    </style>^M
+    <style name="AppTheme" parent="AppBaseTheme">^M
     </style>
 
 </resources>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章