When I changed my package name and rebuilt the project, Android Studio put before many class names this string _root_ide_package_.com.example.<myprojectname>. And I have this error Unresolved reference: _root_ide_package_. Any ideas how to fix it?
While posting a code example would help, I had a similar issue and resolved it by doing a Replace in Path across the source tree and replaced all instances of _root_ide_package_.com.example.<myprojectname>. with nothing.
Just remove anything before the class name, for example:
_root_ide_package_.com.<project_name>.APP
Remove _root_ide_package_.com.<project_name>.
Related
I tried writing a small test to try Espresso.
package com.mycompany.myapp.somemodule
import com.mycompany.myapp.R
import other.uselful.imports
#RunWith(AndroidJUnit4::class)
#LargeTest
class DemoTest {
#get:Rule
var startActivity: ActivityTestRule<StartActivity> = ActivityTestRule(StartActivity::class.java)
#Test
fun aDemoTest() {
onView(withId(R.id.theElementId))
.check(matches(isClickable()))
}
}
Android Studio doesn't show any error. if I ctrl+click on R.id.theElementID, it finds it in the appropriate layout file. However when I try to run, I get a compile error:
Unresolved reference: id
How can I solve this?
I bumped into this issue. Spent 4 hours investigating, and no luck finding anything useful on the internet.
So, I'm hoping that the information below may help someone.
Short answer:
clean the project
execute gradlew :app:build from the command line / Terminal, it may show a build error which leads to the root cause
The longer answer:
I did the following:
I hit "Invalidate caches and restart" from Android Studio
I've executed gradlew :app:build from the command line
The second step printed an error message that the BuildConfig was duplicated.
The reason for this issue was, that I had 2 modules (android-app and android-library) with slightly different package names (I made a typo when creating the second one). This led to the failed build from the command line. After modifying the 2nd module's package name to be the same as the 1st one, the issue was solved.
I didn't receive the "R.id not found" error. So, I could continue to write the UI tests, which worked :-)
Happy coding!
Short answer: Try remove any incorrect import android.R statement.
Long answer
I also have faced this issue.
In my case, in test class, I was importing android.R package due to referring some incorrect resource id previously (R.id.progress) which belonged to android.R package.
I removed that reference as well ans the import statement i.e. import android.R from the test class and the issue resolved. Then source recognized the R.id.etPassword resource id of my layout file.
guess the actual problem is, that the activity had not been started.
R.id.theElementId might be an invalid resource descriptor.
try R.id.the_element_id instead.
also, add #UiThreadTest annotation ...
I getting
Error:(7) Error: Duplicate id #+id/item, already defined earlier in
this layout [DuplicateIds]'
I'm using Android Studio. How can I fix it? Thanks in advance.
If you using text layout and check the xml code for finding the red line(indication of error) in android studio.
If you have than change the value like shown in the image and finally clean and build the project.
Error Image
After change the id
Maybe you had defined two view with the same id.Check your code.(ctrl+f)
It is not the as's fault.
I am getting the following error when I build my Android App project in Visual studio 2015.
No resource found that matches the given name (at 'value' with value '#integer/google_play_services_version')
These lines are located under:
obj\Debug\android\manifest\AndroidManifest.xml
There is 3 entires of it inside the AndroidManifest file.
I have downloaded the google play service from the SDK Manager.
Should I reference anything to my solution?
I already has Xamarin.GooglePlayServices.Base, Xamarin.GooglePlayServices.Basement, Xamarin.GooglePlayServices.Maps Referenced.
Thanks.
you have create integer.xml file inside value folder and define your Integer to that place it will solve your problem.
Try doing and a clean all and check that ALL the content under the obj has been deleted and then perform a build all.
If that does not work:
I would try removing the ~GooglePlayServices~ nugets/references and re-add just the Xamarin.GooglePlayServices.Mapsnuget which will bring in the ~Basement and ~Base libraries.
You should end up with a generated manifest that only has one reference to google_play_services_version and that resource should be picked up from Debug/android/XXX/YYYYYY/ZZZZZ/R.java:
i.e.
public static final int google_play_services_version=0x7f070000;
I added several new packages. One of the package is the reason of the error. I have to check one by one and caught the one causing error. Removing that package is all I need to do to resolve the error.
can some help me here??
i am getting error in following line of code in R.java file
public static final int login_user-fb=0x7f0d00bf;
the identifier "-" is creating problem as you all know.
i have not declared this id anywhere in my project, i am using facebook sdk in my project since than it is giving error.
things i have done to rectify the error till now.
1.removed facebook sdk and rebuilt projct.
2.clean project
3.as you know i cannot edit R.java file, i tried doing everything but every time it is creating that code in my R.java file as whenever i run my project.
please help me out here.
Could you please check through your xml-files, and see that you have the correct naming convention for all your id's etc.
I am thinking of these type of naming errors:
android:id="#+id/text-view-example"
and rename them to:
android:id="#+id/text_view_example"
OR
Search in your project by right-clicking on 'app', in your left side panel (android-view), and click on 'Find in Path', and then type in that exact query, login_user-fb, and then replace them to login_user_fb.
I have this Android program running well, called TestePHP2 (name of main class), package com.testedeacesso.www. It is stable and runs perfectly.
I've cloned this project's folder to start developing an upgrade to it. I called it TesteTempo01, after importing it to Eclipse - option 'from existing project' (yes, I used the refractor to change the class name and I checked 'update references'). I modified this program's main class as I mentioned before and added some code to it, but I kept the package name the same, as well as other classes from the program.
Whe I try to run this program, though, I got a 'can't find main activity' error. After searching through my code, I found out that on the manifest there was a reference to the TestePHP2 that I hadn't changed before. for reference, this was the line on the Android Manifest XML:
> <activity android:name="com.testedeacesso2.www.TesteTempo01"
> android:label="#string/app_name">
After this, I keep getting a NullPointerException because the class can't find the main class! I've searched through the whole code but I found no other references to the old class. Have I forgotten something? Do I need to alter something else to change this class' name? Or the import will only work with the original class names?
You said the package was 'com.testedeacesso.www', but when you reference the class, its 'com.testedeacesso2.www'. I'm guessing you have a problem with class/package references.