2017-03-31 37 views
1

這是更多的建議對我的build.gradle所做的更改,因爲我即將發佈我的第一個android應用程序。但沒有令人滿意的solution.Here是我gradle這個文件在發佈我的android應用程序到生產之前,我應該在我的build.gradle中做什麼更改

buildscript { 
repositories { 
    maven { url 'https://maven.fabric.io/public' } 
} 

dependencies { 
    classpath 'io.fabric.tools:gradle:1.+' 
} 
} 
apply plugin: 'com.android.application' 
apply plugin: 'io.fabric' 

repositories { 
maven { url 'https://maven.fabric.io/public' } 
} 


android { 
compileSdkVersion 25 
buildToolsVersion "25.0.2" 
defaultConfig { 
    applicationId "com.example.app" 
    minSdkVersion 19 
    targetSdkVersion 25 
    multiDexEnabled true 
    versionCode 1 
    versionName "1.0" 
    resConfigs "en_US", "hi_IN" 
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
} 
buildTypes { 
    release { 
     minifyEnabled true 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 
packagingOptions { 
    exclude 'META-INF/LICENSE' 
    exclude 'META-INF/DEPENDENCIES' 
    exclude 'META-INF/LICENSE-FIREBASE.txt' 
    exclude 'META-INF/NOTICE' 
} 

} 

dependencies { 
compile fileTree(dir: 'libs', include: ['*.jar']) 
compile('com.digits.sdk.android:digits:[email protected]') { 
    transitive = true; 

} 
compile('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
    transitive = true; 
} 
compile('io.fabric.sdk.android:fabric:[email protected]') { 
    transitive = true; 
} 
compile 'com.android.support:multidex:1.0.1' 
compile 'com.android.support:appcompat-v7:25.3.1' 
compile 'com.android.support:customtabs:25.3.1' 
compile 'com.android.support:support-v13:25.3.1' 
compile 'com.android.support:design:25.3.1' 
compile 'com.android.support:gridlayout-v7:25.3.1' 
compile 'com.android.support:cardview-v7:25.3.1' 
compile 'com.android.support:recyclerview-v7:25.3.1' 
compile 'com.android.support:support-annotations:25.3.1' 
compile 'de.hdodenhof:circleimageview:1.3.0' 
compile 'com.github.bumptech.glide:glide:3.7.0' 
compile 'com.google.code.gson:gson:2.7' 
compile 'com.google.android.gms:play-services-location:10.2.1' 
compile 'com.google.android.gms:play-services-places:10.2.1' 
compile 'com.google.firebase:firebase-database:10.2.1' 
compile 'com.google.firebase:firebase-core:10.2.1' 
compile 'com.google.firebase:firebase-auth:10.2.1' 
compile 'com.google.firebase:firebase-messaging:10.2.1' 
compile 'com.google.firebase:firebase-crash:10.2.1' 
compile 'com.firebaseui:firebase-ui-database:1.2.0' 
compile 'com.google.firebase:firebase-storage:10.2.1' 
compile 'com.google.firebase:firebase-appindexing:10.2.1' 
compile ('io.branch.sdk.android:library:2.5.9') { 
    transitive = true; 
    exclude module: 'answers-shim'; 
} 

} 
apply plugin: 'com.google.gms.google-services' 

的每一個建議事項,也可能是其他的初學者和我一樣誰正計劃推出他們的第一個構建在Play商店的幫助。

回答

0

我可以看到你已經在你的發佈模式中啓用了職業警衛。我建議你考慮從android doc下面的語句

對於更多的代碼縮小,請嘗試位於相同位置的proguard-android-optimize.txt文件。它包含相同的ProGuard規則,但其他優化可在字節碼級別(內部和各種方法)執行分析,從而進一步縮小APK大小並幫助其更快運行。

改變這種

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

這個

proguardFiles getDefaultProguardFile('**proguard-android-optimize.txt**'), 'proguard-rules.pro' 

同時添加這爲發佈模式

shrinkResources true 

而且不要忘了加親衛隊的規則,如果你還沒有。

做以上兩件事情會讓你的應用程序體積變小並且更加優化。

+0

親職守規則?如何在我的文件中定義它們。 – Shubhendra

+0

@Shubhendra你需要在你的程序的proguard-rules.pro文件中定義它們。如果你不知道它們,你需要閱讀它們。這裏是鏈接到proguard官方手冊。 https://www.guardsquare.com/en/proguard/manual/usage。如果有幫助,請將我的答案標記爲已接受。 –

+0

明白了@ v4_adi,並且我也檢查了有關職業守則規則的firebase文檔。乾杯:-) – Shubhendra

相關問題