The Infamous R.java error - Android

So I have just started my first android app. I have been making some progress but have a long way to go. I got to a certain point where all the sudden I got the infamous "R cannot be resoved to a variable" error. I have been doing some research on this error and so far none of the solutions I have found seem to be working for me. So here is what I know....
* I don't have the R.java file that I should have.
* I have recreated the project many times and will then get the R.java file until I start bringing over some of the old files to the new project, with the same project name I should add.
* I have no images or files that have caps letters in their name that shouldn't or can't have them.
* I have not changed the project name in any of the files.
* I am doing a tabbed UI and the only files that will show as having errors are my "<name>Activity.java" files. Here is what the code looks like in one of the files.
Code:
package com.example.androidtablayout;
import android.app.Activity;
import android.os.Bundle;
public class SeedsActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.seeds_layout); }
}
* I have tried restarting Eclipse
* I restarted computer even
* I have tried everything I can think of and could find online and I am know at my wits end and hope some of you pros might have some ideas as to how to resolve this ever so annoying and frustrating problem.
Thank you all in advance for the help.

Well 24 hours later from the first post it seems im on my own on this. Well I can say after many many MANY hours of online research and troubleshooting I finally have the initial issue fixed, however, I am unable to run the app yet on my phone or on the VM. I just get the application quit unexpectedly error that we are so familiar with from time to time. Not sure if I will get help on the issue though it would be much appreciated, but I figured at the very least I would post an update.

Well, yea me. I figured it out after all. Thank you all ever so much for your help on this.

The problem is normally in one of the XML files. I find the hardest errors stopping an R.java file from being created to find are those in the Manifest file because eclipse gives doesn't let you know there is an error there.
I have to say your title intrigued me, I didn't realise it was infamous.
Good luck with your app.

Related

[Q] custom backup list - cyanogenmod 9/10

Hi folks!
Since when did the Custom Backup List feature disappear from CyanogenMod? It's not working with either CM 9 or 10.
I've created this file: /system/etc/custom_backup_list.txt
I've put a line like this in the file: app/[MY_APP]
It's really not working, the app is gone after a flash. This is not that much of a biggie for me since I usually replace all my custom SystemApps using updater-script in flashable zips, but I just wonder if someone knows if this feature is unsupported in CM9+ or if it's just an issue? I doubt it's an unresolved issue when the stable builds are already out.
Is this feature gone or what? Thanks!
try this
get one addon.d from /system/addon.d
make a copy, change the number to some random number
open it
at this part, edit this
Code:
list_files() {
cat <<EOF
[B]etc/hosts[/B]
EOF
}
change n' add stuff, replacing the file in bold. examples
Code:
list_files() {
cat <<EOF
[B]etc/init.d/s03anything
app/Apollo.apk
media/bootanimation.zip[/B]
EOF
}
then, save it, and next update it will be restored.
btw, if you are editing in windoze, make sure you edited on notepad++. even your custom_backup_list.txt must be edited there.
good luck
Thank you marcellocord, you did it again! Just wanted to say that you can name the file to whatever you want to, with the .sh extension.

[Q] My chinese tablet got into DEMO mode.

Hi, i bough a chinese tablet a few weeks ago.
I didnt intalled anything bad or risky in it.
And this night i got unexplicable popups, adds and applications that i didnt installed.
The source of this activity was a app called com.android.server and com.android.popupreciver
I unistalled them and then i rebooted my tablet, then i got a message saying DEMO.
I heard that the only way to solve this is a hard reset, but i would like to know if there is something else i can do.
=====
Else, i would like to know if there is any ROM compatible for a 7" chinese tablet.
Removing Demo mode from Chinese tablets
I have one of these and have not been using it for a long time due to all the unwanted ads and being unable to figure it out. The other day I decided to give it another try and this is what I found:
A lot of these cheap tablets comes with a trojan and on my A23 Q8H 7" tablet it was in CloudsService.apk. If you remove it the tablet will show big red "Demo" letters across the screen. This comes from the SystemUI.apk and when I decompiled it I saw the following:
Code:
private void showDemoOverlay() {
TextView textview = new TextView(this);
textview.setText("Demo");
textview.setTextSize(180F);
textview.setGravity(17);
textview.setBackgroundColor(0);
textview.setTextColor(0xffff0000);
android.view.WindowManager.LayoutParams layoutparams = new android.view.WindowManager.LayoutParams();
layoutparams.type = 2006;
layoutparams.width = -1;
layoutparams.height = -2;
layoutparams.gravity = 17;
layoutparams.format = textview.getBackground().getOpacity();
layoutparams.flags = 24;
((WindowManager)getSystemService("window")).addView(textview, layoutparams);
}
The above function in SystemUIService.java is indirectly called by this one
Code:
private boolean hasOTAServer() {
android.content.pm.PackageInfo packageinfo;
try {
packageinfo = getPackageManager().getPackageInfo("com.clouds.server", 0);
}
catch (android.content.pm.PackageManager.NameNotFoundException namenotfoundexception) {
packageinfo = null;
namenotfoundexception.printStackTrace();
}
return packageinfo != null;
}
So in short all it does is look for is a package called com.clouds.server and if it doesn't find it the Demo is displayed.
The solution is to create a blank app in Android studio, make sure the package name is com.clouds.server and then install it on the device.
Now this I call informed investigation! I was trying to get rid of the trojan on a chinese tab and after removing at least 5 apps and rebooting i got the DEMO overlay.
I found a blog post dealing with the same problem and this person provided an APK to install (I checked it via virustotal and it came back clean): cmcm.com/article/share/2015-11-09/840.html
How did you find out it was the SystemUI.apk showing the overlay? Or was it just an educated guess? I tried finding the app via dumpsys but couldn't see anything...
P.S.: THANKS!!
Surrogard said:
Now this I call informed investigation! I was trying to get rid of the trojan on a chinese tab and after removing at least 5 apps and rebooting i got the DEMO overlay.
I found a blog post dealing with the same problem and this person provided an APK to install (I checked it via virustotal and it came back clean): cmcm.com/article/share/2015-11-09/840.html
How did you find out it was the SystemUI.apk showing the overlay? Or was it just an educated guess? I tried finding the app via dumpsys but couldn't see anything...
P.S.: THANKS!!
Click to expand...
Click to collapse
It has been a while but if you extract all the APK files and run grep on them you should be able to find the one you are looking for. You can then decompile the APK to have a look at the source code. Another way would be to remove the apps one by one and reboot each time. When you find the APK which causes the Demo mode to be activated just replace it with a blank APK file with the same package name and it should be good. If that does not work then it could be that the tablet checks for more things which means you'll have to go with option 1. I would also not trust virustotal with this as there are many reasons why it could return a false result and it does not take too much skills to bypass virustotal checks.
The solution!
Just install a clean CloudsService.
Normal_CloudsService.apk
Mirror1: https ://drive .google .com/file/d/0B1CH2n58TrbiSFl4Y0twRk5LX3M/view?usp=sharing
Mirror2: https ://drive .google .com/file/d/0B65Tvd8zpsRPOFNLY2NTRVMxckU/view?usp=sharing
VirusTotal: https ://www .virustotal .com/en/file/a014b81ce3cbee336a705eb54a0d6081038d67cc34b65688304a3ee41861903a/analysis/1455333414/
cheers
ofernandofilo said:
Just install a clean CloudsService.
Normal_CloudsService.apk
Mirror1: https ://drive .google .com/file/d/0B1CH2n58TrbiSFl4Y0twRk5LX3M/view?usp=sharing
Mirror2: https ://drive .google .com/file/d/0B65Tvd8zpsRPOFNLY2NTRVMxckU/view?usp=sharing
VirusTotal: https ://www .virustotal .com/en/file/a014b81ce3cbee336a705eb54a0d6081038d67cc34b65688304a3ee41861903a/analysis/1455333414/
cheers
Click to expand...
Click to collapse
Thank you!
Note that you might need to do
adb uninstall com.clouds.server
before you will be able to install this one if you get "Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE]"
it works
I JUST INSTALLED THE APK POSTED IN THE FIRS LINK ... AND IT WAS MY SOLUTION..... I DO IT TO ZEEPAD 7DRK
---- drive.google.com/file/d/0B1CH2n58TrbiSFl4Y0twRk5LX3M/view#! -------
GREETENGS FROM MEXICO LEON GTO
....my english is bad .. i know i know.... jajajaj lool

Youtube Data API v3 - Help please!

Hi, i'm trying to develop one app for a youtube channel. This app will show the uploaded videos as a list (with some infos), show channel infos, trigger notification when a new video is uploaded and etc..
I'm a newbie in Android app development and i'm having trouble with the Youtube Data API... I saw the samples code from google, but when i copy it to my project and try to build it doesnt work at all...
Everything i did until now is just the basics and the designe (a part of it).
Do you guys have some app sample that does the samething i'm trying to do to help me?
Thanks.
I made some progress here, but now i need load the "client_secrets.json", but when i do the command "
getResourceAsStream("/client_secrets.json")", always return null.
The .json is inside "src/main/res" right now, but i tried in almost any other folder and changing the patch in code bellow but got no other result, just null exception ;/
Any help?
Code:
// Load client secrets.
Reader clientSecretReader = new InputStreamReader(Auth.class.getResourceAsStream("/client_secrets.json"));
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, clientSecretReader);

Google Chrome User Agent Android 7.x

Hi,
how can i Set Chrome User Agent to Desktop or chromebook on Android 7.x ?
Old User Agent Apps won't work on 7.x
I need to Set Chrome to Desktop view always on
Put a file in Data/Local called 'chrome-command-line', put this text in
chrome --user-agent="Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36" -force-device-scale-factor=2
Permissions 644, you can change the scale-factor to suit.
Sorry but this is Not working anymore on 7.x
Nobody ?
Just wanted to bump this as I'm also looking for a solution.
This has been bugging me for for a few days, very frustrating, seems like Chrome doesn't read the command line files in Nougat no matter where they are located, what they are called, or how you invoke the application. So I did the next best thing...
I grabbed the latest Chromium source code and modified user_agent.cc so it spits out a desktop UA instead. Cross compiling was a bit of a lengthy process, around 4 hours, but it works perfectly. The code alteration was quite trivial, I know this doesn't really help anyone here with a quick fix, and I really can't see Google adding a permanent desktop mode any time ever.
To make the change, just edit the following and rebuild:
<path>/src/content/common/user_agent.cc
PHP:
std::string BuildUserAgentFromOSAndProduct(const std::string& os_info,
const std::string& product) {
// Derived from Safari's UA string.
// This is done to expose our product name in a manner that is maximally
// compatible with Safari, we hope!!
std::string user_agent;
// base::StringAppendF(
// &user_agent,
// "Mozilla/5.0 (%s) AppleWebKit/%d.%d (KHTML, like Gecko) %s Safari/%d.%d",
// os_info.c_str(),
// WEBKIT_VERSION_MAJOR,
// WEBKIT_VERSION_MINOR,
// product.c_str(),
// WEBKIT_VERSION_MAJOR,
// WEBKIT_VERSION_MINOR);
// return user_agent;
return "<Insert desired user agent here>";
}
dtchky said:
This has been bugging me for for a few days, very frustrating, seems like Chrome doesn't read the command line files in Nougat no matter where they are located, what they are called, or how you invoke the application. So I did the next best thing...
I grabbed the latest Chromium source code and modified user_agent.cc so it spits out a desktop UA instead. Cross compiling was a bit of a lengthy process, around 4 hours, but it works perfectly. The code alteration was quite trivial, I know this doesn't really help anyone here with a quick fix, and I really can't see Google adding a permanent desktop mode any time ever.
To make the change, just edit the following and rebuild:
<path>/src/content/common/user_agent.cc
PHP:
std::string BuildUserAgentFromOSAndProduct(const std::string& os_info,
const std::string& product) {
// Derived from Safari's UA string.
// This is done to expose our product name in a manner that is maximally
// compatible with Safari, we hope!!
std::string user_agent;
// base::StringAppendF(
// &user_agent,
// "Mozilla/5.0 (%s) AppleWebKit/%d.%d (KHTML, like Gecko) %s Safari/%d.%d",
// os_info.c_str(),
// WEBKIT_VERSION_MAJOR,
// WEBKIT_VERSION_MINOR,
// product.c_str(),
// WEBKIT_VERSION_MAJOR,
// WEBKIT_VERSION_MINOR);
// return user_agent;
return "<Insert desired user agent here>";
}
Click to expand...
Click to collapse
Would it be possible for you to share the apk? This is frustrating me beyond belief after I moved to Nougat.
Found a solution for this problem, it was caused by a SELinux context which blocked read access to the command line file.
Download this script and copy it on the SDCard.
Install Android Terminal Emulator, then enter:
Code:
su
sh /sdcard/chrome.sh
- Testing 7.x fix. https://play.google.com/store/apps/details?id=com.linuxjet.apps.ChromeUA
jpeterson said:
- Testing 7.x fix. https://play.google.com/store/apps/details?id=com.linuxjet.apps.ChromeUA
Click to expand...
Click to collapse
Thank you. Is this working for anyone?
cobram3 said:
Thank you. Is this working for anyone?
Click to expand...
Click to collapse
It is available on the play store. I can not guarantee this will work, but I have tested it on my 7.x devices and 8.x devices and it is working on them.
Does not work on my OnePlus 5T on Android 8.0 rooted with Magisk.
Neither does the script posted above.
Any other ideas? I'm sick of manually selecting "view non crippled site" every time I open any webpage.
"Mobile" sites need to die!
EDIT: I figured it out, I needed to set the /data/local directory to be readable by all. (The script above already got the file permissions right for the chrome-command-line file, just not the directory it lived in). After that the user agent string seems to be working as it should and I can actually view useful webpages again!
Well, so much for that.
I wiped my phone and started over, and the same steps I used last time have no effect this time. I'm stuck in mobile website hell.
Anyone with any idea how to fix this?
EDIT: This seems to be related to the file permissions issue still, but I'm not sure how to fix it. When I'm not root, I get permission denied when I do an ls on the /data/local directory, despite that directory, and all the ones above it, being set 755. So whatever is blocking me from being able to ls that directory is also likely blocking the ability for chrome to read that file and behave like a useful web browser instead of a completely crippled one.
ve6rah said:
Does not work on my OnePlus 5T on Android 8.0 rooted with Magisk.
Neither does the script posted above.
Any other ideas? I'm sick of manually selecting "view non crippled site" every time I open any webpage.
"Mobile" sites need to die!
EDIT: I figured it out, I needed to set the /data/local directory to be readable by all. (The script above already got the file permissions right for the chrome-command-line file, just not the directory it lived in). After that the user agent string seems to be working as it should and I can actually view useful webpages again!
Click to expand...
Click to collapse
You can create a "chrome desktop"widget with that app,only by this way,it seems to work.
Unfortunately that only works for opening the browser and does nothing for links clicked in our applications.
Why do developers of websites hate mobile users? This isn't 1998 anymore, people want to access websites from their phones! We shouldn't have to resort to such ridiculous lengths to enable such basic functionality as a working web browser!
https://forum.xda-developers.com/showthread.php?t=1811101&page=13 #128
That helps quite a bit.
Now of course I've run in to another problem. AMP. google assistant and related products love to push AMP pages instead of websites, and chrome won't open them in desktop mode, only in mobile mode. I wonder if there's some way to convince Google assistant to behave and link to real webpages?
*sigh* it's amazing how far companies are willing to go to cripple their websites!
EDIT: Found it! DeAMPify in the play store translates all those external programs (like the google feed) to non amp versions before passing them to the browser.
With enough steps and work-arounds you too can have a functioning web-browser on your smartphone!
I'm here to confirm Wootever's script working on [ROM][8.1.0][STABLE][OFFICIAL][TREBLE] AospExtended ROM V5.4 [Z2 PRO]. I had already created the chrome-command-line file via file explorer and set permissions to 755, but it wasn't working. Customized the UA string to my liking, btw (X11; Linux Arm64).
The way G00gl€ is developing Chrome is fLIck1ng annoying, this is basic functionality being set aside because fLIck you. Latest Android Chrome versions (63 to 66) are a piece of sh1t imho.
Cheers
Wootever said:
Found a solution for this problem, it was caused by a SELinux context which blocked read access to the command line file.
Download this script and copy it on the SDCard.
Install Android Terminal Emulator, then enter:
Code:
su
sh /sdcard/chrome.sh
Click to expand...
Click to collapse
Does anyone still have this file?
Reupload
Reupload ulozto.sk/file/R55e4UbG3ppA/chrome-sh

Notification Limit per app - Android Q

Using a Q rom on my Sammy note 9 (exynos; with august security update).
On Q, android system notification is limited to 24 per app (on P it was 49).
Notifications beyond 24 are not showing in notification panel.
Anyone knows how to change it to 49 or even higher? What files / code should be modified and how? the 24 limit is unusable...
Thanks :fingers-crossed:

			
				
@BADtoBONE
The notification limit per app is hardcoded: MAX_PACKAGE_COUNT. You can observe this in the NotificationManagerService.java source code what is part of package com.android.server.notification.
Thanks!
I can't find the package. Can you verify the location?
Can I change it manually via root explorer to 75 for example? any effects of the phone or OS performance?
Anyone know a tutorial to allow more than 24 notifications?
Still stuck with this issue.
Saw this online -
If you run a custom rom/magisk you can patch services.jar to increase the MAX_PACKAGE_NOTIFICATIONS to 100. [/QUOTE said:
Anyone knows a Magisk module to fix that?
Currently running a custom rom but unable to locate and change the package settings.
Thanks!
Click to expand...
Click to collapse
BADtoBONE said:
Still stuck with this issue.
Saw this online -
Click to expand...
Click to collapse
Hah that was me.
I diddn't find a great way to do it in a way that works generally, but you can use - https://forum.xda-developers.com/t/module-smali-patcher-7-3.3680053/ to make it easier to patch the file yourself. You'd want to patch the enqueueToast function.
I'm having the same problem too, I migrated from iOS to Android in April, and it is incredibly frustrating that notifications from an app are dropped after they reach 50, in iOS there is no limit. I've tried extracting "services.jar" to locate "NotificationManagerService.java" to patch the "MAX_PACKAGE_NOTIFICATIONS" count to higher than 50, but it wouldn't work. I had great difficulty even extracting the .jar to begin with. I tried extracting it to .java, but it kept coming up with errors, so it wouldn't extract it fully. I had to resort to extracting it to the .smali format (using apktool, baksmali etc), which extracted it fully, at least to the best of my knowledge, but it is very hard to read. I was able to locate "MAX_PACKAGE_NOTIFICATIONS", which reported a count of "0x32" (50 in hexadecimal), so I changed it to "0x3e7" (999 in hexadecimal), but it didn't work, it still stopped at 50.
@ajolly
I noticed on Twitter that you seemed to be able to successfully remove the limit:
twitter.com/jolly/status/1201266208944705536
May I ask, how did you end up doing this? You mention using "smalipatcher", but when I run it, it doesn't mention "enqueueToast" anywhere, unless I'm missing a step. Forgive my naiveness, I am still rather new to the whole "Android tinkering" scene.
Any help would be greatly appreciated, as this is driving me up the wall.
Thanks
Following.
I run MIUI 12.6 and the limit is set to 9 or 10. I would love to find a way to change the limit as well.
Thanks!
_csd said:
I'm having the same problem too, I migrated from iOS to Android in April, and it is incredibly frustrating that notifications from an app are dropped after they reach 50, in iOS there is no limit. I've tried extracting "services.jar" to locate "NotificationManagerService.java" to patch the "MAX_PACKAGE_NOTIFICATIONS" count to higher than 50, but it wouldn't work. I had great difficulty even extracting the .jar to begin with. I tried extracting it to .java, but it kept coming up with errors, so it wouldn't extract it fully. I had to resort to extracting it to the .smali format (using apktool, baksmali etc), which extracted it fully, at least to the best of my knowledge, but it is very hard to read. I was able to locate "MAX_PACKAGE_NOTIFICATIONS", which reported a count of "0x32" (50 in hexadecimal), so I changed it to "0x3e7" (999 in hexadecimal), but it didn't work, it still stopped at 50.
@ajolly
I noticed on Twitter that you seemed to be able to successfully remove the limit:
twitter.com/jolly/status/1201266208944705536
May I ask, how did you end up doing this? You mention using "smalipatcher", but when I run it, it doesn't mention "enqueueToast" anywhere, unless I'm missing a step. Forgive my naiveness, I am still rather new to the whole "Android tinkering" scene.
Any help would be greatly appreciated, as this is driving me up the wall.
Thanks
Click to expand...
Click to collapse
Smalipatcher will pull the services.jar file for you, then you can decompile it.
The code is something like:
// Limit the number of toasts that any given package except the android
// package can enqueue. Prevents DOS attacks and deals with leaks.
if (!"android".equals(pkg)) {
int count = 0;
final int N = mToastQueue.size();
for (int i=0; i<N; i++) {
final ToastRecord r = mToastQueue.get(i);
if (r.pkg.equals(pkg)) {
count++;
if (count >= MAX_PACKAGE_NOTIFICATIONS) {
Slog.e(TAG, "Package has already posted " + count
+ " toasts. Not showing more. Package=" + pkg);
return;
}
}
}
Warning, at least for me when I put it too high binder would start crashing, I set it to 99.

Categories

Resources