Error: app:transformClassesWithDexBuilderForDebug - android

I have a class HillfortStore in this package:
package org.wit.hillforts.models
Messed up the package name in the class (missing the 's'):
package org.wit.hillforts.model
Imported class into other classes with wrong package name, it works just fine:
import org.wit.hillforts.model.HillfortStore
To clean things up I fix the name in the class and all classes its imported into. Now I'm getting this error.
Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
com.android.build.api.transform.TransformException: java.lang.IllegalStateException: Dex archives: setting .DEX extension only for .CLASS files

just do this :
in main project folder ,in terminal type
cd android
then type this
./gradlew clean
then build your app again

I needed to complete a rebuild of the app.
This is all it took to fix the issue.
It is working now.

Delete .gradle file from your project folder then clean the project and Rebuild

I had a similar problem because Lombok plugin didn't work with new gradle. Just removed these lines:
compileOnly 'org.projectlombok:lombok:1.18.4'
annotationProcessor 'org.projectlombok:lombok:1.18.4'
and the problem disappeared.
Maybe you also have some kind of "troubled" plugin that doesn't get along with new gradle)

run this in npm
$cd android
than run
$gradlew clean
than run
$cd ..
and finally, run
$npx react-native run-android

Related

Can't run nor debug project but gradle build+install work

After update to Android studio 3.6 Canary11 (macOS) I cannot run nor run Debug variants of my project (Release variants working fine).
When I try to run the project I've got error:
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Entry name 'firebase-abt.properties' collided
But when I delete build directory (rm -rf app/build), I can run/debug project once time. After the first run, it is again with the same error with collision.
I try clear cache, restart the Android studio, but it didn't help.
Maybe it is not related to Android studio, because different project running ok.
Do you have any idea, what the problem may be?
I was facing the same error as MrEngineer13. After hours of struggle turns out you have to delete the built APK files for the project to build another APK successfully
I had a similar issue with Android Studio 3.6 Canary 12 on Mac, I could build different build variants but had this error when I tried to Generate a signed apk:
Entry name 'kotlin/collections/MapWithDefault.kotlin_metadata' collided
I had to delete the .build folder as well as the folders where I build my build variant.
I faced somehow similar issue on Android Studio 3.6.3v
Entry name 'kotlin/collections/MapWithDefault.kotlin_metadata' collided
I resolved the issue by:
Delete build folder under /app
Clean project
Rebuild project
If still doesn't work, do the following:
File > Invalidate Caches/Restart
I just had a similar issue - my generating a debug build variant kept failing with an error about "Entry name res/layout/test_toolbar.xml collided". There is no "test_toolbar_xml" anywhere in my project. I first deleted all build directories and tried - same result. then I went in and deleted caches under .gradle\5.6.4, and under .idea folders. Tried again and this time I was able to build.
Building a "release" variant worked every time.
Delete apk file from subfolders project
try build.gradle
android {
packagingOptions {
pickFirst 'firebase-abt.properties'
}
}
If anyone is still facing this issue, try this -
Step 1
File > Invalidate Caches/Restart
Step 2
Rebuild Project
This is caused by the Android studio's new default packaging tool called zipflinger
You have to set the following in your gradle.properties file to fix the issue.
android.useNewApkCreator=false
Reference: https://developer.android.com/studio/releases/gradle-plugin?authuser=1#zipflinger
After upgrading Gradle, compilation (debug) failed. I got the compilation error message:
Entry name 'res/mipmap-hdpi-v4/ic_launcher.png' collided
Tried the article https://medium.com/#elye.project/resources-collision-without-warning-b29294f518c6 by Elye.
I am using a library where ic_launcher is also defined. I renamed the ic_launcher according to recommendations in the article, but that did not solve the problem.
Tried to clear the cache by deleting the build and gradle directory, but that did not solve the problem.
Tried to set in gradle.properties:android.useNewApkCreator=false but then Android Studio reports:
build.gradle: The option setting android.useNewApkCreator=false is experimental and unsupported.
Since I am not up to using experimental features, I downgraded from:
Gradle Version: 3.6.1
Android Plugin version: 6.2.1
to:
Gradle Version: 3.5.3
Android Plugin version: 5.4.1
Compilation (debug) now works again.
I faced the same problem. I just clean and rebuild, and it's working fine after that.
When getting a entry name 'kotlin/collections/mapwithdefault.kotlin_metadata' collided error in Android Studio v3.6.1 it helped cleaning the build folders.
We ended up creating a script for this: cleanBuldFolders.sh
#!/bin/bash
# Deletes all build folders in the project
find . -name build -type d -exec rm -rf {} +
I faced the same issue when using Android Studio 4.0 Canary 8.
I solved my problem by downgrading from:
Gradle version 3.6.3 to 3.5.3
Android plugin version 5.6.1 to 5.4.1
BUT
I would suggest try these below options before downgrading
Delete build folder inside app
Clean
Rebuild
If you still face the issue, try Invalidate Cache / Restart

Why gradle could not open cp_proj remapped class cache for a flutter plugin

I wrote a plugin with kotlin, which works as example.
I published this plugin without the example folder.
Now I want to create a flutter app with the public plugin
to test whether others can use the plugin.
I get a gradle error:
FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring project ':allocate_user_apps'.
Could not open cp_proj remapped class cache for 8qbsgj5slxel203zipat9627v
(C:\Users\gle.gradle\caches\4.4\scripts-remapped\build_1nm6t3qaagcrhueaws5c4rnfu\8qbsgj5slxel203zipat9627v\cp_proj638c4bcc3be846fd35262b91d5a74869).
Could not open cp_proj generic class cache for build file 'H:\Users\Public\Documents\prog\flutter\flutter_windows_inst.pub-cache\hosted\pub.dartlang.org\allocate_user_apps-0.0.1\android\build.gradle'
(C:\Users\gle.gradle\caches\4.4\scripts\8qbsgj5slxel203zipat9627v\cp_proj\cp_proj638c4bcc3be846fd35262b91d5a74869).
Build file 'H:\Users\Public\Documents\prog\flutter\flutter_windows_inst.pub-cache\hosted\pub.dartlang.org\allocate_user_apps-0.0.1\android\build.gradle'
should not contain a package statement.
Where I can search for failures?
Already tried flutter clean without improvement
Thanks for advice
Erhy
strange:
in
flutter_windows_inst\ .pub-cache\hosted\pub.dartlang.org \allocate_user_apps-0.0.3\ android\build.gradle
I deleted the first line
package android
and the problem was fixed.
From where was this line is created?
With modifications in the plugin project I could solve the problem:
In file settings.gradle of the plugin project already I deleted the first line
package android
also in the file build.gradle of the plugin project already I deleted the first line
package android
I encreased the version number in pubspec.yaml of the plugin project
and executed
cd to the plugin project base directory
flutter packages pub publish
After imported the plugin with the new version number
there was nothing to change in the app project.

Fail demo:transformDexArchiveWithExternalLibsDexMergerForMockDebug with a DexArchiveMergerException

After a rebuild I get :
Error:Execution failed for task ':demo:transformDexArchiveWithExternalLibsDexMergerForMockDebug'.
> com.android.builder.dexing.DexArchiveMergerException: com.android.tools.r8.errors.CompilationError: Program type already present: com.google.android.gms.common.internal.zzag
What does that error message mean? What is wrong?
when I replaces gradle implementation instruction by (the older) compile , it works.
The suggested workaround for this error is to delete the ./gradle folder inside your project or delete all the build folders and the gradle cache.
Additional references:
Dex error On Android Studio 3.0 Beta4
Unable to merge dex
Delete the .gradle directory.
Run your app again.
Notes
The .gradle directory is in your project's root folder. (You may have to show hidden files first.)
I have to do this every time I update a dependency module using Android 3.0.
Hope this helps!
This error (and any other Program type already present: com.google.android.gms.common.internal.xxxxxx error) can be caused by different Play Services and Firebase versions. Make sure all implementation 'com.google.android.gms:xxxx:12.0.0 and all implementation 'com.google.firebase:xxxxxx:12.0.0' have the same version (12.0.0) in this example.

android studio use sync project with gradle files action

I want to use sync project with gradle file in command line but I dont know how to do
like this :
It besides do ./gradlew build also do other things
For example, in a file is written to a local library name android-test
than in settings.gradle read this file and call include ":${android-test}" .if I use AS sync project with gradle files button,AS can load
module to project , but when I run ./gradlew build, it doesn't work.
But I have developed a plugins, and I want to use this action, so how to call this function ?
Building and syncing from the command line is really simple. In the root of your project you can invoke the gradle wrapper's build command with
./gradlew build
To get a list of all available build tasks for your project:
./gradlew tasks
"./gradlew build" and "./gradlew tasks" in the path of your project.
more commands and steps here:https://developer.android.com/studio/build/building-cmdline.html
The action id is Android.SyncProject, so you can call it in your plugin:
ActionManager.getInstance().getAction("Android.SyncProject").actionPerformed(e);
You can find it in android-plugin.xml, maybe line 161.
Also in SyncProjectAction.java, line 36 you can find its text.

Android Studio 0.4.3 - Unable to compile official Android Samples

I've got Android Studio 0.4.3 installed on my system and try to import and run the official samples from the Android Developers site:
http://developer.android.com/samples/index.html
Unfortunately when I try to compile I get the following error:
FAILURE: Could not determine which tasks to execute.
What went wrong: Task 'assemble' not found in root project 'ActionBarCompat-Basic'.
Try: Run gradle tasks to get a list of available tasks.
As you can see I tried to compile the ActionBarCompat-Basic example, but the result is the same for all samples.
I already tried to delete the <component name="FacetManager"> ... </component>
from my iml file and deleted the .idea folder like suggested in this thread:
Gradle: FAILURE: Could not determine which tasks to execute
This did not solve the problem. After removal of the files I imported the project to Android Studio and tried to compile. As a consequence the iml file and the .idea folder are generated again and the error message stays the same.
Anyone else got this problem? Any help is greatly appreciated!
Sample projects are using old version of gradle plugin which is no longer supported by Android Studio 0.4.3
Please do the following changes
Go to your module's build.gradle(like ActionBarCompat-BasicSample/build.gradle) file inside the project and replace dependency classpath at beginning by this
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
Change the distrubutionUrl in ActionBarCopat-Basic/gradle/gradle-wrapper.properties file to this
distributionUrl=http\://services.gradle.org/distributions/gradle-1.9-all.zip
If you are using gradle version 1.10 replace 0.7.+ to 0.8.+ and 1.9 to 1.10 in above configurations .
I am assuming you have already removed component FacetManager from ActionBarCopat-Basic.iml file and re-imported the project.
This worked perfectly for me.

Categories

Resources