[Q] Issues with Eclipse R.id - Android Q&A, Help & Troubleshooting

Intro(Probably Not That Important)
I was looking into making an mobile app for my organization so anybody can keep up with it on the go, so I started to look into the Tutorial XDA has on youtube. I looked around on the site and didn't really see anything that correlated (then again I could just suck really bad at searching this early in the morning).
Problem
I seem to be having trouble with R.id and my button not showing up as a field/can't be resolved. The error I am getting is "button1 cannot be resolved or is not a field". The code I have for the line is directly out of the video.
Code:
final Button button1 = (Button) findViewById(R.id.button1);
Thanks.

Have you declared 'button1' button in your layout .xml file?
You should have something like this in your .xml file:
<Button android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Tip: Sometimes you need to 'clean' the project. Go to Project -> Clean if you are sure you have declared everything but Eclipse says that you haven't. For that, every XML file should be well written.

Related

Almost working: Stock 2.1 Nook Color Reader and Library

I am trying to get the Library and Reader apks from the 2.1 working on cm7. I am fairly close (I hope), the next thing I have to do is sign the apks with the same key as the other apks that share the "media" userid.
If you copy over the following files you will get to where I am at.
[not sure what apks I will need just yet, so this might change]
Code:
/system/app/CryptoServer.apk
/system/app/GlobalSearch.apk
/system/app/Home.apk
/system/app/Library.apk
/system/app/Reader.apk
copy these supporting libraries/files
Code:
/system/framework/bncloudapi.jar
/system/framework/com.bn.authentication.jar
/system/framework/com.bn.cloud.jar
/system/framework/com.bn.gpb.jar
/system/framework/com.bn.provider.utils.jar
/system/lib/libbndeviceinfo.so
/system/lib/libbravodeviceinfo.so
/system/lib/libpdfhost.so
/system/etc/permissions/com.bn.app.crypto.xml
/system/etc/permissions/com.bn.app.deviceinfo.xml
Edit the following file and add the information below
Code:
/system/etc/permissions/platform.xml
This will declare the library in order for the apps to use it.
Code:
<!-- This is a list of all the libraries available for application
code to link against. -->
<library name="android.test.runner"
file="/system/framework/android.test.runner.jar" />
<library name="javax.obex"
file="/system/framework/javax.obex.jar"/>
<library name="com.bn.gpb"
file="/system/framework/com.bn.gpb.jar"/>
<library name="bncloudapi"
file="/system/framework/bncloudapi.jar"/>
<library name="com.bn.cloud"
file="/system/framework/com.bn.cloud.jar"/>
<library name="com.bn.authentication"
file="/system/framework/com.bn.authentication.jar"/>
<library name="com.bn.provider.utils"
file="/system/framework/com.bn.provider.utils.jar"/>
Once you have all this in place, restart the device. Logcat will complain about the wrong certificate for the user android.media.
My next steps are to find out which apks on cm7 use this shared id and resign them all with the same key.
Once that is done, I will launch the Library and Reader with the following commands in adb to attempt to start the activities:
Reader
Code:
am start -a android.intent.action.VIEW -n com.bn.nook.reader.activities/com.bn.nook.reader.activities.ReaderActivity
Library
Code:
am start -a android.intent.action.MAIN -n com.bn.nook.library/com.bn.nook.library.LibraryMainActivity
Very interesting concept. Possibly post in other developers sections than the NC - you may get some support.
I'm not a coder but I follow the concept.
I hope you and others are able to get this to work, because the stock reader app is my favorite.
Not sure if you've already caught this, but from looking at files so far in the APK I think there is a call being made to check for the version of android (specifically Android SDK 7 (2.1)). Is this something you got around by recompiling it?
I've made more progress. I signed the apks with ZipSigner (free in the market). I am getting some force closes trying to run the Library right now, which means I probably need to sign more of the BN apks.
FYI, if anybody else wants to give this a shot, my steps were:
1. edit the apk with 7zip and remove the META-INF dir (not sure if this is required by zipsigner) to unsign it
2. push the unsigned apk to the nook's sdcard
3. From the nook run ZipSigner and choose "media" for the key
4. sign it
5. copy the signed apk to /system/app
If you do this with the Library you should see it show up in the app drawer.
i would love to see this working
Pyrot1c said:
i would love to see this working
Click to expand...
Click to collapse
Agree'd I tried this a while back, but I really know nothing about dev stuff for android, so I didn't get far, I was really hoping someone with the know how would do this.
More Power to you. Can't wait to see this working, the library and shop apps that come with the nook color, are so much better than the Nook app off the market.
I've made a little more progress. I had to decompile the cm7 framework.jar and add some files from nook's framework.jar. I also had to merge changes into 2 files. This was all in order to get the Library app up and running. I have it loading up and I am able to see my sd card.
When I click on an epub it tries to launch the Reader but for some reason the Reader app isn't finding the libpdfhost.so shared library.
I will post instructions on what to do to the framework.jar to get the Library app up and running, but I think long-term it won't be feasible to have since the changes will need to be applied every cm7 update.
What will probably happen is I will make an app that handles epub intents and passes that off to the Reader app. The Library is adding some extra info when it starts the Reader app so I will need to copy that.
This will all be possible once I figure out why the shared library isn't being loaded properly.
Nice job man! Keep it going
Would love to see this working as well keep up the good work
Really cool.
Great progress so far. If you need a tester I'm.
I completely understand why CM can't distribute B&N software, but often it is not recognised that to many of us, the Nook Color is a family device. So it would be great if we can make these mods ourselves.
With the Market Nook app not having newspapers and magazines or NC childrens books, we still have to accommodate the entire family, in which some members of mine, still think of Gingerbread only as a type of cookie.
While I think about it...mmm ..could the library not be found because the original app's code was written to look within the file structure of Eclair instead of Gingerbread and Ext4? Or have you completely rewritten the code for the new file structure? Just thinking on my feet before I seriously studied the posted commands.
Thanks again!
Following this thread with great excitement. I would love to be able to run CM7 but still have the stock nook color app (which supports magazines, nookbooks for kids, etc.). Keep up the great work!!!!
/Kevin
OMG this would be awesome!!!
JoshMiers said:
I've made a little more progress. I had to decompile the cm7 framework.jar and add some files from nook's framework.jar. I also had to merge changes into 2 files. This was all in order to get the Library app up and running. I have it loading up and I am able to see my sd card.
When I click on an epub it tries to launch the Reader but for some reason the Reader app isn't finding the libpdfhost.so shared library.
I will post instructions on what to do to the framework.jar to get the Library app up and running, but I think long-term it won't be feasible to have since the changes will need to be applied every cm7 update.
What will probably happen is I will make an app that handles epub intents and passes that off to the Reader app. The Library is adding some extra info when it starts the Reader app so I will need to copy that.
This will all be possible once I figure out why the shared library isn't being loaded properly.
Click to expand...
Click to collapse
Have you given libpdfhost.so the correct permissions? If not chmod that mofo.
I attempted this a few weeks back myself. Your first post describes my findings exactly, including which files to copy over and adding the shared libs to platform.xml. Your followup post on modding the framework and getting the Library to stay open without FC is further than I got, however. If you want to compare notes, hit me on freenode, #nookie.
In the end, I gave up primarily because the work involved seemed to not be work it considering the Nook app from the market is quite good. The only thing it lacks is magazine subscriptions, I think. I might like a second look considering you seem to be getting closer.
-Muffin
that would be real cool if you guys could make this work.
I wish i knew how to make apps... but i'm not talented like that unfortunately.
anyone got an idea as to how to deal with the home button not working after upgrade? how about clearing of opened up apps in the notification section? how about closure of apps after being done with them as not all apps have exit button ?
i'd appreciate any comments.
thanks
Subscribed. This is the only thing keeping me from upgrading to a Froyo/GB/Honeycomb build.
Also sub'ed ... about to go with a dual-boot Stock+Froyo but would love to have the app on Froyo so I could dump stock.
This is the only thing holding me back from completely getting rid of stock. I actually use Aldiko for reading most of my books but am really looking forward to being able to read magazines from CM7.
I just wanna say keep up the good work. Your progress looks promising thus far.
Having this as an option would be great... seriously.
Work was busy last week so I didn't have much time to look into this.
I have hit a few potentially serious roadblocks. Other than needing to modify the framework.jar (with fairly simple changes) I will also need to either modify the MediaProvider.apk or write my own media provider that declares the content:// URLs that the Reader and Library apps expect.
I figured out how to launch the Reader apk from the commandline, so it will be trivial to write a front-end to do this when an epub is clicked. Also, I have gottem the Reader app to display the first page of my epub before force closing (due to unhandled content:// intents).
I was going to just stop working on this since Aldiko is suitable for my needs right now, but judging by the replies I will keep banging on it and try and write a media provider for all the content intents being sent.

Physics Projection Calculator, Problems.

I am developing my first android app, I have been studying javascript for a few months, and have manged to get it down pretty well, along with creating some fair applications with it.
This is my first android application, and please take into account that i started it less then 5 hours ago. Ill post on this thread whenever I run into problems to hopefully get some help.
Here is my aplication currently:
(attached)
nothing actually "does anything" right now, except the button its just a XML screen and a splash screen really.
Here is a project i did in JDK which i am trying to "Mimick":
The first problem i am having right now is that the background that i am trying to put on to my application is not showing up in the XML properties "Background" under drawable. The Background is saved in all 3 of the draw able folders under rec. Whenever i try to add the background manually with code i get this error.
Failed to convert @drawable/background3 into a drawable
Couldn't resolve resource @drawable/background3
Click to expand...
Click to collapse
Secondly I am trying to figure out how to send the numbers entered into the "editText" objects to the main java method. I used actionListeners in java but i don;t know here. No need to explain it i would be very appreciative if someone could just point me in the right direction.

[HOWTO] Remove Ads from apk

Hi there, here's a little tweak that I've just figured out and that hopefully some of you might enjoy...
But first off, a disclaimer:
Ads or (upgrade) nag banners 'sometimes' have a justifiable reason of being. Devs might use them to get some extra (very small un fact; most finally give this up in the end) revenue from them. That, in turn, that might allow or encourage them to continue pulishing more free apps for you to enjoy. So use your best judgement here and use these tweaks with discernment...​
Message to moderators: if this goes against xda policy in any way, please let me know and I'll remove all this from here.
OK, now that this is set clear, here's what that is all about:
I'm sure that most of you guys have seen ads (or upgrade) banners in free apps and being an xda member, you probably know a few tricks to get rid of some of them. I mean ads like the ones apps or games that do not really need internet connections can easilly be blocked by using ip-tables rules/firewall/anti-ads apks to completly block their internet (like with Droidwall for example). But what about ads on the apps that DO need internet connection and than cannot be completely blocked? What about the empty screen space left for banners on some others with blocked internet access?
Well, through my readings, I've found that some suggest to hack the apks and to simply decompile them, go in \decompiled_apk\smali\com\google\ folder and delete the "ads" folder altogether. Well, from my experience, this doesn't work very well. In many cases, the modded app will not install and in some other cases, the trick might work for a while and then the ads would eventually come back. That last case just happened to me: a while ago, I've tweaked the DI Radio app like so and things seemed just fine. And today, bam!!: ads banners again. God knows how/why they came back with that "ads" folder deleted, but they did!!
So with a little thinkering and code browsing, I've figured out a very simple way to get this done - here's how:
What you need:
- An apk decompiling/compiling/signing tool(s) of your choice;
- the excellent text editor notepad++ - get it from here
Notes:
- PLEASE, do not fill this thread with questions like: how do I decompile/sign apks? - it's not the place here - thanks!
- And please do not full-quote this long post either
- If you rewrite/repost this somewhere else, please play it fair and give credits/link to this thread.
HOWTO:
1. Pull and decompile your apk;
2. Go in \res\layout folder and select all the xmls files, right-click of the highlighted file and press "open" and they should all open with Notepad++ [just click OK if you get the "confirm 'Open' Action"];
3. Select Search/Find... and enter: "@id/ad" [no quotes ""] and press "Find ALL in All opened Documents" on the search popup dialog box;
4. Now look at the search results and there might be 2 possible (maybe more.. I've tried this on only 2 apks so far...) result types:
--> As a first illustration of this: for the DI radio apk I've mentioned above [I use an older version and not the latest that requires login every time...], you get an xml called "playing.xml" with this at line 6:
Code:
<FrameLayout android:layout_gravity="center" android:id="[COLOR="Red"]@id/ad[/COLOR]_frame" android:layout_width="[COLOR="Red"]320.0dip[/COLOR]" android:layout_height="[COLOR="red"]50.0dip[/COLOR]">
On that line, we can see some size attributes for that banner; just resize them to 0!!;
So all there is to do is to edit it like so:
Code:
<FrameLayout android:layout_gravity="center" android:id="@id/ad_frame" android:layout_width="[COLOR="red"]0.0dip[/COLOR]" android:layout_height="[COLOR="red"]0.0dip[/COLOR]">
-->> Second case: for some other apks (like for an older version of a very famous file explorer..), you might get multiple results (many xmls - 6 or 7 of them) all looking like this:
Code:
<com.google.ads.GoogleAdView android:layout_gravity="center" android:id="[COLOR="red"]@id/ad[/COLOR]view" android:layout_width="wrap_content" android:layout_height="wrap_content" />
So no banner sizes in this case but all there is to do is to delete all those lines completely and then save all the respective xmls. Then,
5. Recompile and sign the apk;
6. Backup [for restoring its data later..] and then uninstall your original apk from your phone (if still there)
7. Install your modded one and enjoy your app without any ads, blank spot or nag screen.
Final notes:
- Now, this doesn't stop the app to get the ads from the internet, but it does give you a simple way to hide them and this also make accidental clicks on them a story of the past...
- This is pure dirty hacking and not a general procedure; there might be different ways to implement ads in apps and ways to hide them; so please try at your own risk and feel free to share your results/tricks with us.
- Thanks to oSandmaNo for reminding me this one important drawback: when you tweak apps like so, you will get an error message when trying to update them on the Playstore. You will have to uninstall them before being able to update. so this mean that make a backup with Titanium Backup (or others) first in order to later restore the app's DATA ONLY. Obviously, the remove ads tweak will then be gone after the update, but since you've done it once, it should be fairly easy to do it once more..
- Read post #3 for a few additional tips.
.
.
Always the best
Move this to android software hacking?
I don't want a Tapatalk sig!
Thanks buddy,
Well after a little more experimenting on this yesterday
[ ...nice way to spend time our last day on Earth... Oh wait! we're still alive; the doomsday that never came...], I realize(like I suspected) that there are many different ads implementation/removal methods and will have to had a few extra tips and tricks here.
I even still have an app that I can't figure out where the ad banner is.
But, if I may just add, the whole point here was to:
1- tell people that notepad++ is excellent tool for multi-open and multiple-files search tool - perfect for xmls...
and 2- make people realize that if ads are displayed on the screen, it is more than likely that there is/are entries about it somewhere in /res/layout/ that can be hacked...
Ok, from phone it's not convenient but here's one or two extra tips:
- search for "<com." and look for results related to google AdView or doubleclick - those can all be voided;
- if you find a line that you know/suspect is a banner, do not completely delete it and just use "<!--" (start - w/o ") and "-->" (end) to void that line;
- if a banner line entry is within a RelativeLayout, it might be preferable to add/change its size to zero with android:layout_width="0.0dip" (same with height) rather than void it;
- if you do the above (0 height/width), and the line has a: android:scaleType=fitXY" entry, delete it from the line. Other wise it might just bypass your change to 0 by 0 size...
- so search for "fitXY" is alao another thing to search for in the goose chase... so is "advert", "banner", "pub", ....
Ok, that's it for now...lack of coffee in the morning makes for messy posts...
So the difference between the results of this procedure and an adblock such as AdAway is? I'm just curious.
KicknGuitar said:
So the difference between the results of this procedure and an adblock such as AdAway is? I'm just curious.
Click to expand...
Click to collapse
they will only block the ads but they keep a blank frame in the display and this will get rid of the whole frame
I don't want a Tapatalk sig!
nogoodusername said:
they will only block the ads but they keep a blank frame in the display and this will get rid of the whole frame
Click to expand...
Click to collapse
Yep, that's the idea!
Why can't I ever come up with those 1-liner answers...?!? :silly:
Baahh! since I've already written an answer in a notepad, I'll paste it here in anyway:
Similarly to anti-virus solution and their virus defintion lists, AdAway is an app that blocks ads through the use of hosts files. It basically downloads and keep updated a list of known ads (and rogue) sites and just blocks any internet connection to them using a local redirection. I've already posted something on all this here.
Btw, I personally do not see the point of using such a specific app just for this as there tons of such lists freely available on the net and I don't think it is that important to update it so frequently... I just update the list once every 3-4 months or so and everything has been fine for me so far...
On the other hand, the object of this thread is to deal with apks' layouts and that means to aim at removing any wasted space that the ads might use OR leave empty if you do block them out. Just look at the 4th screenshot on the OP; it might not be clearly visible because I put some text over it, but you see that black rectangle at the bottom? Well that is what I called an app banner. It's black because I used Droidwall to block internet access to that file explorer, but I believe that it would be the exact same if I would only use either AdAway or just my hosts file. It's the layout design of the apk that still uses that space even though it didn't get any ads from the internet...With my tricks, I (at least the goal is to) regain that important screen real estate no matter what; even without any ad blocking solution... And btw, none of those are perfect either; there will always be one new ad site not listed/included yet...
Like I wrote more than once above, not all apps are coded the same and some other apks do not display anything when they do not get any ads from the net. So these tweaks would not be needed for those.
I feel that what I wrote is a bit confusing, but I hope you get my idea anyway.
Added two more SS as example...
[that freakin app had ads entry in a good dozen different xmls but easy doubleclick ones :victory: ]
Adding
android:visibility="gone"
To any layout block (within < and /> ) having the word "ad" in it should work as well
And right on about notepad++ being great for xmls and I use it along with VTS10 which also previews referenced drawables, strings and public.xml entries in the xml apart from having a complete fuss free environment for reverse engineering apps
Thanx for sharing!
bhupatib said:
Adding
android:visibility="gone"
To any layout block (within < and /> )
Click to expand...
Click to collapse
Thanks I wondered about that; I will try it out on the next app I tweak for this..
having the word "ad" in it should work as well
Click to expand...
Click to collapse
You mean searching for the word "ad" or adding that within the layout? Because searding for "ad" when an app 100+ xmls you will get A LOT of results with "android: paddingLeft=...(/right)"...
And right on about notepad++ being great for xmls and I use it along with VTS10 which also previews referenced drawables, strings and public.xml entries in the xml apart from having a complete fuss free environment for reverse engineering apps
Click to expand...
Click to collapse
Thanks, I'll surely have a look at that VTS10 but when I tried to search for it I got just about every results possible (dry vaccum pumps, metal wires, remote house domotic system, etc...) except something related to Android
Thanx for sharing!
Click to expand...
Click to collapse
NP my pleasure.
Can you update the app after modifying? No package signed incorrectly error?
Sent from my MB526 using xda app-developers app
[] AL [] said:
You mean searching for the word "ad" or adding that within the layout?
Click to expand...
Click to collapse
I didn't mean it literally, just something to identify layouts containing adverts (lame, I know ). There'd be better ways of searching for it (like the id search you mentioned)
[] AL [] said:
Thanks, I'll surely have a look at that VTS10
Click to expand...
Click to collapse
Sorry, I used the abbreviation (and wrong one at that; it's just VTS or Virtuous Ten Studio, formerly M10 Studio) without giving you a link. I should be banned
Here:
http://forum.xda-developers.com/showthread.php?t=1619473
It's really great for themers and smali-ers like you
oSandmaNo said:
Can you update the app after modifying? No package signed incorrectly error?
Click to expand...
Click to collapse
Oh! good that you mention this - I thought about it earlier today then I forgot about it...
You are right: you'll get that error and have to uninstall before beeing able to update.
This makes sense and even if you could, the update would replace the old version and remove your changes anyway.
So yes, this is an important drawback and I'll update the OP tomorrow.
I often tend to keep old versions unless new ones bring important fixes or options...why update what is not broken? hehe!
But at least, once you've found how the tweak is done for a specific app, it should be quite easy to do it again...
And really, I don't know about you, but I do not use that many such apps that show ads or blank space... Most don't if they do not absolutely require internet connection and if you use Droidwall and/or a hosts file.
But again, good point and thanks.
Sweet. Thanks. Works!
Sent from my MB525 using xda app-developers app
Luckypatcher is free and easier to remove ads.
Gesendet von meinem MB526
joke19 said:
Luckypatcher is free and easier to remove ads.
Click to expand...
Click to collapse
Maybe, but that has nothing to do with xda philosophy where the forum is there to make people learn and try mods on there own.
Beside, in my mind, this is pretty much warez talk and that is against xda rules...
So I won't thank you for the suggestion
thanks
cool!
thanking you twice today, mate!
piunti said:
thanking you twice today, mate!
Click to expand...
Click to collapse
Way to go!!!
and you're welcomed.
... Keep going, I have more threads... Hehehe!!
Any comments on why or what you thanked? Anyhow, I thank you here and once more on your post above..: fair enough?
Cheers mæite!
Edit: OK well thanked you there (theme thread) also.
Plz do not full-quote my long posts next time....
Madvertise Ads !!!
Awsome tut dude! I've been on it already but now I've encounter some kind of new ad engine called Madvertise!
Can't seem to get rid of it! Do you or anybody aorund know how?
I seemed to have figured out some of its files...
\res\layout\ad_madvertise.xml
\res\values\attrs.xml
\assets\adview.html
\assets\adview.js
Messing around modifying/removing these files makes the APK file unusable!
Ty very much. I had problems with one app for coding. The ad covred the main sting while I was writing and I really could't see anything. But with ur help I can carry on with my work
P.S.: Does the ad eat traffic even when I can't see it? And I'm enclosing that app. Probably, some1 needs it.
thanks OP for great method
Thanks OP for this great method, i was having problems first when compiling but when i downloaded the latest apktool and aapt especially the decompiling was done with any problem. I removed ads from two apps as a piece of cake.

[Q] How to force an android browser to ignore meta viewport?

Some crappy web sites like creditfoncier.fr declares the following tag in the heading of a page:
Code:
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0">
It seems to be a fix for an ios bug. But on my android phone I can only see a part of the page. I found a solution that suits to my needs. If I type the following text in the address bar, the page appears exactly the same as on a desktop browser:
Code:
javascript:var metas = document.getElementsByTagName('meta');for (i=0; i<metas.length; i++) {if (metas[i].name == "viewport") {metas[i].setAttribute("content","");}}
I added it to my bookmarks to fix crappy sites on demand.
But I am looking for a better solution. Is there a browser option or plugin to always ignore declared viewport? Or a web service to disable viewport interpretation?
Thank you
Thank You, Thank You, Thank You
THANK YOU! I know you're asking for a better way, but you just provided me with the only way I have found so far. I have an iPhone 6 Plus (1920x1080) and was forced into crappy mobile layouts of "Responsive" pages when my Mac displays the proper layout and only has 1440x900! I'm just hoping more people can find your post, and even better yet someone makes a browser to ignore the viewport, or better still the whole world stops the evil practice of responsive web design. Anyway on iOS 8.1 this DOES work in Safari, but ONLY as a bookmark. If you paste this into the URL Safari says JavaScript can't be used this way.
You're welcome
You're welcome!
One of the goals of my message was to share a solution I found, as well as keep it safe for myself. The best way would actually be an option in browser, or a browser add-on. I hope someone will develop one.
Glad it helped you.

Hacking AlReader to access Library directly

I've been wrestling with this issue for awhile and can't seem to make much headway so it's time to ask for help.
I'm working on AlReader 1.77, which is the last version that will run on the Nook Simple Touch e-reader (Android 2.1). I'd like to be able to call up the Library section (by activity) directly, without going to a book, then accessing the Library through the menus. In the original AndroidManifest (attached) none of the activities are "exported". ADW Launcher picks out "AlReader3GridCatalog" as the "Library" activity but can't get there via activity shortcut, presumably because the developer has things locked up.
My first step: add
Code:
android:exported="true"
to each of the activities listed in the Manifest (starting at line 115). When I first tried this I had minimal success. Using
Code:
adb shell am start -n com.neverland.alreader/com.neverland.alr.AlReader3GridCatalog
I was able to get to a blank screen with the title bar "Library". The menu options were incomplete and accessing any of them crashed out of the activity (such as it was).
A logcat of accessing the Library in the unmodified app shows that this is the correct activity, but it also says there are "extras" (I hate "extras"). I've been trying various things found in the xml and menu information of the decompiled app and have been picking around in the smali files, but those are mostly Greek to me.
Can anyone offer any suggestions to get me back on track?

Categories

Resources