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

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.

Related

Build works on local but fails on codemagic | Execution failed for task ':app:stripDebugDebugSymbols'

I'm trying to implement a continuous deployment system to build my app and deploy to Google Play using codemagic. Doing a build works fine locally but fails remotely on codemagic.
Error summary:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:stripDebugDebugSymbols'.
> 1 exception was raised by workers:
org.gradle.process.internal.ExecException: A problem occurred starting process 'command '/usr/local/share/android-sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-strip''
Complete log:
== Building for Android ==
> flutter build appbundle --debug
Running "flutter pub get" in My_Project... 1,655ms
💪 Building with sound null safety 💪
Running Gradle task 'bundleDebug'...
[flutter_background_geolocation] Purging debug resources in release build
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/builder/programs/flutter_2_5_3/.pub-cache/hosted/pub.dartlang.org/geocoding-2.0.1/android/src/main/java/com/baseflow/geocoding/GeocodingPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:stripDebugDebugSymbols'.
> 1 exception was raised by workers:
org.gradle.process.internal.ExecException: A problem occurred starting process 'command '/usr/local/share/android-sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-strip''
* 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 2m 19s
Running Gradle task 'bundleDebug'... 141.1s
Gradle task bundleDebug failed with exit code 1
Build failed :|
Failed to build for Android
Current configuration on codemagic:
Flutter channel: stable
Mode: debug
Build for: Android
to fix this you need to upgrade Gradle version in android/gradle/wrapper/gradle-wrapper.properties to 6.7.1 or commit gradle wrapper to your repository if you don't have this file.
Additional to that you also might need to upgrade Android Gradle plugin in andriod/build.gradle
- classpath 'com.android.tools.build:gradle:3.5.4'
+ classpath 'com.android.tools.build:gradle:4.2.0'
WITHOUT GRADLE UPGRADE
if for some reasons you can't upgrade Gradle version you can freeze previous NDK version.
For that you can specify ndkVersion "22.1.7171670" in your build.gradle and make sure you use Java 1.8 since there is an issue with using latest Java versions.
In Codemagic you can specify Java version in environment section in your codemagic.yaml like this
workflows:
workflow-name:
environment:
ndk: r22b
java: 1.8

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

Ionic Android Build Error

I'm seeing these errors after fresh ionic, cordova, and JDK update installations when I do android build:
BUILD FAILED
Total time: 6.254 secs
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':processDebugResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'c:\Android\sdk\build-tools\24.0.2\aapt.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.
Error: cmd: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':processDebugResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'c:\Android\sdk\build-tools\24.0.2\aapt.exe'' finished with non-zero exit value 1
You have to update to JDK 8. Looks like you have the older version 7.
Try JDK 8
and see if it helps.
I had the same problem reinstalled SDK didn't work
removed old sdk and reinstalled SDK did't work
You need to delete the android folder form the platform folder and execute
ionic run android this will reinstall the platform automatically and build from scratch. I think the cache files are the problem so that is why I think this worked.
I hope it will also work for others.