Androidcoder Androidcoder - 1 year ago 278
Android Question

Signed apk error: proguard can't find referenced class android.arch.core.util.Function after com.firebaseui:firebase-ui-database update to 2.3.0

After updating

compile 'com.firebaseui:firebase-ui-database:0.4.0'


to

compile 'com.firebaseui:firebase-ui-database:2.3.0'


I'm able to compile and run my app on my test device, but when attempting to generate the signed apk, I get this in 'messages gradle build'. I expect it's a proguard issue:

Information:Gradle tasks [:app:assembleRelease]
Warning:android.arch.lifecycle.Transformations: can't find referenced class android.arch.core.util.Function
Warning:android.arch.lifecycle.Transformations$1: can't find referenced class android.arch.core.util.Function
Warning:android.arch.lifecycle.Transformations$2: can't find referenced class android.arch.core.util.Function
Warning:there were 16 unresolved references to classes or interfaces.
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
> Job failed, see logs for details
Information:BUILD FAILED in 11s
Information:1 error
Information:5 warnings
Information:See complete output in console


I've tried incremental version updating, but that hasn't worked either. For example:

compile 'com.firebaseui:firebase-ui-database:2.0.0'


won't even sync, giving a merge error message.

I also updated my other SDKs but the firebaseui line now triggers it. Here is full app gradle as was asked of me in the comments:

apply plugin: 'com.android.application'

buildscript {
repositories {
jcenter()
google()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta6'
classpath 'com.google.gms:google-services:3.0.0'
}
}

android {
signingConfigs {
config {
keyAlias xxxxxx
keyPassword xxxxxx
storeFile file('C:/Users/xxxxxxxxx')
storePassword 'xxxxxxxx'
}
}
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.xxxxxx.xxxxxxx"
minSdkVersion 21
targetSdkVersion 26
versionCode xxxxx
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "8g"
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')

compile 'com.android.support:design:26.1.0'

compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.google.android.gms:play-services-drive:11.4.0'
compile 'com.google.android.gms:play-services-plus:11.4.0'
compile 'com.google.android.gms:play-services-location:11.4.0'
compile 'com.google.android.gms:play-services-auth:11.4.0'
compile 'com.google.android.gms:play-services-wallet:11.4.0'
compile 'com.google.android.gms:play-services-games:11.4.0'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:support-v13:26.1.0'

compile 'com.google.firebase:firebase-core:11.4.0'
compile 'com.google.firebase:firebase-invites:11.4.0'
compile 'com.google.firebase:firebase-ads:11.4.0'
compile 'com.google.firebase:firebase-database:11.4.0'
compile 'com.google.firebase:firebase-auth:11.4.0'
compile 'com.google.firebase:firebase-config:11.4.0'
compile 'com.google.firebase:firebase-messaging:11.4.0'
compile 'com.google.firebase:firebase-crash:11.4.0'
compile 'com.google.firebase:firebase-analytics:11.4.0'
compile 'com.google.firebase:firebase-appindexing:11.4.0'

compile 'com.firebaseui:firebase-ui-database:2.3.0'



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


Here are my proguard rules as also mentioned in the comments. I've experimented with various syntax without effect.

-renamesourcefileattribute SourceFile
-keepattributes Signature
-keepattributes SourceFile
-keepattributes LineNumberTable
-keepattributes *Annotation*
-keep class com.android.**
-keepclassmembers class com.android.**

Answer Source

I found that the proguard reference in the error messages was a red herring. This after adding dozens of extra rules to my proguard-rules file to no avail. After adding the following:

compile 'com.firebaseui:firebase-ui-auth:2.3.0' 

I am able to build a signed apk (earlier in the process adding this line had caused errors so I abandoned it). Oddly, with

compile 'com.firebaseui:firebase-ui-database:0.4.0' 

I hadn't needed the auth compile, with 'com.firebaseui:firebase-ui-database:2.3.0' I now do.

Also after adding the auth compile I had to change all my compile versions '26.1.0' to '26.0.1' in the app gradle to avoid merge errors with 'buildToolsVersion 26.0.1'. This despite the 'newer version is available 26.1.0' suggestion it gives me for these compiles. Such are the hurdles overcome in android development through hard experience, regardless of java coding skill.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download