toro icon indicating copy to clipboard operation
toro copied to clipboard

Error when updating Android Gradle plugin to 3.4.0

Open maxbaldrighi opened this issue 5 years ago • 12 comments

What kind of issue is this?

  • [x ] Question.

I marked this as a question because I really don't know if this is a bug.

Toro version: 3.6.2.2903

Right after updating Android Studio to version 3.4, Android Gradle plugin to version 3.4.0 and gradle wrapper to version 5.1.1, I cannot compile my project because of this error issued by the Java compiler:
Caused by: java.lang.AssertionError: annotation tree hasn't been attributed yet: @kotlin.Metadata(mv = {1, 1, 15}, bv = {1, 0, 3}, k = 1, d1 = {"\u0000\u001a\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\u0018\u00002\u00020\u0001B!\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005\u0012\n\b\u0002\u0010\u0006\u001a\u0004\u0018\u00010\u0007\u00a2\u0006\u0002\u0010\b\u00a8\u0006\t"}, d2 = {"L<MY_PACKAGE>/LoopExoPlayerHelper;", "Lim/ene/toro/exoplayer/ExoPlayerViewHelper;", "player", "error/NonExistentClass", "mediaUri", "Landroid/net/Uri;", "extension", "", "(Lerror/NonExistentClass;Landroid/net/Uri;Ljava/lang/String;)V", "app_devDebug"})

It refers to LoopExoPlayerHelper class, subclass of ExoPlayerViewHelper. Looking at ExoPlayerViewHelper, AS warns me that it Cannot access class 'im.ene.toro.ToroPlayer'. Check your module classpath for missing or conflicting dependencies.

Moreover, I don't know if it can help, entering the ExoPlayerViewHelper.java file AS tells me that Library source does not match the bytecode for class ExoPlayerViewHelper.

Restoring to previous gradle versions and clearing AS cache solves everything.

What can this be related to? How can I fix this?

Thank you for your help!

maxbaldrighi avatar Apr 25 '19 00:04 maxbaldrighi

@maxbaldrighi Sounds weird. Let me try clone the tag 3.6.2.2903 and check on AS 3.4.

eneim avatar Apr 25 '19 05:04 eneim

@maxbaldrighi Do you happen to update the gradle version manually?

I try to download source code from 3.6.2.2903, open it in AS 3.4.0 using the "Open existing ...", wait for AS to do the first sync. It will then ask you to update gradle plugin to 3.4.0 and gradle version to 5.something. Instead of manually doing anything I just click the button and wait for AS to update again ... Below is my steps and the result. Please take sometime to try again.

Screen Shot 2019-04-25 at 16 35 57

Below: need to update exoplayer 2.4.4 for mopub as well, since the common artifact seems to be removed. Screen Shot 2019-04-25 at 16 42 38

Screen Shot 2019-04-25 at 16 45 49

Below: successfully build the project.

Screen Shot 2019-04-25 at 16 52 38

eneim avatar Apr 25 '19 08:04 eneim

Thank you very much for your response. I am gonna try again for sure! Just a question: is updating to exoplayer 2.4.4 necessary even if I don't use toro-mopub? The Toro line in my app/build.gradle is just: implementation ("im.ene.toro3:toro-ext-exoplayer:${versions.toro}") { exclude group: 'com.google.android.gms' // due to error in compilation }

maxbaldrighi avatar Apr 25 '19 13:04 maxbaldrighi

@maxbaldrighi If you are trying to work with the source code, it is necessary. As the first sync will also try to compile all modules I suppose. Long ago the artifact for all exoplayer extension exists, but it seems to be gone lately. You can copy paste here:

  implementation "com.google.android.exoplayer:exoplayer-core:r2.4.4"
  implementation "com.google.android.exoplayer:exoplayer-dash:r2.4.4"
  implementation "com.google.android.exoplayer:exoplayer-hls:r2.4.4"
  implementation "com.google.android.exoplayer:exoplayer-smoothstreaming:r2.4.4"
  implementation "com.google.android.exoplayer:exoplayer-ui:r2.4.4"

eneim avatar Apr 25 '19 13:04 eneim

Sorry, I don't understand: if with work with the source code you mean using directly ExoPlayer, I do it only through the dependencies provided by Toro. And the other thing I don't get is why you write 2.4.4 when ExoPlayer library is now at 2.9.6 ...

maxbaldrighi avatar Apr 25 '19 14:04 maxbaldrighi

@maxbaldrighi Think this way:

toro-core is independent from ExoPlayer toro-exoplayer depends on toro-core and ExoPlayer, and support ExoPlayer 2.9.3 at that version toro-mopub 's purpose is to support mopub 4.x (which depends on ExoPlayer r2.4.4), so it cannot share the same dependency with toro-exoplayer. I make it a separated module for that reason.

So, if you just use the toro-exoplayer via jcenter, you do not need to worry about toro-mopub, If you clone the source of this repository and try to customize it, you will also clone toro-mopub together.

When you try to open the project with AS, it will load all resource for all module first.

toro-mopub depends on something doesn't exist on jcenter anymore, which will break the Sync.

eneim avatar Apr 25 '19 14:04 eneim

Because latest mopub library now depends on ExoPlayer 2.9.5, I will soon deprecate toro-mopub and remove it from the repository. It will fix this issue as well.

eneim avatar Apr 25 '19 14:04 eneim

Oh, I'm sorry, I get what you meant now. Thanks.

BTW I tried the "automatic" way leaving to AS the update (like anyway I did a few days ago when I first updated everything) but nothing, I still get that strange kotlin-metadata-related AssertionError I pasted before.

It will fix this issue as well: you mean my current question? So you think in the end it's related to this mopub issue?

maxbaldrighi avatar Apr 25 '19 14:04 maxbaldrighi

@maxbaldrighi Oh I mean it just fix the dependency stuff. I will take a look at your error :( maybe it is the kotlin compiler and gradle kind of thing.

eneim avatar Apr 25 '19 14:04 eneim

Sorry again for misunderstanding.

Thank you, very much!

maxbaldrighi avatar Apr 25 '19 14:04 maxbaldrighi

Hello @eneim!

I know that my issue has a very low priority, but did you have the chance to try and check if the error might come from the library?

maxbaldrighi avatar May 09 '19 18:05 maxbaldrighi

@maxbaldrighi Hi, sorry. As I cannot reproduce this, I guess it is kind of machine specific.

Please try to clone this branch: https://github.com/eneim/toro/tree/nam/v3/repackage and instead of opening it by Android Studio, try ./gradlew clean build from terminal first.

After that, please try to install a clean Android Studio 3.4 (also do not reuse the configuration of other version), and open that branch. Let's see if it happens again.

eneim avatar May 12 '19 05:05 eneim