Pregunta

I figured out the solution to the problems. Answers are in my answer. And i modified the question a little.


Problem still not resolved.

When using Eclipse to build an android project, should it be generating more than 1 R.java file?

Yes, it will generate R.java for each library that has been imported.

How do I keep it from generating the extra 2 R.java files

Dont, import those other 2 libraries, but you will probably need to to fix your dependencies. Multiple is not a problem.

The problem below has been fixed, however... Eclipse is still generating 3 R.java files and my ant script is only generating 1. For the project in question, everything compiles fine in both scenarios (ant or eclipse) but this could possibly be causing an issue in another project and i would like to know the answer to the question above.


Below is the old problem that has been kinda solved

I am trying to create some ant build scripts for several apps. When trying to run this code:

<target name="resource-src" description="Generate the R.java file for this project's resources.">
    <exec executable="${aapt}" failonerror="true">
        <arg value="package"/>
        <arg value="-f"/>
        <arg value="-v"/>
        <arg value="-M"/>
        <arg path="../AndroidManifest.xml"/>
        <arg value="-A"/>
        <arg path="../assets"/>
        <arg value="-I"/>
        <arg path="${android_jar}"/>
        <arg value="-m"/>
        <arg value="-J"/>
        <arg path="../gen"/> <!-- Create R.java in the gen directory -->
        <arg value="-S"/>
        <arg path="../res"/>
    </exec>
</target>

I get this error:

C:\BoogerReport\builder\build.xml:76: exec returned: 1

I noticed that this app is generating multiple R.java files when using eclipse to build the project (in the gen folder). I thought android apps were only supposed to generate 1 R.java file.

1. Is this the case?

2. If not, what could be the issue?

3. Also, are these two problems related or is there something else wrong?


Below is the AndroidManifest.xml for the project in question.


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="alpha.beta.charley.delta.echo.booger.ui"
      android:versionCode="2"
      android:versionName="UnofficialBuild">
    <uses-sdk android:minSdkVersion="10" />
    <application android:icon="@drawable/booger"
        android:label="@string/app_name">
        <activity android:name=".BoogerReport"
                  android:label="@string/app_name"
                  android:configChanges="keyboardHidden|orientation"
                  android:windowSoftInputMode="stateHidden">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="alpha.beta.charley.delta.message.boogerreport.CREATE" />
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="alpha.beta.charley.delta.message.category.LOCATION" /> 
            </intent-filter>
        </activity>
        <activity android:name=".BoogerReportView"
                  android:configChanges="orientation">
            <intent-filter>
                <action android:name="alpha.beta.charley.delta.message.boogerreport.OPEN" />
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
        </activity>
        <activity android:name=".BoogerList" 
                  android:configChanges="orientation" /> 
    </application>
</manifest>

Additional information to answer questions asked:

Paths to the generated R.java files:

  1. alpha.beta.charley.delta
  2. alpha.beta.charley.delta.echo.booger.ui
  3. alpha.beta.charley.datamodel
¿Fue útil?

Solución

The most recent problem answer

The reason why it does that is because when you import a library into android it will auto generate the R.java that are attached to those libraries. So yes, multiple R.java is fine.


Original problem answer

We found the solution. Someone had imported an R.java file from another project. Taking this import out, fixed the problem.

This actually fixed the problem where it was returning an error code of 1. However, when using Eclipse to build the project it still builds 3 R.java files. Adding details to main post about this situation.

Otros consejos

My guess is that the ADT plugin is trying to generate its own R.java in addition to the R.java that your script is making. If you're using Eclipse and not the command line, just use the ADT plugin to build your app.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top