Ionic 3 project and plugin crosswalk error - ionic-framework

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.

Related

Is there a new version for the flutter tflite package?

I started working with Flutter and Dart lately, and I'm building a project using the tflite package. But when I want to build the app, even the demo app when just adding the tflite package to my dependencies in pubspec.yaml, to my phone (Xiaomi redmi note 10, android 12) it shows this error:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\User\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\tflite-1.1.2\android\build.gradle' line: 24
* What went wrong:
A problem occurred evaluating project ':tflite'.
> No signature of method: build_9lbq7rfhl5cpix99148s3txh6.android() is applicable for argument types: (build_9lbq7rfhl5cpix99148s3txh6$_run_closure2) values: [build_9lbq7rfhl5cpix99148s3txh6$_run_closure2#77b9e791]
* 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 5s
Exception: Gradle task assembleDebug failed with exit code 1
Also, when I firstly clicked 'pub get' after depending on tflite, it showed this error:
The plugin `tflite` uses a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.
but since I am not the package author, i didn't thought much of it.
I've seen that the tflite package was lastly updated 18 months ago.
So, is there an updated version of the package? Or, is there an alternative for running the google teachable machine?
That is the last known edit to the package. If there are issues that make it unusable now, I'd suggest leaving an issue on their GitHub page so that they can address it moving forward. Unfortunately, you might have to find an alternative to using that package, or edit the package locally yourself to get rid of any dependency issues.
Judging from the volume of issues on this package raised on github (https://github.com/shaqian/flutter_tflite), I don't think it's being maintained at all anymore.

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).

Cordova-camera plugin

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

How to properly import Open Source projects in Flutter?

I am learning Flutter and I would like to import an Open Source project to learn some of the structure etc.
The project is: https://github.com/matthewtory/trinity-orientation-2018
I am using Android Studio, and so far I can create my own projects and run them via my phone but when I want to import this project I am getting a lot of errors and warnings. The app is finished and also on the play store, so why doesn't it run in my IDE? Am I missing something?
Error message is:
Launching lib\main.dart on SM G960F in debug mode...
Initializing gradle...
Resolving dependencies...
* Error running Gradle:
ProcessException: Process "C:\Users\marcs\AndroidStudioProjects\trinity-orientation-2018-master\android\gradlew.bat" exited abnormally:
firebase_storage
firebase_messaging
url_launcher
camera
path_provider
cloud_firestore
shared_preferences
image_picker
firebase_core
firebase_auth
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\marcs\AndroidStudioProjects\trinity-orientation-2018-master\android\app\build.gradle' line: 16
* What went wrong:
A problem occurred evaluating project ':app'.
> versionCode not found. Define flutter.versionCode in the local.properties file.
* 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
Command: C:\Users\marcs\AndroidStudioProjects\trinity-orientation-2018-master\android\gradlew.bat app:properties
Finished with error: Please review your Gradle project setup in the android/ folder.
I downloaded the project and imported the folder in Android Studio. It first asked to get the dependencies which I did and immediately, I tried to run it on my phone.
Feel free to check the code on the Github project. I have not changed anything. I hope to run this project to learn about animation and navigation concepts.
The error message says you have to define version code. Try to add below lines to your local.properties file (under android folder)
flutter.versionName=1.0.0
flutter.versionCode=1
You may get other errors but at least this will fix the error in your question. Share other error message if you get.

When uninstall nativescript plugin and run 'tns run android' has failed

I'm devloping a nativescript plugin.when I want to change something with the plugin at index.js. so I uninstall the plugin and explanatory note the plugin code in app project.Then I run 'tns run android' ,It's some error display:
...
Merged dex #46 (1 defs/1.3KiB)
Merged dex #47 (1 defs/1.4KiB)
Merged dex #48 (2513 defs/3231.2KiB)
Result is 2560 defs/4103.9KiB. Took 0.1s
:buildMetadata
Exception in thread "main" java.lang.IllegalArgumentException: Class android.support.v7.widget.SnapHelper$2 conflict: D:\app\toast-test\platforms\android\build\intermediates\transforms\dex\F0F1F2\debu
at com.telerik.metadata.ClassRepo.addToCache(ClassRepo.java:21)
at com.telerik.metadata.Builder.build(Builder.java:40)
at com.telerik.metadata.Generator.main(Generator.java:44)
:buildMetadata FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':buildMetadata'.
Process 'command 'C:\Program Files\Java\jdk1.8.0_112\bin\java.exe'' finished with non-zero exit value 1
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 41.154 secs
Command D:\app\toast-test\platforms\android\gradlew.bat failed with exit code 1
How can I rebuild my app success after delete some plugins in project?
and how to update the nativescript plugin to new version?
After removing a plugin with native dependencies in the form of .aar or .jar (those include plugins downloaded through a remote plugin repository like maven) in NativeScript 2.4 you need to re-add the platform.
tns plugin remove nativescript-plugin
tns platform remove android
tns platform add android / tns run/build android
With the coming 2.5 release clearing any traces of the old plugin will be done by the CLI and no manual steps should be required besides simply removing the plugin from your project.