"Finally understand, meituan Android interview

//build.gradle
//Note that the data types in gradle.properties are all String types, and other data types need to be converted by themselves
if (isModule.toBoolean()){
    apply plugin: 'com.android.application'
}else {
    apply plugin: 'com.android.library'
}

3.1.2 dynamic configuration of ApplicationId and AndroidManifest

We know that an App needs an ApplicationId, and the component is also an App during independent debugging, so it also needs an ApplicationId. The component does not need an ApplicationId during integrated debugging; In addition, an App has only one startup page, and components also need a startup page during independent debugging, which is not required during integrated debugging. Therefore, the ApplicationId and AndroidManifest also need isModule for configuration.

//build.gradle (module_cart)
android {
...
    defaultConfig {
...
        if (isModule.toBoolean()) {
            // applicationId is added during independent debugging and removed during integrated debugging
            applicationId "com.hfy.componentlearning.cart"
        }
...
    }

    sourceSets {
        main {
            // Different AndroidManifest.xml files are used for independent debugging and integrated debugging
            if (isModule.toBoolean()) {
                manifest.srcFile 'src/main/moduleManifest/AndroidManifest.xml'
            } else {
                manifest.srcFile 'src/main/AndroidManifest.xml'
            }
        }
    }
...
}

It can be seen that isModule is also used to set applicationId and AndroidManifest respectively. The AndroidManifest for independent debugging is a newly created directory moduleManifest. You can specify the AndroidManifest file paths of the two debugging modes by using manifest.srcFile.

The newly created manifest file in moduleManifest specifies Application and startup activity:

//moduleManifest/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.hfy.module_cart" >
    <application android:name=".CartApplication"
        android:allowBackup="true"
        android:label="Cart"
        android:theme="@style/Theme.AppCompat">
        <activity android:name=".CartActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

The originally automatically generated manifest does not specify Application or start activity:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.hfy.module_cart">
    <application>
        <activity android:name=".CartActivity"></activity>
    </application>
</manifest>

For independent debugging and integrated debugging, use "assemblydebug" to build respectively, and the results are as follows:

3.2 multi project scheme

3.2.1 scheme overview

For multi project schemes, business components exist in independent projects in the form of library module. Independent projects can be debugged independently, and the above configurations are no longer required.

For example, the shopping Cart component is the module of the new project Cart_ For the Cart module, the business code is written in the module_ Just in the Cart. App modules are dependent modules_ Cart. The app module is just a component entry or some demo test code.

Then, when all business components are split into independent components, the original project will become a shell project with only app modules. The shell project is used to integrate all business components.

3.2.1 maven reference component

So how to do integration debugging? Use maven to reference components: 1. Publish the arr package of components to the company's maven warehouse; 2. Then use the implementation dependency in the shell project, which is the same as using a third-party library. In addition, the arr package is divided into SNAPSHOT version and Realease version. The SNAPSHOT version is used for debugging in the development stage, and the official version is used for official release. The details are as follows:

First, in module_ Create a new Maven in the cart module_ Push.gradle file, and build.gradle directory

apply plugin: 'maven'

configurations {
    deployerJars
}

repositories {
    mavenCentral()
}

//Tasks uploaded to Maven warehouse
uploadArchives {
    repositories {
        mavenDeployer {
            pom.version = '1.0.0' // Version number
            pom.artifactId = 'cart' // Project name (usually the name of class library module, or any)
            pom.groupId = 'com.hfy.cart' // Unique identification (usually the module package name, or any)

            //Specify the url of maven warehouse of snapshot version. todo, please change it to your maven server address, account and password
            snapshotRepository(url: 'http://xxx/maven-snapshots/') {
                authentication(userName: '***', password: '***')
            }
            //Specify the url of the official version maven warehouse. todo, please change it to your maven server address, account and password
            repository(url: 'http://xxx/maven-releases/') {
                authentication(userName: '***', password: '***')
            }
        }
    }
}

// Type displays the specified task type or task. Here, you specify the task to execute Javadoc, which has been defined in gradle
task androidJavadocs(type: Javadoc) {
    // Set the location of the source code
    source = android.sourceSets.main.java.sourceFiles
}

// Generate javadoc.jar
task androidJavadocsJar(type: Jar) {
    // Specify document name
    classifier = 'javadoc'
    from androidJavadocs.destinationDir
}

// Package the task s of the code and resources in the main directory to generate sources.jar
task androidSourcesJar(type: Jar) {
    classifier = 'sources'
    from android.sourceSets.main.java.sourceFiles
}

//Configure the files that need to be uploaded to maven warehouse
artifacts {
    archives androidSourcesJar
    archives androidJavadocsJar
}

maven_push.gradle is mainly used to configure the release component ARR: version number, name, Maven warehouse address, account number, etc.

Then, reference in build.gradle:

//build.gradle
apply from: 'maven_push.gradle'

Then, after clicking Sync, click the Gradle task uploadArchives to package and publish arr to the maven warehouse.

Finally, to reference the component ARR in the shell project, you need to add maven warehouse address in build.gradle under the root directory of the shell project:

allprojects {
    repositories {
        google()
        jcenter()
        //Private server warehouse address
        maven {
            url 'http://xxx'
        }
    }
}
Copy code

Then add dependency in build.gradle of app:

dependencies {
    ...
    implementation 'com.hfy.cart:cart:1.0.0'
    //And other business components
}

It can be seen that the multi engineering scheme is the same as the third-party library we usually use, except that we publish the component ARR to the company's private maven warehouse.

In fact, I personally recommend using multi engineering schemes.

  • A single engineering scheme cannot achieve code permission control or clear division of responsibilities of developers. Each developer can modify any component, which will obviously cause confusion.
  • Multiple projects divide each component into separate projects, and code permissions can be clearly controlled. During integration testing, you can integrate through maven reference. Business components and business basic components can also be reused for other projects of the company like basic components.

Note that I use a multi engineering solution in the Demo, and Send ARR to JitPack warehouse , this is for the convenience of demonstration, and sending it to the company's private Maven warehouse is the same meaning. 1. You need to add JitPack repository address in build.gradle under the root directory: maven {URL ' jitpack.io' } ; 2. JitPack is a custom Maven repository, but its process is extremely simplified. You only need to enter the Github project address to publish the project.

Interpretation of open source framework based on design ideas

Chapter I thermal repair design


The second chapter is the design of plug-in framework

Interview review route, sort out knowledge and improve reserves

How well you prepare your knowledge directly determines whether you can successfully pass one and two sides. Therefore, it is necessary to sort out your knowledge before the interview to see whether you need to improve your knowledge reserve.

With regard to knowledge sorting, I would like to share my review route during the interview: (I collected and sorted out the review materials of the following system from various leaders)

CodeChina open source project: Android learning notes summary + mobile architecture Video + big factory interview real questions + project actual combat source code

  • Necessary skills for architects to build foundations
  • Android advanced UI and FrameWork source code
  • 360 ° performance tuning
  • Interpretation of open source framework design ideas
  • NDK module development
  • Wechat applet
  • Hybrid development and fluent

After sorting out the knowledge, it is necessary to check and fill in the gaps. Therefore, for these knowledge points, I have prepared a lot of e-books and notes on hand, which perfectly summarize each knowledge point:

"960 most complete Android Development Notes in the whole network"

379 pages of Android development interview

For half a year, we sorted out the most comprehensive analysis of Android interview questions on the market
It includes the questions asked in the interview of front-line Internet companies such as Tencent, Baidu, Xiaomi, Ali, LETV, meituan, 58, cheetah, 360, Sina and Sohu. Familiarity with the knowledge points listed in this article will greatly increase the probability of passing the first two rounds of technical interviews.

How to use it?

1. You can directly look through the required knowledge points through the directory index to find out omissions and fill vacancies.
2. The number of five pointed stars indicates the frequency of interview questions and represents the important recommendation index

507 page Android development related source code analysis

As long as programmers, whether Java or Android, don't read the source code and only look at the API documents, they will just stay superficial, which is unfavorable to the establishment and completion of our knowledge system and the improvement of practical technology.

To the topic. Familiarity with the knowledge points listed in this article will greatly increase the probability of passing the first two rounds of technical interviews.

How to use it?

1. You can directly look through the required knowledge points through the directory index to find out omissions and fill vacancies.
2. The number of five pointed stars indicates the frequency of interview questions and represents the important recommendation index

[external chain picture transferring... (img-plh55zei-16310778426)]

507 page Android development related source code analysis

As long as programmers, whether Java or Android, don't read the source code and only look at the API documents, they will just stay superficial, which is unfavorable to the establishment and completion of our knowledge system and the improvement of practical technology.

What can really exercise your ability is to read the source code directly, not only limited to reading the source code of major systems, but also various excellent open source libraries.

Tags: Android Design Pattern

Posted on Tue, 23 Nov 2021 19:23:21 -0500 by achilles