".R cannot be resolved to a variable" error in WP for android.

Hi,
First of all, let me tell you that i am not getting some unknown or unique error, this error was faced by multiple users on wpmu and it seems it is not yet resolved by developer.

I have read lot of unresolved questions asking for the same question, but didnt found the answer to those question till now.

With reference to page 19

Our more step at this stage is to perform a search and replace for all instances of edublogs within the code.
Highlight the wp-android folder in the left sidebar. Then in the Search menu, click File.
In the window that pops up, enter the following exactly:
import org.edublogs.android.R;
Click Replace. It may say it's failed, ignore that. Carry on and then it'll say 55 matches found. Enter in your change. For example: import org.mycoolapp.android.R;

There were '0' Matches were found.
I searched for "edublog" and replaced all the instances of edublog with "myappname".
I replaced the "edublog.org" instances with "mydomain.com", Manually.

After following all the instructions successfully, I am getting error while running the project, as instructed on page 21.

Finally, we must compile our changes again. Go to the Run menu again (the green arrow icon), and click on 1 wp-android.

==========================================
I checked here and there and found that there are still 32000+ instances of "edublogs" in the project, out of which 31000+ are in proguard folder and out of which 30000+ were in Dump file.

I am replacing all the 32000+ instances of edublogs with "myappname" and will share the results afterwards.
Kindly have a look at this issue and reply with the basic issue of not finding the code

import org.edublogs.android.R;

Because it seems, all the problems have originated from that moment.

Regards.

  • Shoeb Ansari

    I would like to get some attention from @Jack Kitterhing on this matter, as he is the lead developer for this app.

    After replacing all the 32000+ instances of edublogs to "myappname",
    1) i am still getting the error that R. cannot be resolved to a variable.

    2) In Res> layout > edit.xml >
    android:layout_below="@id/postContent"
    The error is showing as:
    @id/postContent is not a sibling in the same RelativeLayout

    3) In AndroidManifest.xml in root folder of wp-android...
    android:versionName="2.0" android:sharedUserLabel="onlinecity">
    The error is showing as:
    error: Error: String types not allowed (at 'sharedUserLabel' with value 'onlinecity').

    I have used the app name as "onlinecity" which has replaced the instances of "edublogs".
    =============

    dear @Jack Kitterhing,
    Kindly have a look at the above mentioned error messages and help me in resolving it as soon possible.

  • Shoeb Ansari

    Dear @Jack Kitterhing,

    Just one sentence of yours helped me in achieving the success in developing my first ever android app.

    The code in proguard and the dump file, does not and should not be edited.

    I have successfully created the .apk file and will be publishing it in google app store within a week after finalizing my main website functionality.

    Let me share the SOLUTION with the whole community, where i was doing it wrong, if people dont make that mistake, it will sort out for them as well.
    ==============================================

    I deleted the whole assembly and started it over carefully again.
    After downloading all the softwares (which i already had), i prepared the graphics in res folder (page 7 of manual).

    Configured eclipse and compiled the app as explained in the manual till page 16. (no problems will be faced usually till that step)

    In AndroidManifest.xml, I searched for just "edublog" and manually changed all the instances.

    All the instances of 'org.edublog.android' need to be changed to 'org.yourapp.android' (No space and all small letters)

    All the instances of 'Edublogs' can be changed to 'Your App' (caps and spaces are allowed)

    Next, i changed the file names in the src folders and renamed all the instances of 'org.edublogs.android... (it was easy)

    The main issue comes into play when we follow the instructions from manual page 19.

    Our more step at this stage is to perform a search and replace for all instances of edublogs within the code.
    Highlight the wp-android folder in the left sidebar. Then in the Search menu, click File.
    In the window that pops up, enter the following exactly:
    import org.edublogs.android.R;
    Click Replace. It may say it's failed, ignore that. Carry on and then it'll say 55 matches found. Enter in your change. For example: import org.mycoolapp.android.R;

    (This post is getting too long, i will add the solution in next post. Keep reading)

  • Shoeb Ansari

    Searching import org.edublogs.android.R; was giving error that search cannot be initiated.

    I searched for instances of 'edublogs' only and manually edited all the org.edublogs.android instances and Edublog instances across whole project, except the ProGuard folder. (at the end there will be around 30000 instances of Edublogs in Proguard folder, but we dont need to touch that.)

    To successfully edit manually, i am sharing the screenshot.
    you need to check the lower right bar in the eclipse which display search result for 'Edublogs'.
    double Clicking will open the file in frame which is just above that search result section.
    Every line with the instances will give a => arrow, you can simply scroll down to those arrows one by one, if you dont want to use Ctrl+F on the pages.
    =============================================

    This is the most important part of editing the whole application. If the search and replace stuff is done correctly (manually) you will be able to follow all the steps easily and will be able to complete the project successfully.

    Hope this will help all the unresolved questions of the community.
    And this information can be used in the UPDATED version of the MANUAL as well.

    Manual surely need to get updated.

    +++++++++++++++++++++++++++++++++
    One more issue while following manual, will be faced by the users that, it says to refresh the (virtual) android simulator by going top right of the virtual android device.
    There isn't any specific function in top right.
    We can just close the virtual device and can again launch by going to "Android Virtual Device Manager", and selecting the previously created AVD and clicking the START button.
    +++++++++++++++++++++++++++++++++

    Happy to help the community.
    Regards.
    Shoeb Ansari