newInstance failed -- not accessible to Landroid/app/Instrumentation;

Showing 1-3 of 3 messages
newInstance failed -- not accessible to Landroid/app/Instrumentation; Halsafar 6/4/11 12:38 AM
I have checked diff logs.  I have reverted to older versions.  I am
suddenly getting this error everytime I start an Activity from within
my app.  I've uninstalled it off the device and completely cleaned/
rebuilt the project multiple times.

D/dalvikvm(13381): newInstance failed: Lca/foo/bar/TroubleClass; not
accessible to Landroid/app/Instrumentation;
D/AndroidRuntime(13381): Shutting down VM
W/dalvikvm(13381): threadid=1: thread exiting with uncaught exception
(group=0x40025a70)
E/AndroidRuntime(13381): FATAL EXCEPTION: main
E/AndroidRuntime(13381): java.lang.RuntimeException: Unable to
instantiate activity ComponentInfo{ca.foo.bar/
ca.foo.bar.TroubleClass}: java.lang.IllegalAccessException: access to
class not allowed

// crash happens when activity is started like so:
Intent intent = new Intent(CallerClass.this,
                             TroubleClass.class);
                   final int result = 1;
                   startActivityForResult(intent, result);

I see the exception, probably the culprit but dalvik is throwing it.
I tried debugging and stepping through it.  After I create the Intent
and start it up the debugger steps through dalvik code and crashes.
The only other odd thing I see is the path in ComponentInfo, but maybe
that is normal.  I've taken the the TroubleClass Activity down to
nothing but an onCreate() which calls its super.onCreate().  The error
still occurs. The activity is definitely declared in
AndroidManifest.xml.  This continues to happen regardless of what I
do.  Even if I install older well tested versions of the app.

Is there some way to purge an app?  Maybe some .class file got locked
or something and won't delete?


Thanks!
Re: [android-developers] newInstance failed -- not accessible to Landroid/app/Instrumentation; Dianne Hackborn 6/4/11 11:09 AM
The exception is "java.lang.IllegalAccessException: access to class not allowed."  That means the class was found and an attempt to instantiate it made, but there is no empty public constructor that can be called.  This is well past it being declared in the manifest.  Make sure the class is declared public, and it has a public empty constructor.  (Normally an activity should not declare any constructors, which gives it an empty public constructor by default.)


--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-d...@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en



--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

Re: newInstance failed -- not accessible to Landroid/app/Instrumentation; Halsafar 6/4/11 12:07 PM
The class does not have any constructors.  Even as a blank class that
just extends Activity it was failing.  Fortunately the problem is
fixed but it is quite lame, here is my story.

So I deleted the file everywhere in my build dirs.  Went onto the
phone and deleted all I could think of related to my project.  Added a
new class to the project with the same name as the trouble class.  I
was able to launch into it now without a problem, albeit just a blank
Activity.  So I copy and pasted the current code back into it and it
broke again.  So maybe it is something to do with my code.  So I did
the full purge again, back to a working blank class.  I decided to
piece the class back together binary search fashion until I found the
culprit section of code.  I copied sections of code from a repo
browser back into the file.  Oddly I got to the end and now the class
works just fine.

Google already has this post up top for the obvious search queries to
get help on this.  Sorry there is no real solution offered here.  This
error is most likely caused from something wrong with the file not in
terms of code.  Perhaps an evil hidden character or something. I can
take the bad version of TroubleClass I have, copy and paste back into
the file and it breaks again.


On Jun 4, 12:09 pm, Dianne Hackborn <hack...@android.com> wrote:
> The exception is "java.lang.IllegalAccessException: access to class not
> allowed."  That means the class was found and an attempt to instantiate it
> made, but there is no empty public constructor that can be called.  This is
> well past it being declared in the manifest.  Make sure the class is
> declared public, and it has a public empty constructor.  (Normally an
> activity should not declare any constructors, which gives it an empty public
> constructor by default.)
>
>
>
>
>
>
>
>
>
> hack...@android.com