Flutter cannot able to run the project - flutter

Error
BUILD FAILED in 10s
Command: D:\flutterProjects\meetdaxdemodk\android\gradlew.bat app:propertie
Please review your Gradle project setup in the android/ folder.
When I try to run a project I am getting a Gradle error. How can I sort out this issue?

Related

Build Gradle failed after migrating the project to null safety in flutter

I have upgrade my flutter project to null safety and upgrade all plugins to resolvable version but after migration process, when I run the project, facing the following error.
`
A failure occurred while executing com.android.build.gradle.internal.tasks.MergeNativeLibsTask$MergeNativeLibsTaskWorkAction
> 2 files found with path 'lib/arm64-v8a/libavcodec.so' from inputs:
- C:\Users\Rahman\.gradle\caches\transforms-3\4b7c5bb16a1bd3cb611f62104d7d919b\transformed\jetified-mobile-ffmpeg-https-4.4\jni\arm64-v8a\libavcodec.so
C:\Users\Rahman.gradle\caches\transforms-3\154140bea2702dfe2628b83e4cdc7277\transformed\jetified-ffmpeg-kit-https-5.1\jni\arm64-v8a\libavcodec.so
If you are using jniLibs and CMake IMPORTED targets, see
https://developer.android.com/r/tools/jniLibs-vs-imported-targets
`
what I try to solve this problem :
I delete all the gradle files from the directory and allow the new ones from intelliJ idea automatically, After download process completed, I again run the project but face the same error.
I want to run this project, it is very important to me
How to solve this issue

why do I get Gradle task assemble Debug failed error

I imported a flutter project from GitHub. when I tried to run it I had this error(no errors in code). I could not figure out what this error is all about and I keep getting this error for every project which I import from GitHub.Please help me out!
This is the error:
Exception in thread "main" java.util.zip.ZipException: error in opening zip file.
Gradle threw an error while trying to update itself. Retrying the update...
Finished with error: Gradle task assembleDebug failed with exit code 1.
It's kinda common problem when you get a project from github and I solved it once with this answer.
Copy paste from there:
Open your Android Studio preferences(Command + ',') and go to
Languages and Frameworks -> Dart
Check "Enable Dart support for the project your_project_name"
In "Dart SDK path" click in "…" and navigate to flutter SDK directory.
Under that directory you'll find "bin/cache/dart-sdk". This is the
dart sdk path you should use.
Click "Apply"
flutter packages get
flutter run

Unable to build apk, firebase_admob making Error

I am trying to build apk but firebase admob is making problem, if I run without firebase_admob then apk works perfectly and built without any error how to resolve that issue?
I am getting this error :
Execution failed for task ':firebase_admob:verifyReleaseResources' in this case.
I am using firebase_admob: ^0.5.2 this version of it I even try some latest versions but the problem is still there.
C:\Users\Waqas\AndroidStudioProjects\gtvsports1>flutter build apk
You are building a fat APK that includes binaries for android-arm, android-arm64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
To generate an app bundle, run:
flutter build appbundle --target-platform android-arm,android-arm64
Learn more on: https://developer.android.com/guide/app-bundle
To split the APKs per ABI, run:
flutter build apk --target-platform android-arm,android-arm64 --split-per-abi
Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Initializing gradle... 1.3s
Resolving dependencies... 4.7s
Running Gradle task 'assembleRelease'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':firebase_admob:verifyReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
C:\Users\Waqas\AndroidStudioProjects\gtvsports1\build\firebase_admob\intermediates\res\merged\release\values\values.xml:304: error: resource android:attr/fontVariationSettings not foun
d.
C:\Users\Waqas\AndroidStudioProjects\gtvsports1\build\firebase_admob\intermediates\res\merged\release\values\values.xml:305: error: resource android:attr/ttcIndex not found.
error: failed linking references.
* 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 3m 10s
Running Gradle task 'assembleRelease'... 190.9s (!)
Gradle task assembleRelease failed with exit code 1
I was facing similar error. but I would like to suggest you to make appbundle which is the best option to upload app. Run flutter build appbundle sign it with google play store signing enrollment and upload. I resolve it with this.
Seems like you haven't migrated your project to AndroidX, all you need to do is, in your IDE use
Refactor > Migrate to AndroidX
After this
File > Invalidate Caches and Restart
Did you add the dependencies in Android/app/build.gradle?
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
api 'com.google.firebase:firebase-core:16.0.9'
api 'com.google.firebase:firebase-ads:16.0.1'
}

Flutter, Getting build error on image_picker: ^0.6.0+9

When I update my package to image_picker: ^0.6.0+9 getting build error.
I have already migrate Android X.
Error:
Launching lib/main.dart on vivo V3 in debug mode...
Initializing gradle...
Resolving dependencies...
Running Gradle task 'assembleDebug'...
D8: Program type already present: android.support.v4.media.MediaBrowserCompat$CustomActionCallback
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: android.support.v4.media.MediaBrowserCompat$CustomActionCallback
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 2s
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
Finished with error: Gradle task assembleDebug failed with exit code 1
Make Sure to follow the guide to support AndroidX
https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility
For Solving Dex error
Try adding this line In your Project folder > android > app > build.gradle
add the following Line in multiDexEnabled true
inside defaultConfig
Use flutter clean command once it is done then try running your app.
Add following line in gradle.properties
android.useAndroidX=true
android.enableJetifier=true
Remove Simple Permission package.
it's because your app isn't compatible with AndroidX ,
There are 2 solution
1-create a flutter compatible with AndroidX app by using this command in your terminal
flutter create --androidx [project_name]
2-configure your app manually
Its not problem with the Image provider its something to do with the latest flutter package. To resolve this issue
Open the Android folder of your your flutter project in Android Studio
Wait for the gradle to build once the task is complete click on Refactor -> Refactor this -> Migrate to AndroidX or press Ctrl+T -> Migrate to AndroidX
Do flutter clean
And boom your good to go
If you want to do manually by twicking the gradle file here is link
https://flutter.dev/docs/development/androidx-migration
Happy Hacking

Flutter build error. Issue with flutter webview plugin

I have added the flutter webview plugin but its causing problems. Its giving some error when building the project. I tried to delete the cache and rebuild the project but it didn't work.
I just started learning flutter and can't find a solution to this problem.
Below is the error I am getting.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':flutter_webview_plugin:compileDebugJavaWithJavac'.
Unable to find source java class: 'C:\Users\personal\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\flutter_webview_plugin-0.0.9+1\android\src\main\java\com\flutter_webview_plugin\WebviewActivity.java' because it does not belong to any of the source dirs: '[C:\Users\personal\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\flutter_webview_plugin-0.1.5\android\src\main\java, C:\Users\personal\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\flutter_webview_plugin-0.1.5\android\src\debug\java, C:\Users\personal\Documents\AndroidStudioProjects\flutter_newz\build\flutter_webview_plugin\generated\source\r\debug, C:\Users\personal\Documents\AndroidStudioProjects\flutter_newz\build\flutter_webview_plugin\generated\source\buildConfig\debug, C:\Users\personal\Documents\AndroidStudioProjects\flutter_newz\build\flutter_webview_plugin\generated\source\aidl\debug, C:\Users\personal\Documents\AndroidStudioProjects\flutter_newz\build\flutter_webview_plugin\generated\source\rs\debug]'
BUILD FAILED in 54s
Finished with error: Gradle build failed: 1
I was using other plugins for firebase auth, firebase analytics, google sign in , webview, ect. Updating all the plugins to the latest version solved the problem.