Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protobuf-java 3.10.0 is not compatible with older Android versions #6718

Closed
matejdro opened this issue Oct 2, 2019 · 11 comments
Closed

protobuf-java 3.10.0 is not compatible with older Android versions #6718

matejdro opened this issue Oct 2, 2019 · 11 comments
Assignees

Comments

@matejdro
Copy link

matejdro commented Oct 2, 2019

protobuf-java 3.10.0 uses some Java 8 features which makes it incompatible with Android builds where minSdk < O, even with desugaring enabled.

I realize that mobile clients are supposed to use protobuf lite, but some libraries (like Dialogflow client library) use protobuf-java internally, so we do not have a choice.

What did you do?
Steps to reproduce the behavior:

  1. Download and extract
    ProtobufTest.zip
  2. Run ./gradlew assembleDebug

What did you expect to see

I expected build to succeed, like with protobuf-java 3.9.2

What did you see instead?

Build crashes with MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O error.

@matejdro matejdro changed the title protobuf-java is not compatible with older Android versions protobuf-java 3.1.10 is not compatible with older Android versions Oct 2, 2019
@rafi-kamal rafi-kamal changed the title protobuf-java 3.1.10 is not compatible with older Android versions protobuf-java 3.10.0 is not compatible with older Android versions Oct 2, 2019
@rafi-kamal rafi-kamal self-assigned this Oct 2, 2019
@rafi-kamal
Copy link
Contributor

Thanks for reporting the issue and sorry for the trouble. We added those methods for performance reasons, but if it breaks Java 7 compatibility then we are willing to revert the changes. This might take a few days/weeks. Meanwhile, can you please use 3.9.2?

@gmarcosb
Copy link

gmarcosb commented Oct 3, 2019

Does anyone here understand why this would break Java 7 compatibility when MethodHandle should be available in Java7? https://docs.oracle.com/javase/7/docs/api/java/lang/invoke/MethodHandle.html

@rafi-kamal
Copy link
Contributor

rafi-kamal commented Oct 3, 2019

@gmarcosb I think you are right, the issue is not Java 7 specific but rather Android specific. Looking at the Android docs, MethodHandle was added only starting from Android API level 26 (Android O): https://developer.android.com/reference/java/lang/invoke/MethodHandle

@donglua
Copy link

donglua commented Oct 11, 2019

Caused by: com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.
	at com.android.builder.dexing.D8DexArchiveBuilder.getExceptionToRethrow(D8DexArchiveBuilder.java:124)
	at com.android.builder.dexing.D8DexArchiveBuilder.convert(D8DexArchiveBuilder.java:101)
	at com.android.build.gradle.internal.tasks.DexFileDependenciesTask$DexFileDependenciesWorkerAction.run(DexFileDependenciesTask.kt:131)
	at com.android.build.gradle.internal.tasks.Workers$ActionFacade.run(Workers.kt:335)
	at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:41)
	at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.execute(NoIsolationWorkerFactory.java:58)
	at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
	at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
	at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
	at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:51)
	at org.gradle.workers.internal.DefaultWorkerExecutor$1.call(DefaultWorkerExecutor.java:107)
	at org.gradle.workers.internal.DefaultWorkerExecutor$1.call(DefaultWorkerExecutor.java:101)
	at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:215)
	at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164)
	at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131)
	... 3 more
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
	at com.android.tools.r8.utils.t.a(:55)
	at com.android.tools.r8.D8.run(:11)
	at com.android.builder.dexing.D8DexArchiveBuilder.convert(D8DexArchiveBuilder.java:99)
	... 23 more
Caused by: com.android.tools.r8.utils.AbortException: Error: MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O (--min-api 26)
	at com.android.tools.r8.utils.Reporter.a(:21)
	at com.android.tools.r8.utils.Reporter.a(:7)
	at com.android.tools.r8.utils.t.a(:36)
	... 25 more

@hsson
Copy link

hsson commented Oct 16, 2019

We are having this issue too. As like many others, we cannot set minSdkVersion in Android to 26, as this drastically impacts compatibility. Using 3.9.2 is okay for now, but we are expecting this to be fixed in coming releases.

@rafi-kamal
Copy link
Contributor

This should be fixed by #6752. Based on the timeline I'll see if it makes sense to do a 3.10.1 release with the fix, otherwise it will be included in 3.11 release.

@rafi-kamal
Copy link
Contributor

This is now fixed at master, we will include it in the 3.11 release.

@abonander
Copy link

@rafi-kamal do you know the timeline of the 3.11 release? I don't see a milestone for it in the issue tracker.

abonander added a commit to abonander/hedera-protobuf that referenced this issue Oct 31, 2019
That release broke compatibility with Android, 3.9.2 is safe and a fix is due in 3.11: protocolbuffers/protobuf#6718 (comment)
@rafi-kamal
Copy link
Contributor

3.11 will be released sometime next week.

@rafi-kamal
Copy link
Contributor

I've uploaded 3.11.0-rc1 to Maven.

@Nathagamelle
Copy link

thanks all for this thread, indeed skipping to v 3.11.0 saved the day for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants