Amr
Amr

Reputation: 197

main.xml file is not reachable/accessible

I downlaoded an example from the Internet to learn more about the AugmentedReality.

And when I tried to import the project, eclipse couldnt find any project and then, i decided

to copy all the files one by one in a new project I created. But, when I tried to fix some

error, I could not fix and error reads: "main canot be resolved or is not a field"

this error appeared around 'setContentView(R.layout.main);' despite of, in the resources file

there is a main.xml file, but eclipse cant find it.

any suggestions to fix such an error?

LOGCAT:

05-17 16:56:16.975: E/AndroidRuntime(12497): FATAL EXCEPTION: main

05-17 16:56:16.975: E/AndroidRuntime(12497): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.imrannazar.sobel/com.imrannazar.sobel.Sobel}: android.view.InflateException: Binary XML file line #3: Error inflating class com.imrannazar.sobel.OverlayView 05-17 16:56:16.975: E/AndroidRuntime(12497): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651) 05-17 16:56:16.975: E/AndroidRuntime(12497): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667) 05-17 16:56:16.975: E/AndroidRuntime(12497): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 05-17 16:56:16.975: E/AndroidRuntime(12497): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) 05-17 16:56:16.975: E/AndroidRuntime(12497): at android.os.Handler.dispatchMessage(Handler.java:99) 05-17 16:56:16.975: E/AndroidRuntime(12497): at android.os.Looper.loop(Looper.java:130) 05-17 16:56:16.975: E/AndroidRuntime(12497): at android.app.ActivityThread.main(ActivityThread.java:3691) 05-17 16:56:16.975: E/AndroidRuntime(12497): at java.lang.reflect.Method.invokeNative(Native Method) 05-17 16:56:16.975: E/AndroidRuntime(12497): at java.lang.reflect.Method.invoke(Method.java:507) 05-17 16:56:16.975: E/AndroidRuntime(12497): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907) 05-17 16:56:16.975: E/AndroidRuntime(12497): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665) 05-17 16:56:16.975: E/AndroidRuntime(12497): at dalvik.system.NativeStart.main(Native Method) 05-17 16:56:16.975: E/AndroidRuntime(12497): Caused by: android.view.InflateException: Binary XML file line #3: Error inflating class com.imrannazar.sobel.OverlayView 05-17 16:56:16.975: E/AndroidRuntime(12497): at android.view.LayoutInflater.createView(LayoutInflater.java:508) 05-17 16:56:16.975: E/AndroidRuntime(12497): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570) 05-17 16:56:16.975: E/AndroidRuntime(12497): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623) 05-17 16:56:16.975: E/AndroidRuntime(12497): at android.view.LayoutInflater.inflate(LayoutInflater.java:408) 05-17 16:56:16.975: E/AndroidRuntime(12497): at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 05-17 16:56:16.975: E/AndroidRuntime(12497): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) 05-17 16:56:16.975: E/AndroidRuntime(12497): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:215) 05-17 16:56:16.975: E/AndroidRuntime(12497): at android.app.Activity.setContentView(Activity.java:1663) 05-17 16:56:16.975: E/AndroidRuntime(12497): at com.imrannazar.sobel.Sobel.onCreate(Sobel.java:74) 05-17 16:56:16.975: E/AndroidRuntime(12497): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 05-17 16:56:16.975: E/AndroidRuntime(12497): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615) 05-17 16:56:16.975: E/AndroidRuntime(12497): ... 11 more 05-17 16:56:16.975: E/AndroidRuntime(12497): Caused by: java.lang.NoSuchMethodException 05-17 16:56:16.975: E/AndroidRuntime(12497): at java.lang.Class.getDeclaredConstructors(Native Method) 05-17 16:56:16.975: E/AndroidRuntime(12497): at java.lang.Class.getConstructor(Class.java:472) 05-17 16:56:16.975: E/AndroidRuntime(12497): at android.view.LayoutInflater.createView(LayoutInflater.java:480) 05-17 16:56:16.975: E/AndroidRuntime(12497): ... 21 more

Upvotes: 2

Views: 445

Answers (2)

Barak
Barak

Reputation: 16393

Look for

import android.R

Delete it, then clean your project and things should start working again

Upvotes: 3

Imran Rana
Imran Rana

Reputation: 11899

I think you have an import like:

import android.R;

Remove it and your problem should be gone.

Upvotes: 5

Related Questions