简体   繁体   中英

android protobuf javalite and R8

my release build failed on the task:minifyReleaseWithR8

> Task :app:minifyReleaseWithR8 FAILED
AGPBI: {"kind":"error","text":"Type com.google.protobuf.SourceContextOrBuilder is defined multiple times: /Users/userz/.gradle/caches/transforms-2/files-2.1/fa3559cc4d07efe76175d461f7267b38/jetified-protobuf-javalite-3.11.0.jar:com/google/protobuf/SourceContextOrBuilder.class, /Users/userz/path-to-project/build/intermediates/javac/release/classes/com/google/protobuf/SourceContextOrBuilder.class","sources":[{"file":"/Users/userz/.gradle/caches/transforms-2/files-2.1/fa3559cc4d07efe76175d461f7267b38/jetified-protobuf-javalite-3.11.0.jar"}],"tool":"R8"}

protobuf in project is defined as follows:

protobuf {
    protoc {
        // You still need protoc like in the non-Android case
        artifact = "com.google.protobuf:protoc:3.11.0"
    }
    generateProtoTasks {
        all().each { task ->
            task.builtins {
                java {
                    option "lite"
                }
            }
        }
    }
}

protobuf "com.google.protobuf:protobuf-javalite:3.11.0"

Interesting thing that if I delete firebase performance library

implementation "com.google.firebase:firebase-perf"

than build fails earlier (on:kaptReleaseKotlin task)

> Task :app:kaptReleaseKotlin
path-to-project/build/generated/source/proto/release/java/main/MessageOuterClass.java:9: error: cannot find symbol
      com.google.protobuf.ExtensionRegistryLite registry) {  
symbol:   class ExtensionRegistryLite
  location: package com.google.protobuf/path-to-project/build/generated/source/proto/release/java/main/MessageOuterClass.java:493: error: cannot find symbol
      com.google.protobuf.MessageLiteOrBuilder {
implementation "com.google.protobuf:protobuf-javalite:3.11.0"

solved the problem

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM