Build failed while builing in release mode - android

I am trying to generate signed build but it shows the below error:
Warning:there were 87 unresolved references to classes or interfaces.
You may need to add missing library jars or update their versions.
If your code works fine without the missing classes, you can suppress
the warnings with '-dontwarn' options.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Warning:there were 2 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile the code.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)
Exception while processing task
java.io.IOException: Please correct the above warnings first.
at proguard.Initializer.execute(Initializer.java:473)
at proguard.ProGuard.initialize(ProGuard.java:233)
at proguard.ProGuard.execute(ProGuard.java:98)
at proguard.gradle.ProGuardTask.proguard(ProGuardTask.java:1074)
at com.android.build.gradle.tasks.AndroidProGuardTask.doMinification(AndroidProGuardTask.java:139)
at com.android.build.gradle.tasks.AndroidProGuardTask$1.run(AndroidProGuardTask.java:115)
at com.android.builder.tasks.Job.runTask(Job.java:48)
at com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41)
at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:227)
at java.lang.Thread.run(Thread.java:745)
:app:dexRelease
:app:crashlyticsStoreDeobsRelease
:app:crashlyticsUploadDeobsRelease
:app:validateExternalOverrideSigning
:app:packageRelease FAILED
Error:Execution failed for task ':app:packageRelease'.
> Unable to compute hash of D:\Project\AppLocker\app\build\intermediates\classes-proguard\release\classes.jar
Information:BUILD FAILED
Information:Total time: 5.629 secs
Information:1 error
Information:62 warnings
Information:See complete output in console
I tried rebuild/clean build option but still I am getting the same error everytime.
My project has following dependencies:
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:preference-v7:23.1.1'
compile 'com.android.support:preference-v14:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:palette-v7:23.1.1'
compile 'com.cocosw:bottomsheet:1.+#aar'
compile 'com.github.paolorotolo:appintro:3.2.+'
compile 'com.pnikosis:materialish-progress:1.7'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
Please suggest how to fix the above issue. Thanks.

It looks like ProGuard may be stripping out the classes that your build relies on. Try doing a release build with ProGuard disabled (minifyEnabled false) and see if that works. If this works then you need to configure your ProGuard rules to not strip out the types your code relies on.

I solved the issue by adding -ignorewarnings at the top of my proguard rule file.

Try adding packagingOptions to the gradle, try cleaning the project,delete the build folder and rebuild again,Specify all the jar files u have used in gradle.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.package"
minSdkVersion 15
targetSdkVersion 23
versionCode 6
versionName "2.0.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
}

Related

Android studio build error after update to v 3.0

Got prompted for an update and let it do its thing and got these errors everything worked fine before the update.
Information:Gradle tasks [:app:generateDebugSources,
:app:generateDebugAndroidTestSources, :app:mockableAndroidJar,
:app:compileDebugAndroidTestSources, :app:compileDebugUnitTestSources,
:app:compileDebugSources]
/Users/.../topografie/activity/FlashCardActivity.java
Error:(60, 14) error: cannot find symbol method
addOnPageChangeListener()
/Users/.../topografie/activity/MainActivity.java
Error:(87, 14) error: cannot find symbol method
addOnPageChangeListener(OnPageChangeListener)
/Users/.../topografie/activity/MuscleDetailActivity.java
Error:(58, 14) error: cannot find symbol method
addOnPageChangeListener()
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details. Information:BUILD FAILED in 2s Information:4 errors Information:0
warnings Information:See complete output in console
Gradle console says:
symbol: method addOnPageChangeListener(OnPageChangeListener)
location: variable pager of type ViewPager Note:
/Users/.../MuscleDetailActivity.java uses unchecked or unsafe
operations. Note: Recompile with -Xlint:unchecked for details. 1 error
I've come across several similar questions, but none of the answers worked for me. I've cleaned and rebuild the project and I updated all the dependencies in Gradle. EDIT: Gradle syncs fine, but the project build gives error
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.anatomie.bny.topografie"
minSdkVersion 17
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile files('libs/android-support-v13.jar')
compile files('libs/picasso-2.5.2.jar')
compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:support-vector-drawable:26.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:26.1.0'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
compile 'com.github.AndroidDeveloperLB:AutoFitTextView:4'
testCompile 'junit:junit:4.12'
}
Please help, I've been at it for hours and can't find a solution
Delete .gradle and .idea folder
And REBUILD
If that doesn't work, again delete .gradle and .idea folder
and RESTART
You can try my answer. And also restart Android Studio after following these steps.
Change the plugin version in your project-level build.gradle file as follows:
buildscript {
repositories {
...
// You need to add the following repository to download the
// new plugin.
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
then Rebuild project

Error:com.android.builder.dexing.DexArchiveBuilderException: Failed to process guava-21.0.jar Android 3.1 Dev Channel

After updating my dependency versions in AndroidStudio3.1, I started getting the following error:
Information:Gradle tasks [:app:assembleDebug]
Error:com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\Blabla\.gradle\caches\modules-2\files-2.1\com.google.guava\guava\21.0\3a3d111be1be1b745edfa7d91678a12d7ed38709\guava-21.0.jar
Error:com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.
Error:com.android.tools.r8.ApiLevelException: Default interface methods are only supported starting with Android N (--min-api 24): java.util.Collection com.google.common.collect.BiMap.values()
Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\Blabla\.gradle\caches\modules-2\files-2.1\com.google.guava\guava\21.0\3a3d111be1be1b745edfa7d91678a12d7ed38709\guava-21.0.jar
Information:BUILD FAILED in 6s
Information:4 errors
Information:0 warnings
Information:See complete output in console
I have already cleaned and rebuilt project. Checked my "multiDexEnabled true" and 'compile 'com.android.support:multidex:1.0.2' is added.
What else can I do?
EDIT: Adding build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.blabla"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:27.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:multidex:1.0.2'
compile 'com.android.support:design:27.0.0'
compile 'com.android.support:cardview-v7:27.0.0'
compile 'com.jakewharton:butterknife:8.7.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.google.guava:guava:21.0'
compile 'com.microsoft.azure:azure-mobile-android:3.2.0#aar'
compile 'com.microsoft.azure:notification-hubs-android-sdk:0.4#aar'
compile 'com.microsoft.azure:azure-notifications-handler:1.0.1#aar'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.google.firebase:firebase-core:11.4.2'
compile 'com.google.firebase:firebase-crash:11.4.2'
compile 'com.google.firebase:firebase-auth:11.4.2'
compile 'com.google.firebase:firebase-database:11.4.2'
compile 'com.google.firebase:firebase-storage:11.4.2'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'
compile 'com.google.android.gms:play-services-maps:11.4.2'
compile 'com.google.android.gms:play-services-location:11.4.2'
compile 'com.google.maps.android:android-maps-utils:0.5+'
}
apply plugin: 'com.google.gms.google-services'
I had the same issue in react-native project,
the below lines worked for me,
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Update your Guava version
Guava 21 is Java 8 only.
Update your gradle to Guava version 27.0.1-android, which is compatible with Android:
Gradle 4.6+:
dependencies {
implementation 'com.google.guava:guava:27.0.1-android'
}
Previous Gradle versions:
dependencies {
compile 'com.google.guava:guava:27.0.1-android'
}
I had same problem and I solved it cleaning project and rebuilding it.
In Android Studio go to Build --> Clean Project and after, Build --> Rebuild Project
Hope it helps
I had the similar case when I switched to OkHttp 4.x. It turned out that I had to disable the method profiling in run configuration:
Edit Configurations -> app -> Profiling tab -> uncheck Enable advanced profiling. It solved my case but I cannot use profiling now on older devices.
In my case, I was getting the error because I was clicking the Debug 'app' button while my build variant was set to release. When I changed my build variant to debug, then clicked the Debug button again, the error went away. I hope this helps someone.
I had the same issue and my problem was dependency conflict.
I searched for the conflict via the gradle dependency tree:
gradlew app:dependencies
Then I excluded the module for the conflicting library (e.g org.json:json):
api ('<conflicting-library>',{
exclude group:'org.json', module:'json'
})

Duplicate dependency error for gms /analytics android studio 2.2rc2

My app Level Gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "24.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.mss.triplestar"
minSdkVersion 15
targetSdkVersion 23
multiDexEnabled true
}
//====================Add below two line=============
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
preDexLibraries = false //delete the already predexed libraries
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:23.4.0'
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/libGoogleAnalyticsServices.jar')
// compile files('libs/libGoogleAnalyticsV2.jar')
compile 'com.google.android.gms:play-services-analytics:9.0.0'
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/vungle-publisher-adaptive-id-3.3.1.jar')
compile 'com.google.android.gms:play-services-ads:9.0.0'
compile project(':wheelLib')
compile 'com.google.android.gms:play-services:9.0.0'
// compile 'com.google.android.gms:play-services-gcm:9.0.0'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'com.scottyab:aescrypt:0.0.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:24.2.0'
}
My log output
Information:Gradle tasks [:app:assembleDebug]
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.5 is ignored for debug as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.5 is ignored for release as it may be conflicting with the internal version provided by Android.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/analytics/internal/Command$1.class
Information:BUILD FAILED
Information:Total time: 2.579 secs
Information:1 error
Information:2 warnings
Information:See complete output in console
This is my log output i am trying to build and update my project but
it gives me this error if i removed analytic jar than i get easy
tracker error .please help i am stuck at this point getting no clue
.tried all the solutions .Thanks in advance
Since you are adding a legacy version of the Google Analytics SDK for Android you should remove it.
Remove:
compile files('libs/libGoogleAnalyticsServices.jar')
Also add the plugin to the bottom of your app-level build.gradle:
apply plugin: 'com.google.gms.google-services'
Also no reason to use both:
compile 'com.google.android.gms:play-services-ads:9.0.0'
compile 'com.google.android.gms:play-services:9.0.0'
and you shouldn't ever be using compile 'com.google.android.gms:play-services:9.0.0' as that includes every Google Play services library - only use the APIs you need.
change
buildToolsVersion "24.0.2" to 23.0.4

Could not resolve all dependencies for configuration ':app:_debugCompile'. in android studio

When I am run my application in android studio error. I am new in android developing.
My Logtag is here:
Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:assembleDebug]
Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not find com.android.support:recyclerview-v7:.
Searched in the following locations:
https://jcenter.bintray.com/com/android/support/recyclerview-v7//recyclerview-v7-.pom
https://jcenter.bintray.com/com/android/support/recyclerview-v7//recyclerview-v7-.jar
file:/C:/Users/ANDROID/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/recyclerview-v7//recyclerview-v7-.pom
file:/C:/Users/ANDROID/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/recyclerview-v7//recyclerview-v7-.jar
file:/C:/Users/ANDROID/AppData/Local/Android/sdk/extras/google/m2repository/com/android/support/recyclerview-v7//recyclerview-v7-.pom
file:/C:/Users/ANDROID/AppData/Local/Android/sdk/extras/google/m2repository/com/android/support/recyclerview-v7//recyclerview-v7-.jar
Required by:
ShoppingMazza:app:unspecified
Information:BUILD FAILED
Information:Total time: 4.964 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
My build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.catalyst.android.shoppingmazza"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.1.5#aar'
compile 'com.android.support:recyclerview-v7:'
}
Error:
Error:A problem occurred configuring project ':app'. Could not
resolve all dependencies for configuration ':app:_debugCompile'.
Could not find com.android.support:recyclerview-v7:.
From error i can say you'll have to add the following gradle dependency :
compile 'com.android.support:recyclerview-v7:+'
EDIT:
Error:Execution failed for task ':app:dexDebug'. >
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command
'C:\Program Files\Java\jdk1.8.0_51\bin\java.exe'' finished with
non-zero exit value 1
For this error i think you are compiling JAR library twice. You are using
compile fileTree(dir: 'libs', include: ['*.jar'])
in build.gradle file so it will compile all library that has jar extension on libs folder, so You can remove this lines:
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.1.5#aar'
If issue still exists then issue is quite possibly due to exceeding the 65K methods dex limit imposed by Android. This problem can be solved either by cleaning the project, and removing some unused libraries and methods from dependencies in build.gradle, OR by adding multidex support.
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
Did you forget the version? In your gradle config you should have something like this:
compile 'com.android.support:recyclerview-v7:23.0.1'
In my case, I deleted caches folder inside .gradle folder and then I added compile. It worked for me!

Android - Duplicate Entry Error - How do I use one class from one JAR file when it exists in two JAR files without running into this error?

How do I get my code to use only one class from one JAR file when the same class from two JAR files exist in the files ormlite-android-4.6.jar & ormlite-core-4.45.jar without running into this error?
Here is a copy of my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.android.engineering"
minSdkVersion 16
targetSdkVersion 21
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
//compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.code.gson:gson:2.2.4'
compile 'joda-time:joda-time:2.0'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.android.support:appcompat-v7:22.0.0'
compile files('libs/achartengine-1.1.0.jar')
compile files('libs/butterknife-5.1.2.jar')
compile files('libs/com.google.guava_1.6.0.jar')
compile files('libs/com.springsource.org.junit-4.10.0.jar')
compile files('libs/commons-collections-3.2.1.jar')
compile files('libs/dagger-1.1.0.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/opencsv-3.3.jar')
compile files('libs/ormlite-android-4.6.jar')
compile files('libs/ormlite-core-4.45.jar')
compile files('libs/log4j-1.2.16.jar')
compile files('libs/icepick-2.3.jar')
compile files('libs/mockito-core-1.9.5.jar')
}
Here is the error I get:
:app:packageAllDebugClassesForMultiDex FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: com/j256/ormlite/dao/BaseDaoImpl$1.class
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 5.131 secs
The code I think is trying to use BaseDaoImpl.class which both exists in package com.j256.ormlite.dao.BaseDaoImpl in both ormlite-android-4.6.jar & ormlite-core-4.45.jar. How do I get it to use one class from one JAR file without running into this error?
You can use
compile ("net.danlew:android.joda:2.9.0") {
exclude group: 'org.joda.time'
}
or to exclude module use
compile ("net.danlew:android.joda:2.9.0") {
exclude module: 'jode-time'
}
Run "gradlew dependencies" which will allow you to see all the libraries. You can use the "exclude" directive to remove duplicate libraries.
Look here to read more about the exclude directive: https://gradle.org/docs/current/userguide/dependency_management.html#sub:exclude_transitive_dependencies

Categories

Resources