"Cause: invalid code lengths set" error. The run tasks ended at App:packageDebug. From the long list of things, three under compiler are more informative I guess:
org.gradle.tooling.BuildException: invalid code lengths set
java.util.zip.ZipException: invalid code lengths set
java.lang.IllegalStateException: Still waiting to inspect output APK's res/raw/shape_predictor_68_face_landmarks.dat
On the right side there was: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:packageDebug'.
I searched all over the places and tried everything I could find, but it did not work. Also, I cleaned the cache and restarted, I tried different emulator and devices. I also tried different project settings and structure settings. I also noticed that a very similar post was not answered: build failed because of "org.gradle.tooling.BuildException: invalid code lengths set"
Related
I am trying to work with Jenkins however I cannot build the apk with it as I am having issue with AAPT2 and Gradle.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Multiple task action failures occurred:
> A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> Android resource compilation failed
ERROR:C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-3\b478eb984dbbd1317dab9bfd9689b3aa\transformed\appcompat-1.3.0\res\drawable-hdpi-v4\abc_list_divider_mtrl_alpha.9.png: AAPT: error: file not found.
> A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> Android resource compilation failed
ERROR:C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-3\b478eb984dbbd1317dab9bfd9689b3aa\transformed\appcompat-1.3.0\res\drawable-xhdpi-v4\abc_list_divider_mtrl_alpha.9.png: AAPT: error: file not found.
> A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> Android resource compilation failed
ERROR:C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-3\b478eb984dbbd1317dab9bfd9689b3aa\transformed\appcompat-1.3.0\res\drawable-mdpi-v4\abc_list_divider_mtrl_alpha.9.png: AAPT: error: file not found.
I already read tons of SO question that may share same issue to my case saying that it has something to do with the file path being too long but I still cannot find any solution.
UPDATE
I tried to change Android Studio Gradle home similar to what Jenkins is using and received similar error which indicates that it may really have something to do with long file path.
I think the final question will be how to change Jenkins Gradle Home?
You need to replace \ with \\ if you are giving path with jenkins in Windows.
May be if file path is too huge or that is the root cause you can try mounting the directory to a short path
EDIT : Based on your modified question :
Open Jenkins dashboard. Navigate to Manage Jenkins-> Configure System. Under the Global properties section add another environment variable named GRADLE_USER_HOME as shown below.
I ran into this exact issue, but unfortunately changing the GRADLE_USER_HOME environment variable did not help, as aapt2 appeared to ignore the change and still used Windows/system32/... for the cache location.
The problem was how I was running Jenkins as a service. In the service.msc settings, it was set to Log On as a Local System account, which set the USER_HOME variables to C:\Windows\System32. Because of this, the reason the error said that the file did not exist was because Jenkins/gradle did not have access to the System32 folder.
My fix was to change the log on method to 'This account', then enter a user account so Jenkins wasn't logged on as system anymore.
I tried to generate code report using detekt and when execute the below command in terminal
gradle detekt
it showing build failed with below message.
* What went wrong:
Execution failed for task ':app:detekt'.
> Build failed with 395 weighted issues.
As others have said in the comments, this means you have 395 issues in your code (kind of like lint warnings).
Detekt has a maxissues: property that determines whether or not to fail the build if your issues surpass the allowed number of maxissues. What I did was search the whole project for maxissues, which will take you to your detekt-config.yml or default-detekt-config.yml. There, you can change your maxissues to whatever you want.
In our old code base, we had 900 some issues, so I changed mine from maxissues:0 to masissues:1000. As we clean up the code, I hope to bring that number down.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:mergeDebugResources'.
Multiple task action failures occurred:
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
AAPT2 aapt2-3.6.2-6040484-windows Daemon #12: Compile 'C:\Users\Abh\AndroidStudioProjects\MyApplication\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-th\values-th.xml' timed out, attempting to stop daemon.
This should not happen under normal circumstances, please file an issue if it does.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
AAPT2 aapt2-3.6.2-6040484-windows Daemon #9: Compile 'C:\Users\Abh\AndroidStudioProjects\MyApplication\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-en-rAU\values-en-rAU.xml' timed out, attempting to stop daemon.
This should not happen under normal circumstances, please file an issue if it does.
This is the issue, I keep getting whenever I try to run flutter.
Could anyone provide a solution to this...please?
Without seeing the whole picture it is really hard to say, though, according to official documentation About AAPT issue seems to be related to your resource bundle. Check if you are using everything correct links to your resources. I believe issue have occurred in your .xml files values-th and values-en-rAU. It is a good idea if there are some strings marked as translatable check if there are corresponding values in those file
My app is for view images When user click on next button show next image or back button show the previous image, the problem started When I tried to run the project I see some error about images size
"The file is too large; 80.83M. Showing a read-only of the first 2.56M".
I tried this solution the privous message is disappered but I still see some errors
Error:error: failed to read data meta data.
Error:failed parsing overlays.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':app:processDebugResources'.
> Failed to execute aapt
The first error
The second error
1) Write android:largeHeap="true" in your manifest under application.
2) Go to File -> Invalidate caches/restart -> Just restart. This will clear all caches.
3) Go to Build -> Clean project
4) Go to Build -> Rebuild project
Why do you need a PNG this big? A good practice is to keep your APK size as small as possible, with a reasonable size for an app like yours around 4MB. Even if you crunch these PNG images they will still be way too big and result in a huge size of your APK.
According to the Android Developers' guide:
Users often avoid downloading apps that seem too large, particularly
in emerging markets where devices connect to often-spotty 2G and 3G
networks or work on pay-by-the-byte plans.
More info: here
The method count for my app apk in the apk analyzer is shown as 62481. It's close but still not over 64K. There's no other .dex file, only the highlighted one. I still get the "The number of method references in a .dex file cannot exceed 64K." error while running the app. If I make it a multidex application it executes without any issues.
Is there something I am missing?
Thanks in advance.
PS. I also used an online tool at http://inloop.github.io/apk-method-count.
It also shows the same count.
Stacktrace:
Error:The number of method references in a .dex file cannot exceed 64K.Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
Error:Execution failed for task ':app:transformClassesWithDexForDevDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.android.dx.command.Main with arguments {--dex --num-threads=4 --output D:\Xyz\abc\app\build\intermediates\transforms\dex\dev\debug\folders\1000\1f\main D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_1db0d0b69914354c7a1f54768d6d2b5c56a14a07.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_836009343e593bdd8d97066c1d4d35a4bac1ee03.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\logging-interceptor-3.2.0_e343134b40348a9375191b04bcb9815ad536eeb2.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\support-annotations-25.3.1_0ba0705a7d535784c50abb2c1df9c6ecd3b76c98.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_2e91d022d43bd04e01ff1ad098ec0770289b4c62.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_2e8f50ec08e5c86040aa91ab1741d7343a67f4f8.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_56c577ef5726762c4031ca5dda95111b9dc7e458.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_8a11d8b5e54b85a6e1de144a7cb6b1a4e6fd4ab4.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_60ec19e545d0173331896d4142d37b46059c43a3.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_7f0598945bce91b289e292f0f55a3b3d72fbf351.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\jackson-core-asl-1.9.7_f4c11563ba078112f420d3670220ff4b972681f9.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_30f2ee70b7f228236ae4edfc7d2c64f9216386c9.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_59a52153273d00e2e703ed0658850f6a5d884966.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\okhttp-3.8.0_9dc1c3bb542549a12a11d8322d4a6481d2d02cf0.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_b2bda403ff0525ec0227a0f80e19afca69d12b67.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\butterknife-annotations-8.2.1_3a165264321d2f81fe77b7c2637671018e4cac57.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_cc143144ac466f41255b7f36bfbd3d0ea695a209.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_824200b22e8ea74a383eac9a277e3ac2464aa539.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_a4e001df1fa4644f23dcefc07868e903a5607863.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_e2ecd357ba3fb919c3a438530d0290e93647178a.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\retrofit-2.3.0_68728c00c537fecad305d89fa97c2421840a623a.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\eventbus-3.0.0_e0bff5f7960a2e7ecac4f69bde0f78a82ca5e63d.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\jackson-mapper-asl-1.9.7_5369f60c40e50a63d03a92ef2ae29385677ceb8f.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_c6b3c7487cd2e972f77ca0e03bb19710c73e53e0.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_91361bf27fc5b6e472e367aa00f031bba7c4c20a.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\pgsdk_645c5225a64fe7c0b1a59aec735ebc050640f22d.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_f85f3afb04ff29a87a12af3638aef9aae6220a24.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_a1fc8b96a2a8c9acf7c645a9259c58c41a1f26fd.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_a7d0bdd1c2bdc70470127f504b003285bc078fe9.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\rxjava-1.1.1_8e601112604030616d0454987beb13c6bd5559f7.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_cf60fb6a5a8e2e831c1ac5e904054d7cae4fb66b.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\bolts-android-1.2.1_747b105f3d05185ddbb7f3461fcfcfb14fd400ad.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_3df31fa2a2dfd25d1ef407482294b0a9e4681dd4.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_880f0190688e96d2158375d20eb2b6a3ad0a1c00.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_a9174f45b029718961bea6288c5ab72b69c8d83c.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\adapter-rxjava-2.0.1_e254eec75d7b47f606b6044afe4f5de923c90209.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\library-2.4.0_aa6ede67eeee82afb5059b7cc11f144669e8d317.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\glide-3.6.1_eaf678ca6bb624fad8c858722d2c87b6d59be41a.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_7daee3352899d51e4a9fe3f8b397499be0258db8.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_8f9dc6ff8f790bc8764ce044b5b1932958f23f34.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_30f0950a769a9270e254c7ca0c6a59f5f6401d22.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_4a2b2594a565922e474f16ffba114c7002d1a6cb.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_30fe7465623d9f918d58d6edc58452e68aefdace.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_df3ee71424be542d1c2312a5b88578621627461a.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\converter-gson-2.2.0_243824882f104fb7a674d1f7f050d17f53106431.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_411c4b35195250868998df3b091d787100369a10.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_d2afcb23c7f7377b02c40aa75147aaa062228f64.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\httpclient-android-4.3.5_f8796db42b8aa66927828d31c761f0fddedbb772.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\okhttp-urlconnection-3.2.0_d542fad0507536391190065b8f9437055ccb7ec4.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_aba481f309d2fb09d40e15dd99edc01c161c6ad6.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\android-auto-scroll-view-pager-1.1.2_c97341019a7b0d29b9d66da4f9922ddf63d2d79d.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_bed303341316ad80fca44d4ef59f78e331db2eea.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\okio-1.13.0_c8981a062393bcce02a0a96d7eada6216359b2c1.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_ecae2ffa55c32320769f0dbad6bfc31f8fe4b89b.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_1a190aa1f8a574c091a5817b5f14c3eb6fc7d54d.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_47e5bef139248db621fc15da425e6ef000f8d1bd.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_0f5cd2cb52b7d4f288ad9e8011572878dd28daf1.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\httpmime-4.3.6_c281370eb9c8ee9d741d91e11bb30c8e896b2a58.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\okhttp-2.3.0_4e123907da30c2cd9d1f9862f2daa77436911e75.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_79b6efa0386df702de375178db0cc4c91ee16251.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_7b485f1753fd8a21285f68f4a5e82b3c9e3b7ce5.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_fffbb83068c9bb8ccc07ebafbdf10bfbb39a5ed3.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_0c6da562aac3d9ee3da240276b4588219e13286d.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_4cb6cc03b1dfb6968d9ba10603ae4401cffc9ee4.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_7109e5c327c1f89c08882b5cd1861f4316a13978.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\gson-2.7_7ed1d08353e6bed2c04dde33c5774a7d806dc0e8.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\javax.annotation-api-1.2_8c1b8b35c9219706f347411da651634f419b0bc5.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_8b802d0ed2c87696bde342b3a35978ec09593815.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_ff73a2835210f90ea5eb74d9ee7d3d53acc7d0bd.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_8136d3746547bd087e4415cc0d16dea272792c80.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_9efdaefe6637a742ef19f1d0780d46930c401498.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_3993fa06956ed2627c1c4a6d5fb8e2698532576f.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_973b2919579e6677a87ed69b39531a634cc9caf5.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\okhttp-urlconnection-2.3.0_c4971a2461656fb7836c771c25274b1b14cbdd47.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\debug_41a4fb652b966a530aadf11ba3e268e403f48a5d.jar D:\Xyz\abc\app\build\intermediates\pre-dexed\dev\debug\classes_af64895670d5e2390fb265b2c8fec8bbd127ec31.jar}
Ok. This was one of those oops issues.
The apk I was analyzing was a release build with minifyEnabled true. But while executing the app debug build was selected for which proguard was not enabled and hence the error.