Android android studio project is compiled in source code

Some permissions in app cannot be implemented in Android studio, such as shutdown. Although permissions are configured, APP signature is still required. Therefore, app is directly compiled in source code

1, First, put the app code in the source code
1. It can be placed under the package/app / of your own project in the vendor directory
2. It can be placed in vendor / Google / partner [GMS / apps or vendor/mtk/qcom, etc
3. It can also be directly placed under packages/apps /

As shown in the figure below:

Add a mk file to the file

2, The contents of mk file are as follows:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
 #This is mainly used for eng, user or userdebug versions to participate in compilation; all versions of optional values participate in compilation
LOCAL_MODULE_TAGS   := optional
 #Compiled java file path
LOCAL_SRC_FILES := $(call all-java-files-under, app/src/main/java)
 #Android manifest.xml file to be compiled
LOCAL_MANIFEST_FILE := app/src/main/AndroidManifest.xml
 #Compiled resource file path
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/app/src/main/res
 #Name of compiled apk
LOCAL_PACKAGE_NAME := MyReboot
 #apk signature
LOCAL_CERTIFICATE := platform

include $(BUILD_PACKAGE)
include $(CLEAR_VERS)
include $(call all-makefiles-under,$(LOCAL_PATH))

3, Problem solving:
After the above process is imported, no error will be reported for android-support-v7-appcompat and other files. The solution is as follows:

Replace the original style.xml file, or change the contents of the file as follows

<resources>

    <!-- Base application theme. -->
    <!-- Annotate
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">         
    -->
        <!-- Customize your theme here. -->

        <!-- Annotate

        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

    -->
     <!--Add original Activity Corresponding theme-->
     <style name="AppBaseTheme" parent="android:Theme.Light">
    </style>
     <style name="AppTheme" parent="AppBaseTheme">
     </style>
     <!--Add original theme-->

</resources> 

Simultaneous modification

//Comment out the v7 and add the following import items
 #import android.support.v7.app.AppCompatActivity;
import android.app.Activity;

//Comment out AppCompatActivity and add Activity 
//public class MainActivity extends AppCompatActivity implements SensorEventListener {
public class MainActivity extends Activity implements SensorEventListener {

}

Then mm compiles apk

Tags: Android Java xml Google

Posted on Mon, 06 Jan 2020 05:23:45 -0800 by UpcomingPhpDev