Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8643627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:05:47+00:00 2026-06-12T12:05:47+00:00

in my android project all of my .java view files import the R file

  • 0

in my android project all of my .java view files import the R file based on the name of the current package. When I change the name of my package name in the Android Manifest (dynamically, not refactoring via Eclipse or any other IDE), I need to the references of all my java files to point to the new R file that gets generated

I am making a build script via Ant, but I am not sure what the regular expression convention would look like

The strings that need to be replaced look like this:

import com.mysite.myapp.R;

ie.

import com.sushiroll.california.R

This is what I have in my ant build script

<replaceregexp file="src/*"
           match="import*.R"
           replace="import ${current.package}.R"
           byline="true">
        <fileset dir="src/.">
            <include name="*.java"/>
        </fileset>
</replaceregexp>

where I want to match all strings that say import and end in .R

and replace it with import $current.package}.R

how would I word that for ant regex? the match and replace that I wrote were just guesses

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:05:49+00:00Added an answer on June 12, 2026 at 12:05 pm

    You need to group old package name chars before .R

    if you know package name

        match="import com\.mysite\.myapp\.R;"
    

    if you do now know package name, but be prepared to be failed for wrong imports if you import R from different packages

        match="import (.*).R;"
    

    replace to

    replace="import ${current.package}.R;"

    and the

        <fileset dir="src">
            <include name="**/*.java"/>
        </fileset>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We all can import an existing Android project into workspace using File->Import->Existing projects into
I have a main class in Android java project where all functions are defined.
Eclipse is complaining about my Android project saying all my references to resources are
I am currently working on an android project which lists all of the apps
I have 1 android app project and 1 widget project, they all work fine.
I hope you're all good. I am working on an android application project and
I'm writing an Android project where I'm recording several audio files. Therefore, I'm setting
I have seen the API demos of android (/ApiDemos/src/com/example/android/apis/view/Gallery1.java) , but they take images
i'm trying to include a maven java project into my android project. the maven
I have tried all that i could to generate the R.java file but in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.