91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

eclipse下使用MultiDex解決65536限制

發布時間:2020-06-10 18:38:08 來源:網絡 閱讀:7145 作者:破軍少帥 欄目:移動開發


eclipse下使用MultiDex解決65536限制

 

 

采用Android dex分包方案解決,步驟如下:

 

一、安裝gradle 

 

1.1、下載gradle-2.2.1-bin.zip (也可以使用最新的gradle版本)

         (https://services.gradle.org/distributions/gradle-2.2.1-bin.zip) 

1.2、解壓到安裝目錄 

         如:D:\WorkInstall\gradle-2.2.1

         eclipse下使用MultiDex解決65536限制

1.3、配置環境變量  

         GRADLE_HOMEpath

         eclipse下使用MultiDex解決65536限制

        

         eclipse下使用MultiDex解決65536限制

1.4、驗證環境變量 

         打開 cmd 輸入 gardle -v,如下環境配置成功

         eclipse下使用MultiDex解決65536限制

 

 

 

二、配置Android SDK

 

2.1、生成 build.gradle 配置文件:

         打開eclipse,選擇主工程,右鍵 -->Ecport --> Generate Gradle build files ,選擇主工程    以及相關的工程,Finish

         eclipse下使用MultiDex解決65536限制

         eclipse下使用MultiDex解決65536限制

 

2.2、配置 build-tools

         打開 build.gradle,查看屬性 buildToolsVersion,進入 sdk/build-tools/,選擇對應的版本。

         eclipse下使用MultiDex解決65536限制

        

         進入sdk/extras/android/support/,把 multidex 文件夾復制到 sdk/build-tools/21.1.2/錄下。

         eclipse下使用MultiDex解決65536限制

 

2.3、配置子工程 build.gradle 文件

         1 workspace配置:

         打開 workspace,里面會有build.gradle settings.gradle. 配置如下

         build.gradle:

         注意:gradle 版本對應的Android配置(2.2.1-----對應 0.14+,具體的對應可以查看google     文檔)。

         //Top-level build file where you can add configuration options common to all     sub-projects/modules.

         buildscript{

               repositories {

                mavenCentral()

               }

               dependencies {

         classpath'com.android.tools.build:gradle:0.14.+'

               }

         }

         settings.gradle:【主要是工程配置】

         include':google-play-services_lib'

         include':easy3d-myshare-core-magic'

         include':magic-finger-china'

         include':pulltorefresh-library'

         include':android-support-v7-recyclerview'

         include':ImageViewTextEdit-library'

         include':ImageViewZoom-library'

        

         2每個子工程 build.gradle 配置:

         首先,給每個子工程添加 local.properties 文件,文件內容:sdk.dir=Android SDK路徑)

         sdk.dir=D\:\\WorkInstall\\sdk

         eclipse下使用MultiDex解決65536限制

        

         build.gradle:(子工程的 build.gradle配置都一樣)

         applyplugin: 'android-library'

        

         dependencies{

              compile fileTree(dir: 'libs', include:'*.jar')

         }

        

         android{

              compileSdkVersion 22

        buildToolsVersion"21.1.2"

           enforceUniquePackageName=false

        

           defaultConfig {

                   minSdkVersion14

                   targetSdkVersion19 

                  

                 //Enabling multidex support.

                   multiDexEnabledtrue

           }

        

           dexOptions {

                   preDexLibraries= false

           }

           lintOptions { 

                   abortOnErrorfalse 

        }

        

              sourceSets {

                 main{

                       manifest.srcFile 'AndroidManifest.xml'

                       java.srcDirs = ['src']

                       resources.srcDirs = ['src']

                       aidl.srcDirs = ['src']

                       renderscript.srcDirs = ['src']

                       res.srcDirs = ['res']

                       assets.srcDirs = ['assets']

                 }

                  

                 //Move the tests to tests/java, tests/res, etc...

                 instrumentTest.setRoot('tests')

                  

                 //Move the build types to build-types/<type>

                 //For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml,...

                 //This moves them out of them default location under src/<type>/... whichwould

                 //conflict with src/ being used by the main source set.

                 //Adding new build types or product flavors should be accompanied

                 //by a similar customization.

                 debug.setRoot('build-types/debug')

                 release.setRoot('build-types/release')

              }

         }

 

2.4、配置主工程 build.gradle 文件

        

         applyplugin: 'android'

         dependencies{

              compile fileTree(dir: 'libs', include:'*.jar')

              compileproject(':android-support-v7-recyclerview')

              compile project(':easy3d-myshare-core-magic')

              compile project(':google-play-services_lib')

              compile project(':pulltorefresh-library')

              compile project(':ImageViewTextEdit-library')

   

              compile'com.android.support:support-v4:23.1.0'

           compile 'com.android.support:multidex:1.0.0'

          

           compile(project(':android-support-v7-recyclerview')){

                   excludemodule: 'support-v4'

           }

         }

 

         android{

              compileSdkVersion 22

              buildToolsVersion "21.1.2"

 

           packagingOptions {

             exclude 'META-INF/DEPENDENCIES.txt'

             exclude 'META-INF/LICENSE.txt'

             exclude 'META-INF/NOTICE.txt'

             exclude 'META-INF/NOTICE'

             exclude 'META-INF/LICENSE'

             exclude 'META-INF/DEPENDENCIES'

             exclude 'META-INF/notice.txt'

             exclude 'META-INF/MANIFEST.MF'

             exclude 'META-INF/license.txt'

             exclude 'META-INF/dependencies.txt'

           }

           configurations {

                     all*.exclude module: 'support-v4'

           }

           dexOptions {

                   preDexLibraries= false

           }

           lintOptions { 

                   abortOnErrorfalse 

        }

              compileOptions {

                 sourceCompatibilityJavaVersion.VERSION_1_7

                 targetCompatibilityJavaVersion.VERSION_1_7

              }

 

           defaultConfig {

                   minSdkVersion14

                   targetSdkVersion19 

                  

                 //Enabling multidex support.

                   multiDexEnabledtrue

           }

           // 打包的簽名信息(storeFile 簽名文件的路徑)

           signingConfigs {  

                myrelease {  

                               keyAlias'magic_finger.keystore'

                            keyPassword'magic_finger_20150724'

                            storeFilefile('magic_finger.keystore')

                            storePassword'magic_finger_20150724'

                   }

           }

        

           buildTypes {

                   release{

                            //混淆

                            minifyEnabledtrue

                            //Zipalign優化

                               //zipAlignEnabledtrue

                               //移除無用的resource文件

                               //shrinkResourcestrue

                            //proguardFile getDefaultProguardFile('proguard-android.txt')

                            //加載默認混淆配置文件 progudard-android.txtsdk目錄里面,                                     //proguard.cfg是我們自己配的混淆文件

            proguardFilesgetDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'

                            signingConfigsigningConfigs.myrelease                           

                 }

           }

        

     sourceSets {

        main {

            manifest.srcFile'AndroidManifest.xml'

            java.srcDirs = ['src']

            resources.srcDirs = ['src']

            aidl.srcDirs = ['src']

            renderscript.srcDirs = ['src']

            res.srcDirs = ['res']

            assets.srcDirs = ['assets']

              jniLibs.srcDirs= ['libs']

        }

 

        // Move the tests to tests/java,tests/res, etc...

        instrumentTest.setRoot('tests')

 

        // Move the build types tobuild-types/<type>

        // For instance,build-types/debug/java, build-types/debug/AndroidManifest.xml, ...

        // This moves them out of them defaultlocation under src/<type>/... which would

        // conflict with src/ being used by themain source set.

        // Adding new build types or productflavors should be accompanied

        // by a similar customization.

        debug.setRoot('build-types/debug')

        release.setRoot('build-types/release')

     }

        

         afterEvaluate{

                   tasks.matching{

                            it.name.startsWith('dex')

                   }.each{ dx ->

                            if(dx.additionalParameters == null) {

                                     dx.additionalParameters= ['--multi-dex']

                            }else{

                                     dx.additionalParameters+= '--multi-dex'

                            } 

                   }

           }

         }

 

2.4、添加 android-support-multidex.jar

         android-support-multidex.jar(sdk\extras\android\support\multidex\library\libs)引入到   工程中。 

         (注:最好放在referenced libraies中,而不是放在libs下,這樣避免buildjar包重復

         同樣,以相同的方式把 android-support-v4.jar 添加進去(PS:這里出現了 duplicate entry: com/nineoldandroids/animation/Animator$AnimatorListener.class

         eclipse下使用MultiDex解決65536限制

 

2.5 配置MultiDexApplication

         然后在Application中覆蓋方法attachBaseContext 

         注:這里有三種方式: android.support.multidex.MultiDexApplication

         a.AndroidManifest.xmlapplication中聲明MultiDexApplication;

         b.如果你已經有自己的Application類,讓其繼承MultiDexApplication 

     c.如果你的Application類已經繼承自其它類,那么可以重寫attachBaseContext()方法: 

         根據自身情況選擇一種方式。

 

 

三、打包apk

         完成之后,可以開始打包了。

         cmd,進入工程所在的目錄,輸入:gradle build --stacktrace,最終Build successful為止。

         打開apk包,可以看見.dex被分成了多。

         eclipse下使用MultiDex解決65536限制

         eclipse下使用MultiDex解決65536限制

 

五、常見問題:

以上步驟會出現一些問題,目前的解決方案如下:

5.1SDK location not found. Define location with sdk.dir in thelocal.properties file or with an ANDROID_HOME environment variable.

         請檢查所有工程里面是否包含了 local.properties,且 sdk.dir 是否配置正確

 

5.2java.util.zip.ZipException: duplicate entry:xxxx.class

         一定是jar沖突了,可能是多個project中都引入了相同的jar,需要剔除掉重復的jar

 

5.3Execution failed for task ':magic-finger-china:packageRelease'.

         這個是簽名文件不對,請檢查

         eclipse下使用MultiDex解決65536限制

 

 

5.4Failed to shrink resources: java.util.zip.ZipException: invalidentry compressed

 size(expected 4017 but got 4081 bytes); ignoring

         去掉混淆文件里面 zippalignEnable true.

 

5.5、Error:Execution failed for task ':app:proguardDemoRelease'.

> java.io.IOException: The same input jar xxxx is specified twice.

         proguard.cfg 文件,打開,并去掉所有的 -libraryjars libs/xxxx;

 

 

 

 

 

 

 

 

 

 


附件:http://down.51cto.com/data/2366261
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

长泰县| 仁布县| 陆川县| 怀仁县| 平度市| 望都县| 福安市| 灵武市| 东至县| 攀枝花市| 镇雄县| 蕲春县| 维西| 黎城县| 金溪县| 洛川县| 东光县| 天长市| 寿宁县| 兰坪| 徐州市| 伽师县| 威宁| 图们市| 化州市| 湘潭市| 广昌县| 长宁区| 依安县| 南昌市| 孟连| 隆子县| 胶南市| 新沂市| 莎车县| 彝良县| 揭阳市| 镇赉县| 白银市| 丰镇市| 绥宁县|