Cordova-camera plugin - ionic-framework

When adding cordova camera plugin into my project then i am facing cordova build problem as follows:
Step 1: Adding ionic cordova camera plugins
Step 2: try to build the native app using ionic cordova build android --debug
then the following error is displaying
Task :app:transformClassesWithMultidexlistForDebug FAILED
D8: Program type already present: android.support.v4.app.ActionBarDrawerToggle$Delegate
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
com.android.build.api.transform.TransformException: Error while generating the main dex list:
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.app.ActionBarDrawerToggle$Delegate
[ERROR] An error occurred while running subprocess cordova.
cordova.cmd build android --debug exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.

This problem may be from your AndroidManifest.xml. Open your AndroidManifest.xml file and find android.support.v4.app.ActionBarDrawerToggle, you will find two line for this. Comment one of them and keep only one android.support.v4.app.ActionBarDrawerToggle. Then try to run again.
This will may help you.

I change cordova-camera plugin version from 4.3.0 to 4.1.0 and now it works well this may be ionic v4 plugin issue

install the latest cordova platform[
]1

Related

Flutter says Execution failed for task ':sqflite:compileDebugJavaWithJavac'

I used to have this sqflite in my pubspec.yaml file but recently I removed the dependence seeing I won't be making use of it, then I run the app on my android device and emulator I got a strange error and have googled for the solution, it seems I can't find any help and as well check stackoverflow.
What have done so far:
As a rule of thumb, i ran flutter clean to see if issue will be
resolved but it did not worked either
Invalidate and Restart Android Studio
Here is the Error am having
Launching lib/main.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...
/Users/zionnite/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-2.0.0+3/android/src/main/java/com/tekartik/sqflite/SqflitePlugin.java:910: error: cannot find symbol
database.deleteDatabase(path);
^
symbol: variable database
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':sqflite:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* 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 58s
Exception: Gradle task assembleDebug failed with exit code 1
Dependency of Interest
# sqflite: ^2.0.0+3
# path_provider: ^2.0.1
At this time even if I enable the dependency, the issue still persists.
However, everything is working out great on my ios simulator except android device and emulator
The issue caused by Java version 8. So you should use Java version 11.
Add this to build.gradle file (android/app/build.gradle)
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
Change JDK of Gradle in Android studio
Finally, Clean and rebuild.
That's it.
Issue resolved after downloading Java 11,also check the gradle and wrapper version you're using
I was encountering the same issue.I have done everything which is mentioned on stackoverflow .but the problem is in my new added package which is cached_network_image .I just remove this package and every thing start working.So you just check which new package you added and which create fuss..
I was able combat the enemy of death fighting for the progress of my code and obtain victory through the magical touch of flutter pub cache repair.
what i mean to say is that, when i ran flutter pub cache repair, Flutter was able to build and run on my android device and emulator

How do I solve a configuration problem with audioplayers when using the command flutter build apk?

I have just created an app with flutter and I want to get the apks by splitting per abi. When given the command, there is a problem with configuring the plugin audioplayers.
I thought it could be a problem with using androidX?
Here is the error I get:
´´´
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':audioplayers:verifyReleaseResources'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource linking failed
C:\Users\vanda_qwkpv9x.gradle\caches\transforms-2\files-2.1\7faf2ad74a0b9932e38d86e684646e95\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.
C:\Users\vanda_qwkpv9x.gradle\caches\transforms-2\files-2.1\7faf2ad74a0b9932e38d86e684646e95\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcIndex not found.
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 56s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 57.7s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve
the incompatibility.
Building plugin audioplayers...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 2.0s
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'audioplayers'.
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 1s
The plugin audioplayers could not be built due to the issue above.
Anyone suggestions?
EDIT: With newer Flutter projects (thus newer Gradle versions), android.enableR8 is deprecated!
I'm not an expert with Android nor Flutter, but after many tests it seems that the issue isn't related to a package your recently installed, but with the size of the build! I was getting errors related to audioplayers, assets_audio_player, multiple Firebase packages and so on.
In android\gradle.properties make sure you don't have android.enableR8 set to false.
Here were my issues and steps for those interested:
I was only getting errors similar to yours only on build, not while using hot reload
Errors were related to audioplayers which led me to think it's just a package issue
Replaced it with assets_audio_player, but the problems continued
Changed the order, but this made the error shift to Firebase. I recently added Craslytics and this made me think it's because I used a newer version compared to the 1-2 months old packages. I thought it was the time to upgrade to 8.x, but that didn't make sense either. Never had such issues with any FB service/
Removed the latest sound packages, build was successful, but after adding more random packages (just to increase the size), the errors came back!
R8 announcement:
R8, the new code shrinker from Google, is available in Android studio 3.3 beta
Android developers know that APK size is an important factor in user engagement. Code shrinking helps reduce the size of your APK by getting rid of unused code and resources as well as making your actual code take less space (also known as minification or obfuscation).

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 when adding "image_cropper" and "contacts_service" packages

I can successfully build and run a fresh new flutter project. But when I add both image_cropper: ^1.0.0 and contacts_service: ^0.2.4 packages to pubspec.yaml and run flutter packages get, I cannot build the project anymore, and get this build error:
D8: Program type already present: android.support.v4.app.INotificationSideChannel
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: E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\2.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\3.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\4.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\5.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\6.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\7.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\8.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\9.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\10.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\11.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\12.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\13.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\14.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\15.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\16.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\17.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\18.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\19.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\20.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\21.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\22.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\23.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\24.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\25.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\26.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\27.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\28.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\29.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\30.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\31.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\32.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\33.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\34.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\35.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\36.jar
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: android.support.v4.app.INotificationSideChannel
* 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 19s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See https:///CP92wY for more information on the problem and how to fix it.
*******************************************************************************************
Finished with error: Gradle task assembleDebug failed with exit code 1
I do not understand this error very well, but it seems that there is a naming conflict between these two packages (because of duplicate_classes in the error text). Is there any workaround for this?
Note that this error does not happen with any other pair of packages for me.
In build.gradle defaultConfig add multiDexEnabled true
This was an Android X compatibility issue. I could get it fixed by following the steps mentioned here, but in summary:
First make sure that compileSdkVersion is at least 28 in app/build.gradle. This property controls the version of the Android SDK that Gradle uses to build your APK. It doesn’t affect the minimum SDK version that your app can run on.
Right click on android directory of flutter project and open it using this menu: Flutter > Open android module in android studio
In the newly opened project, from menus select Refactor > Migrate to AdnroidX
Close the project and open your flutter project again.

Ionic 3 project and plugin crosswalk error

I have a Ionic 3 project, when I run "ionic cordova run android --prod" I see
This error:
ANDROID_HOME=C:\Users\asus\AppData\Local\Android\sdk\
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_131\
Subproject Path: CordovaLib null
The Task.leftShift(Closure) method has been deprecated and
is scheduled to be removed in Gradle 5.0. Please use
Task.doLast(Action) instead.
at build_86b8k75dm7qqz7n5jyg9xp8kh.run(D:\project\ionic\MyProject\platforms\android\build.gradle:138) org.xwalk:xwalk_core_library:23+ The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0.
Incremental java compilation is an incubating feature. The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please use TaskInp uts.file(Object).skipWhenEmpty() instead.
FAILURE: Build failed with an exception.
* What went wrong:
BUILD FAILED
Total time: 15.644 secs A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_armv7DebugApkCopy'.
> Could not resolve org.xwalk:xwalk_core_library:23+.
Required by:
project :
> Could not resolve org.xwalk:xwalk_core_library:23+.
> Failed to list versions for org.xwalk:xwalk_core_library.
> Unable to load Maven meta-data from https://download.01.org/crosswalk/releases/crosswalk/android/maven2/org /xwalk/xwalk_core_library/maven-metadata.xml.
> Could not GET 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2/org/xwalk/xwalk_core_ library/maven-metadata.xml'. Received status code 503 from server: Service Unavailable
* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Error: cmd: Command failed with exit code 1 Error output: FAILURE: Build failed with an exception.
* What went wrong: A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_armv7DebugApkCopy'.
> Could not resolve org.xwalk:xwalk_core_library:23+.
Required by:
project :
> Could not resolve org.xwalk:xwalk_core_library:23+.
> Failed to list versions for org.xwalk:xwalk_core_library.
> Unable to load Maven meta-data from https://download.01.org/crosswalk/releases/crosswalk/android/maven2/org /xwalk/xwalk_core_library/maven-metadata.xml.
> Could not GET 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2/org/xwalk/xwalk_core_ library/maven-metadata.xml'. Received status code 503 from server: Service Unavailable
* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.
[ERROR] An error occurred while running cordova run android (exit code 1).
I did not recieve this error before running Ionic.
The 01.org server seems to be down. So till the servers are back online, you can ask Gradle to use the local copy of Crosswalk.
I was having the same issue from last one hour. The following solution worked for me.
Open platforms\android\cordova-plugin-crosswalk-webview\*-xwalk.gradle file in your project directory, where * is your project name.
Look for the section -
dependencies {
compile xwalkSpec
}
Replace it with your exact Crosswalk version which you find in Chrome Developer Tools by typing window.navigator.userAgent in your Developer Tools console.
So your final data would look something like this -
dependencies {
compile 'org.xwalk:xwalk_core_library:23.53.589.4'
}
1 Get crosswalk version
There are another two ways to get xwalk_core_library version, you can use either of them:
Go to platforms/android/build/intermediates/exploded-aar/org.xwalk‌​/xwalk_core_library/‌​, then you can see version like 19.49.514.5
In the Google cache, you can select a version number
2 Change the gradle
Just like #hemantv said, in file platforms\android\cordova-plugin-crosswalk-webview*-xwalk.gradle
Change the file form
dependencies {
compile xwalkSpec
}
to
dependencies {
compile 'org.xwalk:xwalk_core_library:19.49.514.5'
}
19.49.514.5 is the version get from the step one.
Another way, you can use this plugin temporarily:
cordova plugin add https://github.com/zhouzhongyuan/cordova-plugin-crosswalk-webview
It just fixed this error.
Get Crosswalk version
As answered by Zhongyuan Zhou, there are ways to get locally saved Crosswalk library on your project, but I prefer the following:
Go to platforms/android/build/intermediates/exploded-aar/org.xwalk‌​/xwalk_core_library/‌​, then you can see version like 22.52.561.4
Modify config.xml
Add the following into your config.xml
<preference name="xwalkVersion" value="xwalk_core_library:22.52.561.4" />
Compile the Android build
Do the usual ionic cordova build android to build the Android APK or ionic cordova run android to build and run / install the Android app on an emulator or device.
Reference: https://forum.ionicframework.com/t/server-error-with-crosswalk-when-running-ionic-run-android/104009/15
This is follow up to hemantv's answer. I was panicking but his answer saved my day, and I was able to successfully compile the app using the locally stored xwalk.
This is what I did and i hope it helps someone out there who's stuck with the same predicament.
I found out the Crosswalk version I have stored locally by running a search (including sub directorys) for "xwalk_core_library" in my app directory and found the file "org.xwalk-xwalk_core_library-17.46.448.10_9bf812c8b76a44fdb31553d48df45b60d1362adc.jar" and figured out the version I had was "org.xwalk-xwalk_core_library-17.46.448.10" (everything after the underscore "_" is irrelevant)
I followed the instructions and opened up the platforms\android\cordova-plugin-crosswalk-webview*-xwalk.gradle in a text editor
found
dependencies {
compile xwalkSpec
}
replaced with
dependencies {
compile 'org.xwalk:xwalk_core_library:17.46.448.10'
}
reattempted to compile and it worked like a charm.