The following script 100% can be used as long as your version and path are configured correctly
Environment: Eclipse Windows 7
gradle:2.3
The Android project contains multiple library
Main project configuration:
Settings.gradle File Configuration Library
Include ' lib_01 ' include ' lib_02 ' Project (': lib_01 '). ProjectDir = new File (' D:\\pj1 ') Project (': lib_02 '). ProjectDir = New File (' D:\\pj2 ')
The library name corresponds to the project path of the library, of course, if you can use relative paths with the main project
Build.gradle Content
Buildscript {repositories {jcenter ()} dependencies {classpath ' com.android.tools.build:gradle:1 .1.2 '}}apply plugin: ' Com.android.application ' android {compilesdkversion buildtoolsversion ' 19.1.0 ' l intoptions {Abortonerror false} sourcesets {main {manifest.srcfile ' androidmanif Est.xml ' java.srcdirs = [' src '] resources.srcdirs = [' src '] res.srcdirs = [' res '] Assets.srcdirs = [' Assets ']}}signingconfigs {release {StoreFile file ("D:\\my.keystore" ) Storepassword "112233" Keyalias "test" Keypassword "112233"}} buildtypes {release {signingconfig signingconfigs.release minifyenabled true proguardfile ' Proguar D.txt '}}}dependencies {Compile files (' Libs/ftp4j-1.7.2.jar ', ' Libs/mymap.jar ') Compile project (': l Ib_01 ') Compile ProjecT (': lib_02 ')}
The path of confusion is also the same. Typically, the Proguard.txt is configured under the main project, but the file does not need to add--libraryjars this thing, otherwise you will be quoted the Jar 2 times twice
Compile project corresponds to compiling the 2 library libraries above
2 dependent libraries also require a build.gradle, each dependent on the library project requires a build.gradle.
Content:
Buildscript { repositories { jcenter () } dependencies { classpath ' com.android.tools.build: gradle:1.1.2 ' }}apply plugin: ' Android-library ' android { compilesdkversion buildtoolsversion ' 19.1.0 " defaultconfig { minsdkversion targetsdkversion } sourcesets { main { Manifest.srcfile ' androidmanifest.xml ' jnilibs.srcdirs = [' Libs '] java.srcdirs = [' src '] Resources.srcdirs = [' src '] aidl.srcdirs = [' src ' ] renderscript.srcdirs = [' src '] res.srcdirs = [' res '] assets.srcdirs = [' Assets '}}}
When the project is packaged, it finds the AAR that relies on the library to process the build, and the APK files are all in the Build/output directory.
Jnilibs.srcdirsis used to process the so module files.
Note: The default situation is that there is no activity in the Androidmanifest.xml file in the project. If please remove (this place does not study how to avoid multiple manifest problems)
The dependent file should be empty.
<manifest xmlns:android= "http://schemas.android.com/apk/res/android" package= "MY.MOBILE.PACKAGE01" > <uses-sdk android:minsdkversion= "9" android:targetsdkversion= "/> <application" android:allowbackup= "true" android:icon= "@drawable/app_icon" > </application></ Manifest>
Download the Gradle first configure the environment variables
In the main project
Perform gradle tasks
Perform Gradle Build
Gradle although convenient, but gradle have version incompatibility problem, and need to download the relevant library and jar files, only need to keep trying, go to http://stackoverflow.com/above generally can know to find the answer.
Android uses Gradle for packaging confusion, including relying on library