Reputation: 1477
I was editing a layout in Android Studio and added a Switch. I first set its ID to "switch". After a compilation error, I realized it was a reserved keyword and I cannot use it, so I decided to change its ID to "mySwitch" but Android Studio crashed at this moment.
After launching it again, I checked the ID, which does have been changed to "mySwitch", but when trying to compile, I still get this error:
/path/to/app/build/generated/source/r/debug/com/example/program/R.java: error: invalid symbol name 'com.example.program:id/switch'.
I guess Android Studio did not change all occurences of "switch" before crashing, but I did not find any.
What I tried but did not work :
Is there any occurence of my Switch ID I did not think of ?
Upvotes: 1
Views: 8617
Reputation: 730
Ensure that you have not named your resource a system reserved name like Continue.xml or such.
Upvotes: 0
Reputation: 271
You have to check your last edited xml file if it shows the error of invalid name symbol where id is assigned to null go through the code and check all the id's in my case the layout constraints were assigned null value. Check the id's and either remove them or assign them suitable values
Upvotes: 0
Reputation: 146
you need to find where in your xml code an object had taken "null" as an id android:id="@+id/null"
so first you need to go to the last xml you edited 1 - click right on it 2 - Analyse 3 - Inspect Code ... 4 - click ok and you will see how much errors and warnings you have
Upvotes: 1
Reputation: 1
same xlm file you declear samething like
`android:id="@+id/null`enter code here`
find it and fix; from right click on eath xml file..and run analyze--->Inspect Code
Upvotes: 0
Reputation: 1477
I found the problem, I should have thought of that earlier.
What I did is right click on "my_layout.xml"
> Analyze
> Inspect Code...
Then it showed me this line
app:layout_constraintEnd_toStartOf="@+id/switch"
I don't know how I missed that...
Upvotes: 3
Reputation: 1062
try manually deleting the build folder in your project and use "build" -> "Rebuild Project". By that way all mapping files (including your inconsistent layout mapping) should also go away. and Rebuilding recreates the map.
I still doubt, if you have missed to change id with name switch somewhere else. Think that way also..
Upvotes: 0