当前位置:网站首页>About the project error reporting solution of mpaas Pb access mode adapting to 64 bit CPU architecture

About the project error reporting solution of mpaas Pb access mode adapting to 64 bit CPU architecture

2022-07-05 04:04:00 High calcium Xiaoxin

background :

2021 At the end of the year , Domestic manufacturers began to vigorously promote the application market app Conduct 64 Adaptation of bit architecture , And issued relevant regulations , The approximate time is 2022 year 2 Not received from the beginning of the month, only 32 Bit application ,9、10 Receiving containing... Is not supported from the beginning of the month 32 Bit application .

The mobile phones we use are now multi-core CPU, In order to be compatible with as many applications as possible , At present, it is compatible with the kernel 32 Bit applied , This leads to a part of non adaptation 64 The application of bit architecture is still used 32 Bit instruction set , No play 64 position CPU The advantages of , In terms of performance , Operational efficiency , In terms of user experience , Did not conform to the development of the times .

last year arm Launched armv9 Of CPU framework , This new architecture eliminates the super core and medium core for 32 Compatibility of bit applications .

New snapdragon 8 Gen 1 The processor uses the latest armv9 framework ,8 In two cores , Yes 3 individual 2.5GHz Of A710 Big nucleus 、1 individual 3.0GHz Of X2 Meganucleus and 4 individual 1.8GHz Of A510 Median nucleus . If an application doesn't do 64 Bit adaptation , Then you can only use 3 Kernel , When we develop, we often open multiple threads to do some time-consuming operations , So for this 8 Nuclear cell phones only use 3 nucleus The situation of , It's really unacceptable .

Preface :

An zhuozuo 64 Bit architecture adaptation is actually very simple , I wrote a summary before , You can turn it forward if you need it . This article is mainly based on the current architecture of the project (mPaaS frame ,Portal-Bundle Access mode ) Some problems and solutions encountered during adaptation .

The project USES mPaaS Framework of the Portal-Bundle Access mode , For some historical reasons , At first, this mode only supports gradle 4.4 edition , Many conflicts have escalated this time gradle To 6.2 after , The inspection rules are stricter , There are many problems caused by the irregular usage of old projects .

Here is a summary , Also give it to the partners who need it .

One 、64 Bit architecture adaptation

(1) One is upgrading gradle To 6.2 edition ( Can be higher , But stricter inspection rules will expose more problems ), For details, you can refer to this document
mPaaS Support more CPU framework - Mobile development platform mPaaS - Alibaba cloud
(2) A new version of gradle plug-in unit , Also need to adapt mPaaS Plug in related content
common problem - Mobile development platform mPaaS - Alibaba cloud

Two 、 Solve the compilation error

1、 Report errors  Cannot change dependencies of dependency configuration ':api:provided' after it has been included in dependency resolution, Pictured :

 

reason : The official documents say that there is no need to introduce it again android gradle plug-in unit , Just introduce mPaaS gradle Just plug in , But in practice , If it is not introduced, the error shown in the figure above will be reported .

 

solve : introduce android gradle Official plugin

 

notes : In many old projects , Most of them use provided 、compile And other abandoned dependency methods , Just take this opportunity , Replace all these .( The difference in usage is Baidu by ourselves )

provided ----> compileOnly

compile -----> api / implementation

2、 Report errors  android-apt plugin is incompatible with the Android Gradle plugin. Please use 'annotationProcessor'

reason : This mistake should also be caused by a change in usage

solve

(1) adopt apt Relying on third parties

// apt 'org.androidannotations:androidannotations:4.4.0'
// Change to 
annotationProcessor 'org.androidannotations:androidannotations:4.4.0'

(2) root directory build.gradle Under the use of  

//classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// This needs to be deleted or commented out 

(3)build.gradle Is cited in   'android-apt' The plug-in

//apply plugin: 'android-apt'
// This usage should also be deleted 

3、 Report errors  Could not find the AndroidManifest.xml file, using  generation folder 

reason : The project relies on org.androidannotations:androidannotations:4.4.0 This library . I don't know the specific principle

solve

(1) Reduce gradle Version of ( We upgraded just for adaptation gradle 4.4 To 6.2 , So it's not feasible )

(2) stay build.gradle in defaultConfig Add the following code , Which one? moudle Depend on which moudle Medium plus

android {
    defaultConfig {
      
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = [
// 'resourcePackageName': "com.mobile.mbank.search",
"androidManifestFile": "$projectDir/src/main/AndroidManifest.xml".toString()
                ]
            }
        }
    }

}

I commented out the line of configuring the package name above , It will cause other errors , Configure only androidmanifest.xml It can also solve my current compilation error .

4、 Report errors  The SourceSet 'flatDir' is not recognized by the Android Gradle Plugin. 

reason : I don't know why other development is in sourceSets The following is used flatDir , I checked and found no such usage , As for why I didn't report errors before , I don't know , Just change to the correct usage .

solve

sourceSets {
        flatDir {
            assets.srcDirs = ['../api/src/main/assets']
        }
    }
//  Change to the following 
sourceSets {
        main {
            assets.srcDirs = ['../api/src/main/assets']
        }
    }

5、 Report errors  error: item inner element must either be a resource reference or empty.

reason : gradle The resource format verification is more stringent

solve

<item type="id" name="about_process_icon">false</item>
//  Change to the following 
<item type="id" name="about_process_icon"/>

For other resource format issues, please refer to the following article of the boss , I also read his article to change

solve error: item inner element must either be a resource reference or empty._ A bowl of single fried rice column -CSDN Blog Error description error: < item> inner element must either be a resource reference or empty. The new version of the Gradle The verification of resource format has become strict, so the above error solutions appear. Examples of tag content quoting other content and reporting errors :<array name="server"> <item name="host">1...https://blog.csdn.net/djzhao627/article/details/105640432

6、 Report errors  Caused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: com.xxxx.xxx.xxx

reason : The third party depends on the repeated reference of packages . Because there are many bundle project , Plus the developers' non-standard operation in the early stage , It will eventually lead to the integration of multiple bundle When packing , There is a conflict of repeated dependencies of the same third-party library , Even the conflict of dependencies under different third-party libraries ( This is more troublesome ).

solve

(1) If it is only in the current bundle The use of , Use as much as possible compileOnly The way , It can avoid dependency conflicts during packaging to the greatest extent .

(2) Try to unify the third-party dependencies into one bundle Manage , adopt api moudle Use compile Way for others bundle Provides access to .

(3) If there is a dependency conflict between different third-party libraries , Can pass gradle dependencies Command to check which libraries are in conflict , Then remove the dependency . Specific methods can be Baidu .

原网站

版权声明
本文为[High calcium Xiaoxin]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140712561855.html