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

Error when building example on Android #228

Open
vricosti opened this issue May 22, 2022 · 7 comments
Open

Error when building example on Android #228

vricosti opened this issue May 22, 2022 · 7 comments

Comments

@vricosti
Copy link

When I try to test example I get the following build error:

Launching lib\main.dart on Pixel 3 in debug mode...
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Note: D:\Dev\Perso\flutter\flutter_uploader-main\android\src\main\java\com\bluechilli\flutteruploader\FlutterUploaderPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
ERROR:: D8: Cannot fit requested classes in a single dex file (# methods: 67485 > 65536)
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 
The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
	at com.android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.java:128)
	at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:115)
	at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:111)
	at com.android.build.gradle.internal.tasks.DexMergingWorkAction.merge(DexMergingTask.kt:805)
	at com.android.build.gradle.internal.tasks.DexMergingWorkAction.run(DexMergingTask.kt:760)
	at com.android.build.gradle.internal.profile.ProfileAwareWorkAction.execute(ProfileAwareWorkAction.kt:74)
	at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
	at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:67)
	at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:63)
	at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:97)
	at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:63)
	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.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)
	at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)
	at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
	at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:60)
	at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$2(DefaultWorkerExecutor.java:200)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	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)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, position: null
	at Version.fakeStackEntry(Version_2.2.66.java:0)
	at com.android.tools.r8.utils.a0.a(SourceFile:89)
	at com.android.tools.r8.D8.run(D8.java:11)
	at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:113)
	... 36 more
Caused by: com.android.tools.r8.utils.b: Cannot fit requested classes in a single dex file (# methods: 67485 > 65536)
	at com.android.tools.r8.utils.V0.a(SourceFile:22)
	at com.android.tools.r8.utils.V0.a(SourceFile:25)
	at com.android.tools.r8.dex.P.a(SourceFile:55)
	at com.android.tools.r8.dex.P$h.a(SourceFile:7)
	at com.android.tools.r8.dex.b.a(SourceFile:14)
	at com.android.tools.r8.dex.b.c(SourceFile:30)
	at com.android.tools.r8.D8.d(D8.java:163)
	at com.android.tools.r8.D8.b(D8.java:1)
	at com.android.tools.r8.utils.a0.a(SourceFile:47)
	... 38 more

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDexDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingTaskDelegate
   > There was a failure while executing work items
      > A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingWorkAction
         > com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
           The number of method references in a .dex file cannot exceed 64K.
           Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org

BUILD FAILED in 1m 37s
[!] App requires Multidex support
┌─ Flutter Fix ──────────────────────────────────────────────────────────────────────────────────┐
│ Flutter multidex handling is disabled. If you wish to let the tool configure multidex, use the │
│ --mutidex flag.                                                                                │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

@vricosti
Copy link
Author

I have modified like this:

        minSdkVersion 21
        targetSdkVersion 31
        multiDexEnabled true

but then I have another error:

Launching lib\main.dart on Pixel 3 in debug mode...
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
√  Built build\app\outputs\flutter-apk\app-debug.apk.
E/AndroidRuntime(27181): FATAL EXCEPTION: main
E/AndroidRuntime(27181): Process: com.bluechilli.flutteruploaderexample, PID: 27181
E/AndroidRuntime(27181): java.lang.RuntimeException: Unable to get provider com.bluechilli.flutteruploader.FlutterUploaderInitializer: java.lang.IllegalStateException: WorkManager is already initialized.  Did you try to initialize it manually without disabling WorkManagerInitializer? See WorkManager#initialize(Context, Configuration) or the class level Javadoc for more information.
E/AndroidRuntime(27181): 	at android.app.ActivityThread.installProvider(ActivityThread.java:7251)
E/AndroidRuntime(27181): 	at android.app.ActivityThread.installContentProviders(ActivityThread.java:6787)
E/AndroidRuntime(27181): 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6704)
E/AndroidRuntime(27181): 	at android.app.ActivityThread.access$1300(ActivityThread.java:237)
E/AndroidRuntime(27181): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
E/AndroidRuntime(27181): 	at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(27181): 	at android.os.Looper.loop(Looper.java:223)
E/AndroidRuntime(27181): 	at android.app.ActivityThread.main(ActivityThread.java:7664)
E/AndroidRuntime(27181): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(27181): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/AndroidRuntime(27181): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
E/AndroidRuntime(27181): Caused by: java.lang.IllegalStateException: WorkManager is already initialized.  Did you try to initialize it manually without disabling WorkManagerInitializer? See WorkManager#initialize(Context, Configuration) or the class level Javadoc for more information.
E/AndroidRuntime(27181): 	at androidx.work.impl.WorkManagerImpl.initialize(WorkManagerImpl.java:185)
E/AndroidRuntime(27181): 	at androidx.work.WorkManager.initialize(WorkManager.java:210)
E/AndroidRuntime(27181): 	at com.bluechilli.flutteruploader.FlutterUploaderInitializer.onCreate(FlutterUploaderInitializer.java:28)
E/AndroidRuntime(27181): 	at android.content.ContentProvider.attachInfo(ContentProvider.java:2388)
E/AndroidRuntime(27181): 	at android.content.ContentProvider.attachInfo(ContentProvider.java:2358)
E/AndroidRuntime(27181): 	at android.app.ActivityThread.installProvider(ActivityThread.java:7246)
E/AndroidRuntime(27181): 	... 10 more

@spatialbits
Copy link

spatialbits commented May 26, 2022

I'm experiencing the same WorkManager is already initialized exception on 3.0.0-beta.4. Did you find a solution?

@spatialbits
Copy link

spatialbits commented May 26, 2022

Running it off the latest commit on main fixed it for me.
See 5ed749b

EDIT: never mind, this didn't fix it for me.

EDIT2: as an experiment, I removed the call to initialize the WorkManager in FlutterUploaderInitializer.java. Doing that stops the error and surprisingly uploads still seem to work. No idea what kind of impacts this would have on other functionality though.
image

@georgiosd
Copy link

No official answer? :-\

@jakehockey10
Copy link

guess not

@Bestfastfire
Copy link

Same here

@mudi256
Copy link

mudi256 commented Jan 17, 2023

remove the below from the manifest for version 3.0.0-beta.4

<provider android:name="androidx.work.impl.WorkManagerInitializer" android:authorities="${applicationId}.workmanager-init" android:enabled="false" android:exported="false" />

<provider android:name="com.bluechilli.flutteruploader.FlutterUploaderInitializer" android:authorities="${applicationId}.flutter-upload-init" android:exported="false"> <meta-data android:name="com.bluechilli.flutterupload.MAX_CONCURRENT_TASKS" android:value="3" /> <meta-data android:name="com.bluechilli.flutteruploader.UPLOAD_CONNECTION_TIMEOUT_IN_SECONDS" android:value="3600" /> </provider>

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

6 participants