In old times of Android Studio, when I had compilation error and something was wrong resources I could quickly click on the error and was pointing me to the file. Now I’m getting error com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed but there is nothing to click that takes me quickly to the file to fix an error. Can I find these links somewhere?
You can find the issue on your project using the build report on Android Studio. You just need to switch between views:
This view will show the gradle build logs, and most likely will contain the resources issue.
Related
We have started to see random errors in a Xamarin Android build in Azure DevOps that appear to be related to the localization of resource files:
/Users/runner/work/1/s/Apps/MyApp/MyApp.Droid/obj/Release/lp/187/jl/res/values-hu/values.xml(1): error APT2254: xml parser error: no element found.
/Users/runner/work/1/s/Apps/MyApp/MyApp.Droid/obj/Release/lp/187/jl/res/values-hu/values.xml : error APT2261: file failed to compile.
/Users/runner/work/1/s/Apps/MyApp/MyApp.Droid/obj/Release/lp/187/jl/res/values-hu/values.xml(1): error APT2254: xml parser error: no element found.
/Users/runner/work/1/s/Apps/MyApp/MyApp.Droid/obj/Release/lp/187/jl/res/values-hu/values.xml : error APT2261: file failed to compile.
We don't support localization in our app so I don't understand why the build is trying to create localized versions of the resources. We still see the error even if we specify <AndroidResgenExtraArgs>-c en</AndroidResgenExtraArgs> in the project.
The build doesn't always fail and when it does it fails for different language codes. We don't see the issue when building locally but this could because we would normally be building for debug.
Have we misunderstood what is happening here? What could be the cause of the issue?
I have an old android project that is having compilation problems. I've added a gradle.properties file to root with a single line:
android.enableAapt2 = false
However, I'm still getting this error:
Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT error: check logs for details
Which doesn't make sense to me because I've disabled aapt2 and it still seems to be using it. In addition, I've checked every log I can find with no additional information found on what is actually breaking.
As for your first question, the build is giving you an AAPT error, which might be coming from AAPT(1), not just AAPT2, that's why disabling AAPT2 doesn't "fix" it.
Secondly, disabling AAPT2 is not a solution. AAPT2 is telling you there's something wrong with your files. It fails the build early so that your app doesn't crash at run-time (which AAPT would silently allow).
Lastly, it's possible that you modified something in between the builds or that it didn't build in the past either. A way to figure out what the problem is, is to check the logs. If you're having trouble finding them in Android Studio (they will be in different places for different versions of Android Studio, Android Gradle Plugin and Gradle), an easy way to generate it is to go to the Terminal window in Android Studio and run "gradlew clean assembleDebug". The errors from AAPT/AAPT2 should be just above the stacktrace.
I'm an Android Studio noob and I'm confused about how it reports errors. I have a fairly large Android project - about 25 java source files - mostly Activities - and a similar number of XML files.
I do a Build > Clean Project and a Build > Rebuild Project, and the Gradle Console reports BUILD SUCCESSFUL. In the Messages tab it says:
BUILD SUCCESSFUL
Total Time 4.368 seconds
0 errors
0 warnings
But if I actually open up an XML file, e.g., the Android manifest.xml file, I see errors marked in red, such as
Cannot resolve symbol 'PlyListActivity'
and
Cannot resolve symbol 'ActivityMsgClass'
... those seem like errors to me. Yet the Android manifest.xml file is not marked or highlighted in any way in the UI - if I hadn't opened it in the editor I wouldn't have seen those errors. So short of opening up each of the 25 XML files in my project, how can I find out about such errors when I do a build?
Edit: Just to be clear - my question is not about what causes the errors listed in the manifest. My question is why does the build show 0 errors and 0 warnings, and is there any way in Android Studio to be aware of these errors/warnings short of having to open up each and every file (25 in my case) in the editor to look for them?
This is a very annoying bug, and it's been around forever. Unfortunanetly, there is no way you can fix it, this doesn't only happen to the Manifest but to the resources XML files too. However, your app will crash if there is a real error, not a warning.
However, there could be a way if you mess around Android Studio, I couldn't find this, but maybe you could:
Go to Android Studio. Go to File>Settings, alternatively press CTRL+ALT+S
Go to Editor>Inspections,now here, you can change all the errors in Android Studio to a warning, or nothing and vise-versa. This could solve your problem if you find your error in this window and disable it (Make sure it is Manifest Only). Otherwise, I hate to say the answer even for myself, there is no solution.
UPDATE: If you go to Analyze>Inspect Code you can see all your errors and warnings in your project.
This is not an error. This show both the class are not defined in your project as activity, but you have still defined in manifest as activity.
If you run the 'lint' gradle task, it should generate an webpage that details all the warning/error/issues it detects during build time.
Ran lint on variant debug: 11 issues found
Ran lint on variant release: 11 issues found
Wrote HTML report to file:///C:/Android/JsoupExample/app/build/outputs/lint-results-debug.html
Wrote XML report to file:///C:/Android/JsoupExample/app/build/outputs/lint-results-debug.xml
I have no Idea what is happening, last time when I finished my app I build its release apk and all was working just fine as expected but now today when I tried to make that pproject again and to make another apk I am getting the following error.
Error:Execution failed for task ':app:mergeDebugResources'.
Crunching Cruncher common_signin_btn_icon_pressed_light.9.png failed, see logs
I have no idea how to resolve it I have serached and found restarting Android studio and clean the project would remove it , doing this many times has no effect on this error. I have even restarted my machine but the condition of error in same.
In the logs I have seen that this png file is from the library I added , so just for testing I removed that library and tried to build then it started to give me same error with different png file name in other library. So how to fix this issue ?
My Questions are :
How can this issue be Solved ?
Have some one faced this problem too ?
Is this problem has been reported to google ?
Why in android we do not have any stable platform for development as IOS have ?
Try to remove "builds" folders and do rebuild. But soon, the whole thing in a long file name. Read this answer. By the way, you looked logs? Maybe this is not the PNG? You have not sent the log and did not specify the version Gradle.
Believe me, iOS developers have own problems.
When I attempt to run my Android application I get the following message:
your project contains error(s), please fix them before running your application
All I did was to clean the application and everything went wrong.
Normally, you would see a red asterisk against the offending file and the corresponding line with the error. But in this case I get no such indication.
Screenshots:
Sounds like you have a syntax error in one of your XML files, or an invalid file name.
When you do a clean it deletes certain files, it would then automatically build, if you have syntax errors the R.java file won't be generated and you will have the above error.
you can check in android console(window->show view->console),it will give some more information,check it once,check your build path if your are import your project somewhere else and the project uses 3rd party libraries or you may have problems with your XML resources.
Found the source of my mysterious error.
It turns out it was a imported java class I had forgotten about which I wasn't using and caused the error to showup when I "cleaned" the project.
I visited the build path where I saw it had an associated error. I removed it and all was well.