I have a problem with building release app with Proguard enabled. Building is stuck with executing the task :app:transformClassesAndResourcesWithProguardForRelease which takes for more than 40 minutes!
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile('com.github.afollestad.material-dialogs:core:0.8.5.5@aar') {
transitive = true
}
apt 'com.jakewharton:butterknife-compiler:8.0.1'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:support-v4:24.2.0'
compile 'com.android.support:percent:24.2.0'
compile 'com.android.support:recyclerview-v7:24.2.0'
compile 'com.android.support:cardview-v7:24.2.0'
compile 'com.google.android.gms:play-services-appindexing:9.4.0'
compile 'com.google.android.gms:play-services-analytics:9.4.0'
compile 'com.instabug.library:instabug:2.6.1'
compile 'net.hockeyapp.android:HockeySDK:4.1.0'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.squareup.okhttp:logging-interceptor:2.6.0'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.jakewharton:butterknife:8.0.1'
compile 'com.mobsandgeeks:android-saripaar:2.0.3'
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
compile 'joda-time:joda-time:2.8.2'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'info.hoang8f:android-segmented:1.0.6'
compile 'com.pnikosis:materialish-progress:1.7'
compile 'hanks.xyz:smallbang-library:0.1.2'
compile 'com.jzxiang.pickerview:TimePickerDialog:1.0.1'
}
What can be the cause of this mess?
Thanks!
Well you have a lot of libraries, despiste the commentary above solved your problem, there's some tips to help work with a lot of libraries.
On your App->build.gradle
defaultConfig {
....
multiDexEnabled true // add this
}
productFlavors {
// Define separate dev and prod product flavors.
dev {
// dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
// to pre-dex each module and produce an APK that can be tested on
// Android Lollipop without time consuming dex merging processes.
minSdkVersion 21
}
prod {
// The actual minSdkVersion for the application.
minSdkVersion 17
}
}
Hope it helps
In my case, it happens for proguard-rules.pro so I hide all the rule and use this configuration on my build.gradle file and it's works for me.
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
defaultConfig {
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
My build was that long that I could not wait for it to finish, it was longer than 2 hours. It stuck on this build task and my solution was to clean local repository :
git clean -xfd
After that, I managed to build normally (in less than 5 minutes).
我只是在 Android Studio 上使用 Clean Project:“Build > Clean Project”
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.