1

Hi every body i'm currently trying to solve a strange problem. I reduced as mush as i could my app to show you clearly the problem.

I can launch my app with the main layout just like this:

public class AndroidReaderActivity extends Activity {
     @Override
     public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.main);
}

With this main.xml

<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/main"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
</ListView>

Nothing really new about that BUT if i add a new layout named list.xml within the layout directory my app crashes... i don't understand. Here is the log (Once i add the new xml the program doesn't find the main.xml ressource)

05-16 03:00:14.631: E/AndroidRuntime(4399): FATAL EXCEPTION: main
05-16 03:00:14.631: E/AndroidRuntime(4399): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.infotel/com.infotel.AndroidReaderActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030001
05-16 03:00:14.631: E/AndroidRuntime(4399):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
05-16 03:00:14.631: E/AndroidRuntime(4399):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-16 03:00:14.631: E/AndroidRuntime(4399):     at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-16 03:00:14.631: E/AndroidRuntime(4399):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-16 03:00:14.631: E/AndroidRuntime(4399):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-16 03:00:14.631: E/AndroidRuntime(4399):     at android.os.Looper.loop(Looper.java:137)
05-16 03:00:14.631: E/AndroidRuntime(4399):     at android.app.ActivityThread.main(ActivityThread.java:4424)
05-16 03:00:14.631: E/AndroidRuntime(4399):     at java.lang.reflect.Method.invokeNative(Native Method)
05-16 03:00:14.631: E/AndroidRuntime(4399):     at java.lang.reflect.Method.invoke(Method.java:511)
05-16 03:00:14.631: E/AndroidRuntime(4399):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-16 03:00:14.631: E/AndroidRuntime(4399):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-16 03:00:14.631: E/AndroidRuntime(4399):     at dalvik.system.NativeStart.main(Native Method)
05-16 03:00:14.631: E/AndroidRuntime(4399): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030001
05-16 03:00:14.631: E/AndroidRuntime(4399):     at android.content.res.Resources.getValue(Resources.java:1018)
05-16 03:00:14.631: E/AndroidRuntime(4399):     at android.content.res.Resources.loadXmlResourceParser(Resources.java:2105)
05-16 03:00:14.631: E/AndroidRuntime(4399):     at android.content.res.Resources.getLayout(Resources.java:857)
05-16 03:00:14.631: E/AndroidRuntime(4399):     at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
05-16 03:00:14.631: E/AndroidRuntime(4399):     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-16 03:00:14.631: E/AndroidRuntime(4399):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
05-16 03:00:14.631: E/AndroidRuntime(4399):     at android.app.Activity.setContentView(Activity.java:1835)
05-16 03:00:14.631: E/AndroidRuntime(4399):     at com.infotel.AndroidReaderActivity.onCreate(AndroidReaderActivity.java:92)
05-16 03:00:14.631: E/AndroidRuntime(4399):     at android.app.Activity.performCreate(Activity.java:4465)
05-16 03:00:14.631: E/AndroidRuntime(4399):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
05-16 03:00:14.631: E/AndroidRuntime(4399):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)

Thanks for your help guys :D

EDIT

This is my list.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="100dip" >
    <ImageView 
        android:id="@+list/thumb"
        android:layout_width="60dip"
        android:layout_height="60dip"
        android:layout_centerVertical="true"
        android:layout_alignParentLeft="true"
        />
    <TextView
        android:id="@+list/text"
        android:layout_toRightOf="@+list/thumb"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="18dip"
        android:layout_marginLeft="10dip"
        android:layout_centerVertical="true"
        android:singleLine="true"
        android:ellipsize="end"
        android:textStyle="bold" 
        />
</RelativeLayout>

And my manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.infotel"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="15" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".AndroidReaderActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
Bobyblanco
  • 123
  • 12

3 Answers3

4

There is no problem everything is fine , please once clean your project then run again,because your resources java file not properly build.

or

check once your project package name should be similar in manifest file.

Bhaskar Reddy
  • 480
  • 5
  • 13
  • That was the problem ... thank you very much, i don't usually need to do it in iOS :s i didn't even think it was possible to clean a project but it works now thanks to every one – Bobyblanco May 22 '12 at 12:52
1

Check your gen/R.java file and search for 0x7f030001 See which resource it is and it will probably give you a hint to the problem. This is not a problem with adding activities to your manifest as Kalaji suggested.

IncrediApp
  • 10,303
  • 2
  • 33
  • 24
0

Check the AndroidManifest.xml file for your project. Make sure it that the <activity> opening tag is set to:

<activity android:name=".AndroidReaderActivity" android:label="@string/app_name">
Jacek
  • 464
  • 4
  • 9