When I clean the android project in android studio, the error happen, I have backed to previous commit or different branch, which works find couple days ago, but has this error now. I have checked this question and there is not large image or strings added for my project. STRING_TOO_LARGE String in Kothlin
I had encountered the same and fixed by clear the build cache .
I was stuck on this problem and read through this topic and no one provided a future solution. I did NOT want to revert back my Gradle. Therefore, here is the link to the updated dependencies https://github.com/stripe/stripe-android. Look for the "Android Studio (or Gradle)" section and you should see this "implementation 'com.stripe:stripe-android:8.1.0'" also you might need to add "-keep class com.stripe.android.** { *; }" if you are enabling minification in your build.gradle file.
Overall Stripe has stopped updating their own "Stripe docs" which can be found here. To give them credit their docs are helpful and should be read at least once, but be mindful that most of the docs are out date when I wrote this...
Hope this helps :)
You can use AAPT (from the android sdk/build-tools) to examine the APK and look for the offending string with the following command line (Linux):
// Linux/Mac
./aapt dump --values resources MyAppName-regular-debug.apk | grep -B 1 'STRING_TOO_LARGE'
// Windows
aapt dump --values resources MyAppName-regular-debug.apk | grep -B 1 'STRING_TOO_LARGE'
Which should point you to the culprit. In my case it was:
resource 0x7f0f015a com.example.app:string/eula: t=0x03 d=0x00000f10 (s=0x0008 r=0x00)
(string8) "STRING_TOO_LARGE"
For the time being, you can downgrade Gradle version to resolve this issue.
Use gradle 3.1 version like 3.1.3 below.
classpath 'com.android.tools.build:gradle:3.1.3'
It happens that I had an SVG too long (90Kb). So I've opened de SVG in Adobe illustrator, simplified the path to a significant number of vector less so the new icon weight 3Kb and, finally, imported again in Android Studio.
You can have a look at your Project in Android Studio and watch if your SVG drawables are larger than needed for an icon.
just use <?xml version="1.0" encoding="utf-8"?> before in your drawable file.
Example:
<?xml version="1.0" encoding="utf-8"?>
<vector
android:autoMirrored="true"
android:height="24dp"
android:viewportHeight="490.282"
android:viewportWidth="490.282"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path
android:fillColor="#fff"
android:pathData="M0.043,245.197c0.6,10.1 7.3,18.6 17,21.5l179.6,54.3l6.6,123.8c0.3,4.9 3.6,9.2 8.3,10.8c1.3,0.5 2.7,0.7 4,0.7c3.5,0 6.8,-1.4 9.2,-4.1l63.5,-70.3l90,62.3c4,2.8 8.7,4.3 13.6,4.3c11.3,0 21.1,-8 23.5,-19.2l74.7,-380.7c0.9,-4.4 -0.8,-9 -4.2,-11.8c-3.5,-2.9 -8.2,-3.6 -12.4,-1.9l-459,186.8C5.143,225.897 -0.557,235.097 0.043,245.197zM226.043,414.097l-4.1,-78.1l46,31.8L226.043,414.097zM391.443,423.597l-163.8,-113.4l229.7,-222.2L391.443,423.597zM432.143,78.197l-227.1,219.7l-179.4,-54.2L432.143,78.197z"/>
</vector>
None of the above solutions worked for me. What ended up being the cause of the problem was, as it states, a String that was too large. Specifically, in my arrays.xml file under the values directory, I had some SVG arrays that were used within my app and commenting them out solved the issue.
If you know for certain you have some longer Strings somewhere in your resource directories (/res), check for any large Strings that may be lurking.
Also, this solution may help others but was not linked to in this thread.
I've been hunting for the source of STRING_TOO_LARGE errors in our build for a long time and none of these solutions worked. The reason none of them worked was that I had progaurd turned on in debug builds so when the string was replaced it didn't end up in the apk. When i disabled progaurd for debug builds, built the apk and then decompiled with apktool as suggested elsewhere
java -jar apktool_2.4.1.jar d debug.apk
and found the xml file that was in another library but progaurd stripped out before:
grep -r "STRING_TOO_LARGE" ./debug
Hope that helps someone
I found an SVG file that had a very long pathData. I commented it out and the error went away. That very same vector (when called) at runtime would cause a crash (before it was commented out).
clear your gradle in windows
gradlew cleanBuildCache
in mac
./gradlew cleanBuildCache
then building you apk if your project has problem it will be show you in the 'Messages'
view. location your problem and fix it. run agent.
The issue is caused by the AAPT/AAPT2 (Android Asset Packaging Tool) which processes your app’s resources and replaces them with the STRING_TOO_LARGE value when it finds a large string.
Find out for which one cause this problem.
To find out follow below steps:
A. Best Way:
Generate build APK
Decompile APK using any decompiler and download it.
Open it in any editor(Ex. VS Code)
Then search "STRING_TOO_LARGE" text globally and you will find affected files.
B. Another Way
The simplest way to find out, Builds an APK and analyze it. Select Build > Build Bundle(s) / APK(s) > Build APK(s). When the build completes, a confirmation notification appears, providing a link to the APK file and a link to analyze it in the APK Analyzer.
If you take a look into the the vector drawable file affected by this issue, you will find something like this:
I found this solution from Here
Just use gradlew cleanBuildCache in your Android studio terminal
In my case, i deleted a view from xml but forgot to remove its references in my kotlin code. Make sure to check this before doing anything fancy.
I found the answer from a duplicate question for Kotlin from here
Add <?xml version="1.0" encoding="utf-8"?> to the top of any resource .xml file that is missing it. (check your layout xml files, specially)
For me "gradlew cleanBuildCache" did not work, and running aapt dump --values resources MyAppName-regular-debug.apk | grep -B 1 'STRING_TOO_LARGE' did nothing either...
I ended up just deleting all my vector images since they were all pretty large and that fixed my build.. So I guess I'll have to add those back in a way that does not throw the error again..
In my case, I had renamed the package and the output-metadata.json contained the old package name. Renamed the package name there, and it was fixed.
In my case, the problem was due to the following lines in the manifest:
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name"/>
Once I deleted them, the build went fine.
In my case I declared a string variable in xml using data binding without assigning a value to it. by setting value to variable problem resolved
Windows 10 Solution
Finding the file with the error: use a online decompiler if it's not a problem is some one else sees your code. Download .zip file. Open up notepad++ search -> Find in files -> STRING_TOO_LARGE -> Find all.
If the problem file is a vector asset:
Vikasdeep Singh has a great solution: avocado. Avocado will make the vector file smaller.
I had this problem and clearing the cache or updating the Gradle plugin version was not a solution
To solve the problem I had to change the name of the longest XML file to make it a bit shorter, and right after doing that the problem was solved.
In my case I use Invalidate cache and restore
go to file/Invalidate cache and restore
instead of this
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
Replaced it with this in the gradle.properties
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=STRING_TOO_LARGE
Firstly, is it legal to use the dark theme of JavaFX's SceneBuilder 2 in my application? Since it is open source now here: SceneBuilder/css
Secondly, how to do this if legal? Or just for training purposes if not legal?
I tried to download the ThemeDark.css file from the link above and add it to my fxml file, but i see no change applied.
Any ideas ?
Edit (what I did):
I have downloaded the .css file and pasted it in package css.
Then I added these lines in my .fxml file (with the <> symbols but I removed them in this question as they hid the text if present) :
stylesheets
URL value="#/css/ThemeDark.css"
/stylesheets
See below resulting screenshot: (themeDark not applied)
If you are using SceneBuilder you can add a global css sheet to it and be happy with the new look.
Alternative, if you want to set it within your code you can use
scene.getStylesheets().clear();
scene.getStylesheets().add("path/stylesheet.css"); // Modify to your path
to add a style-sheet. Notice that you should put your style-sheet in a resource folder in your application, just to keep everything cleaned up.
Where is the R.java file in Android Studio? Can someone please help with this? I already tried google for the answer but can't find any solution.
Based on the new stable release of Android Studio (3.6) we have:
So, now to find your generated resource classes you need the following steps:
1) Open your project.
2) Go to your module build path.
3) Open the outputs/apk/debug/app-name-debug.apk file.
4) Choose your classes.dex file.
5) Look at the down placed area and go to your full package path.
6) You can see all bytecoded resource classes. So, scroll down to what you are looking for.
7) Expand the resource class you need to proceed (for example, let it be R.id)
8) Go to you id's.
That's it.
UPDATE:
If you would like to see actual id integer number you should follows steps below:
1) By (7) Go to the resource class you need to proceed and right click to show the context menu
2) Choose "Show Bytecode" to see the flexible dialog "DEX Byte Code for R$id", for example, for id class
3) Scroll down to the actual id to look its number
Although the current Android Gradle Plugin doesn't generate a R.java anymore you can still inspect the corresponding class file (see Sergey V.`s answer).
However, if you (like probably in most cases) just want to look up the generated IDs for your resources, there is an easier way:
In the project pane on the left hand side switch from Android to Project view using the drop-down at the top. Then navigate to app/build/intermediates/runtime_symbol_list/<insert build type here>/R.txt. This file lists all IDs generated by AGP during the build process.
I use Android Studio 3.3.2
\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\android\support\constraint\R.java
As noted above, "The new Android Gradle Plugin generates the corresponding bytecode directly and does not make the intermediate R.java file".
Using the ubuntudroid solution you can find an id also this way. Find R.txt and copy absolute path. Project > app > build > intermediates > runtime_symbol_list > debug > R.txt. Then right click and select Copy Path..., 1. Absolute Path Ctrl+Shift+C.
This way you will obtain a path to R.txt, for instance, "C:\Users\user\AndroidStudioProjects\your_project\app\build\intermediates\runtime_symbol_list\debug\R.txt". Copy the path without R.txt to a text file for future references, for example, with Notepad++.
Press Ctrl+Shift+F to find in directory. Insert an id and the path.
== Old answer ==
Change a project view from Android to Project or Project Files. Find one of these two files.
Then you can revert back to Android view.
I use Android Studio 2.3.3. The R.java file is shown in the picture above.
In the left upper side, there is a select list. Select the [project] option so that you can see all the folders and files.
R.java is the generated file by ADT or Android studio. It will be located under app\build\generated\source\r directory.
./app/build/generated/source/r/debug/android/support/v7/appcompat/R.java
./app/build/generated/source/r/debug/your/packagename/name/R.java
I am using Android Studio 2.2.3 , the R.java file is shown in the picture below.
Goto in the left upper side there is a selecting list ,
select [package]
Open "App Folder"
com.example.saeedanwar.myapplication;
r
In my project in Android Studio 4.1
R.jar that you can actually unzip resides in app build folder, as follows:
jar -xf R.jar
Once the jar is unpacked you can find R.java inside of app package:
If you're using Mac or Linux, try the following command line on your terminal:
find . -name "R.*"
It will print something like:
./app/build/intermediaries/runtime_symbol_list/debug/R.txt
./app/build/intermediaries/compile_and_runtime_not_namespaced_r_class_jar/debug/R.jar
It is inside app\build\generated\source\r folder
Project/app/build/generated/source/r/debug/com.android.'projectname'/R.java
--The R.Java that contains your xml layouts and views id's in Android Studio 3.5.3 -- Project/app/build/generated/not_namespaced_r_class_sources/debug/r/com/"your package"/R.java
This answer will be in a constant state of flux until Android standardize a method of matching their annoying decimal/hexadecimal id references to a tangible resource such as my_layout.xml.
For Android Studio Dolphin | 2021.3.1 Patch 1 have a look at this file:
/project/package/build/intermediates/stable_resource_ids_file/debug/stableIds.txt
It is produced by RUN (not just BUILD). Sample:
layout/mtrl_picker_header_fullscreen = 0x7f0d00de
string/cancel = 0x7f1101f0
style/ThemeOverlay.MaterialComponents.MaterialCalendar = 0x7f1202f3
id/gpxBtn = 0x7f0a0346
When I create a new project with API14 as minimum, then there is no values-21 or values-22 folder in my project. I don't see any styles.XML anywhere, so how should I put in XML code for just Lollipop?
I use Android Studio 1.0.1, and I have SDK 21, 21.1.1, 24.0.2 installed.
Updated: Since API 22 has been released. API 23 is the same idea.
Right click the RES folder
Then type values-v22 as the directory name and choose xml as the resource type.
If you do NOT see the values-v22 show up, click the Project pulldown at the top of the screen like so. e.g. Change from Android to Project
Now right click styles.xml in the values folder and choose copy
Now right click the values-v22 folder and click paste.
You should see this popup
Click ok
At this point you should be good to go.
It is just a bug! Anyway I find a way to get it back:
Write anything in styles.xml that is related to new material theme
example: <item name="android:colorPrimary">#color/colorPrimary</item>
It will show you an error hover over it and press Alt+Enter.
choose the first choice Override Resource in values-v21.
I know it isn't the best way to do that, but it works until anyone can find a better way.
Try to switch from Android to [![Project][1]][1] as shown below
I am developing an Android app using Phonegap and jQueryMobile, working in Eclipse. I want the app, with the user's permission, to auto-install a launcher icon on the user's "desktop". I've found the example LauncherShortcuts.java on Android Developers, and I am almost to the point of getting it to work. That's a big achievement, since I know extremely little of Java programming.
Almost.
This is the example code online:
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/LauncherShortcuts.html
One string or thingy in the code refuses to cooperate. Line 83...
TextView intentInfo = (TextView) findViewById(R.id.txt_shortcut_intent);
...has this constant or variable in it called "R.id.txt_shortcut_intent", and Eclipse says it doesn't recognize the id part. If I follow its suggestion of adding a class 'id' in R., it tells me there is no field txt_shortcut_intent in 'R.id'. That doesn't surprise me.
I've been able to fix a few similar errors involving R.something_or_other. But not this one. My R.java only contains the classes attr,drawable,layout, and string.
What is going on here and most importantly, what should I do to get this thing up and running? The launcher icon is all that stands between here and actually launching the app (how ironic).
If you find any errors in the project. Sometimes id of R.java entries will be shifted to string folder or R.java.
For this choose
project → clean
file → close all
click on your project
See the entries in id of R.java your ids will be in this folder
An android app uses an xml to define the layout of all the elements you want to display. In this case, you're missing an element that displays text called TextView. You don't have the Textview 'txt_shortcut_intent' defined in the xml, probably.
Here's the xml you're looking for (just copy and paste it into your main.xml):
http://developer.android.com/resources/samples/ApiDemos/res/layout/launcher_shortcuts.html
The ADT Plugin in Eclipse can only rebuild the R class if there are no (Java) errors.
Therefore, fix all errors and check if your layout ressource has the correct id (txt_shortcut_intent).
It's worth a try to clean the project and restart Eclipse.