Search code examples
androidgoogle-ad-manager

aapt.exe has stopped working and R.java cannot be resolved after adding Google Play Services library to an existing project


I get the solution. Post the solution below. Thank you every one.

I'm trying to add new google-play-services_lib in my old project, due to which R.jave file is removed from the project. Also, as soon as i remove google-play-services_lib, i get my R.java file back. minimum sdk version is 11. I'm referring to following link: https://developer.android.com/google/play-services/setup.html

I am following these steps to add library as a project ==> Right-click on My project -> Properties In Android->Library section click Add select recently added project -> Ok

then aapt.exe has stopped working and R.jave file is removed from the project


Solution

  • Finally i got the solution : I changed ( android:id="@+id/) to ( android:id="@id/) in each views from my all layouts and create a new resource file at res/values/ids.xml and provide its "name"

    For example

    step1: old_layout.xml

    <EditText  android:id="@+id/amount"                       
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content" />
    <Button
                        android:id="@+id/submit"                       
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" />
    

    new_layout.xml

    <EditText  android:id="@id/amount"                       
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content" />
    
    
    <Button android:id="@id/submit"                       
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" />
    

    step2: res/values/ids.xml

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    <item type="id" name="amount" />
    <item type="id" name="submit" />
    </resources>
    

    Step3: clean and run the project .

    Thats all its work for me