Gradle provides guidance on compiling multiple projects (including multi-Library Project dependencies) and gradlelibrary

Source: Internet
Author: User

Gradle provides guidance on compiling multiple projects (including multi-Library Project dependencies) and gradlelibrary

Gradle Android's latest automated compilation script tutorial (demo source code is provided)

In this article, I wrote a simple example of android project and android library compilation based on Gradle2.1. Some netizens asked me if I support multi-library compilation. My reply is yes, for details, see the following guide:


In actual development there are a lot of projects reference android-support-v4.jar or other jar package resources;

Sometimes it's okay to put the android-support-v4.jar in libs of every library and compile and run it in eclpse, because you can compile the redundant jarexclud settings but execute gradle build outside, A duplicate jar package is displayed.



Solution:

In eclipse, we can create a project for the public jar package. Other library libraries reference this jar package library and then be referenced by the main project;

In this case, you must set the following settings in build. gradle in each library project:

dependencies{compile fileTree(dir:'libs',include:"*.jar")compile project(':DependLibs:appcompat_v7')}

This seems to be quite correct, but it is still wrong to think about it carefully, because each referenced database has compiled the public jar Library to the compilation reference, and finally a conflict will be prompted.


Correct writing is as follows:

dependencies{compile fileTree(dir:'libs',include:"*.jar")//compile project(':DependLibs:appcompat_v7')compile 'com.android.support:support-v4:20.0.0'}

Another incorrect method

dependencies{compile fileTree(dir:'libs',include:"*.jar")//compile project(':DependLibs:appcompat_v7')compile 'com.android.support:support-v4:20'}

Are there any differences between the two statements?


Prompt you cannot find cocould not find com. android. support: support-v4: 20


If this problem occurs, first look at it:



Android Support Respository and Andoid Support Library in the Extras package of Android sdk are Installed. If

You can go to the following directory to find D: \ dev \ adt-bundle-windows-x86-20140702 \ sdk \ extras \ android \ m2repository \ com \ android \ support \ support-v4 \ 255.0.0




Find it and start building.




Many slidingmenu_library references, and the viewPagerlibrary project has been compiled.


If you have any questions, please contact me (QQ group:221057495).



Multiple Linux dynamic library dependencies and compilation problems

This can only indicate one problem. The library you are dependent on has a problem and you have not added all its dependencies, that is, ① libb in your example. so depends on liba. so;, you should generate libb. in so. so dependencies should be added.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.