We need to combine two apps to add a feature to the original project. Project A and project B are as follows:
In the beginning, we separate project B into a module, and then, as a library, it is called to project A.
The problem is that the application, activity and duplicate packages already exist in Project B, how does this need to be solved?
The application of Project B can be combined with the application of project A, but the activity needs to be managed, and the problem is that only the major projects have activity. There is no ordinary project??
Later, due to the lack of certainty, it is still the traditional method, the direct separation of Project B, the resource files in res, Java files placed in the src,application merged together, Androidmanifest merged together.
1. The main problems encountered are:
(1) Due to the introduction of the third-party library minimum supported version is higher than the minimum supported version of Project A, you will be prompted:
Error:execution failed for task ': App:processdebugmanifest '.
> Manifest merger failed:uses-sdk:minsdkversion 8 cannot be smaller than version 9 declared in library [jp.wasabeef:b lurry:1.0.0]/users/xxx/xxx/app/build/intermediates/exploded-aar/jp.wasabeef/blurry/1.0.0/androidmanifest.xml
Suggestion:use tools:overridelibrary= "Jp.wasabeef.blurry" to force usage
Solution: Increase the minimum supported version of a third-party library, or reduce the minimum supported version of project A, or use using Tools:overridelibrary = "Xxx.xxx.xxx" as prompted to resolve the issue
(2) because the imported jar packages are duplicated, you will be prompted:
Solution: Locate the duplicate package, and then delete the
(3) because there is not enough memory allocated to the application, there is a
Exception in thread "main" Java.lang.OutOfMemoryError:GC overhead limit exceeded
Solution: Added a build.gradule in the
Dexoptions{javamaxheapsize "2g"}
(4) All of theApp 's code is in a dex file, and Dex's method number is controlled from 0 to 65536, and if Dex has too many methods, it will not work. Therefore, according to the official statement, a. In the defaultconfig of Gradule.gradule is added
multidexenabled true
B. Add this paragraph to the application (before the method has been separated, and then need to merge to the same application)
@Override
protected void Attachbasecontext (Context base)
{
Super.attachbasecontext (base);
Multidex.install (this);
}
The main problem, also as above, on the whole, for Android Studio A lot of understanding, such as shortcut keys, Gradule, module, project, debugging use, are unfamiliar, need to gradually upgrade their Android Studio Awareness (can refer to the official documentation for more information)
Two apps Merge