Firebase-perf与let插件冲突 [英] Firebase-perf conflicting with let plugin

查看:149
本文介绍了Firebase-perf与let插件冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们最近被要求在Android应用上实施"Firebase性能监控",但这已经给我们带来了许多不同的问题.该应用程序曾经可以正常运行,但是在添加了"firebase-perf"后便可以编译,但随后在运行时我们发现了

We were recently asked to implement "Firebase Performance Monitoring" on an Android app, but it's been causing us lots of different problems. The app used to work just fine, but upon adding "firebase-perf", it compiles, but then on runtime we found out the Let plugin stopped working, every permission defined with the @AskPermission annotation is simply ignored.

在查看gradle构建输出时,我偶然发现了此堆栈跟踪:

Looking through the gradle build output, I stumbled upon this stack-trace:

java.lang.IllegalStateException: Expecting .,<, or ;, but found firebaseperf while unpacking <K:Ljava/lang/Object;>Lcom/google/android/gms/internal/firebase-perf/zzw<TK;>;
    at org.aspectj.util.GenericSignatureParser.parseClassTypeSignature(GenericSignatureParser.java:204)
    at org.aspectj.util.GenericSignatureParser.parseAsClassSignature(GenericSignatureParser.java:56)
    at org.aspectj.weaver.UnresolvedType.forGenericTypeSignature(UnresolvedType.java:274)
    at org.aspectj.weaver.bcel.BcelWorld.addSourceObjectType(BcelWorld.java:482)
    at org.aspectj.weaver.bcel.BcelWorld.addSourceObjectType(BcelWorld.java:456)
    at org.aspectj.weaver.bcel.BcelWeaver.addAspectsFromJarFile(BcelWeaver.java:263)
    at org.aspectj.weaver.bcel.BcelWeaver.addLibraryJarFile(BcelWeaver.java:236)
    at org.aspectj.ajdt.internal.core.builder.AjBuildManager.initBcelWorld(AjBuildManager.java:874)
    at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:249)
    at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:185)
    at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:112)
    at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:60)
    at org.aspectj.tools.ajc.Main.run(Main.java:371)
    at org.aspectj.tools.ajc.Main$run.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
    at com.canelmas.let.LetPlugin$_apply_closure2_closure3.doCall(LetPlugin.groovy:66)
    ...

我到处都看到了一些类似的案例,但是找不到解决方案.从我的角度来看,这看起来像是在不同的类路径中定义的不同版本的Aspectjs之间的冲突.

I've seen some similar cases here and there but couldn't find a solution yet. The way I see it, it looks like a conflict between differing versions of aspectjs, defined in different classpaths.

这是项目级gradle文件的相关部分:

This is the relevant part of out project-level gradle file:

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath group: 'org.tmatesoft.svnkit', name: 'svnkit', version: '1.7.11'
        classpath('com.canelmas.let:let-plugin:0.1.11')
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'com.google.firebase:firebase-plugins:1.1.5'
    }
}

以下是我们在应用程序级gradle中定义的firebase依赖项:

And these are the firebase dependencies we have defined in the app-level gradle:

dependencies {
    compile 'com.google.firebase:firebase-core:16.0.7'
    compile 'com.google.firebase:firebase-perf:16.2.3'
}

有人有可能解决的想法吗?

Does anyone have an idea of a possible fix?

编辑:

There was someone in another thread, who claimed to have solved the problem with the code below, but I have no idea how to actually use it. Could anyone more Gradle-savvy be able to explain where is this declaration supposed to go and what I'm supposed to do with it?

我尝试将其放置在gradle文件的许多不同位置,但出现此错误:无此类属性:类的类路径:org.gradle.api.tasks.compile.JavaCompile"

I tried placing it many different places of my gradle file but I'm getting this error: "No such property: classpath for class: org.gradle.api.tasks.compile.JavaCompile"

def filtered_class_filetree = javaCompile.classpath.asFileTree.filter {
    !it.canonicalPath.contains("firebase-perf")
}

推荐答案

如果多个库正在编译aspectj的不同版本(或任何其他依赖项),则可以始终强制(或忽略)所需的内容,如下所示:

If multiple libraries are compiling different versions of aspectj (or any other dependency), you can always force (or ignore) the ones you want like below:

implementation('com.google.firebase:firebase-core:16.0.7', { // this will remove aspectj dependencies from firebase
    exclude group: 'org.aspectj', module: 'aspectjrt'
    exclude group: 'com.android.support', module: 'aspectjtools'
  })

您还可以强制如下所示的方面的版本(在模块中,在您的依赖项旁边):

You can also force aspect's version like below (beside your dependencies, in the module):

configurations.all {
    resolutionStrategy.force 'org.aspectj:aspectjrt:x.x.x'
}

要回答您的最后一个问题:

To answer your last question:

我尝试将其放置在gradle文件的许多不同位置,但我 收到此错误:没有这样的属性:类的类路径: org.gradle.api.tasks.compile.JavaCompile"

I tried placing it many different places of my gradle file but I'm getting this error: "No such property: classpath for class: org.gradle.api.tasks.compile.JavaCompile"

您可以使用模块内android块中的applicationVariants访问Java编译器(和类路径):

You can access java compiler (and classpath) using applicationVariants in android block inside your module:

  // inside your android module 
  android {
       //...
       applicationVariants.all {
       variant ->
         variant.javaCompiler.classpath = variant.javaCompiler.classpath.filter {
           !it.canonicalPath.contains("firebase-perf")
         }
     }
  }

这篇关于Firebase-perf与let插件冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆