Questions tagged [instantiationexception]

Java Exception that is thrown when an application tries to create an instance of a class using the newInstance method in class Class, but the specified class object cannot be instantiated.

65 questions
70
votes
2 answers

How to instantiate an inner class with reflection in Java?

I try to instantiate the inner class defined in the following Java code: public class Mother { public class Child { public void doStuff() { // ... } } } When I try to get an instance of Child like…
Stephan
  • 41,764
  • 65
  • 238
  • 329
17
votes
4 answers

Fragment - InstantiationException: no empty Constructor -> Google Maps v2?

I get this error message, when I open a closed App again via App-Change button: Caused by: java.lang.InstantiationException: can't instantiate class com.*.FragmentContact$1; no empty constructor I've found several tips about Inner-Classes and to…
Osiriz
  • 218
  • 1
  • 2
  • 15
11
votes
2 answers

InstantiationException on simple reflective call to newInstance on a class?

I have an abstract class A, i.e. public abstract class A { private final Object o; public A(Object o) { this.o = o; } public int a() { return 0; } public abstract int b(); } I have a subclass B,…
mburke13
  • 350
  • 2
  • 6
  • 22
9
votes
5 answers

Why is InstantiationException a checked exception?

My understanding is that checked exceptions are those that the caller of the can reasonably be expected to recover from. I don't understand why this is the case with InstantiationException. If a class cannot be instantiated then what is the caller…
tttppp
  • 7,723
  • 8
  • 32
  • 38
9
votes
3 answers

Why am I having this InstantiationException in Java when accessing final local variables?

I was playing with some code to make a "closure like" construct ( not working btw ) Everything looked fine but when I tried to access a final local variable in the code, the exception InstantiationException is thrown. If I remove the access to the…
OscarRyz
  • 196,001
  • 113
  • 385
  • 569
8
votes
2 answers

How to prevent mediaplayer to stop when screen goes off?

I have a mediaplayer in a Music class that is called from another secondary Activity. It works fine. But when screen goes off (either by timeout or button), the music stops playing, and when coming back and try to close the activity the program goes…
Luis A. Florit
  • 2,169
  • 1
  • 33
  • 58
6
votes
1 answer

InstantiationException: Unable to instantiate fragment make sure class name exists, is public, and has an empty constructor that is public

I have a project that I originally developed using Android Studio. I decided to convert it to Xamarin (Visual Studio 2015). After hours of porting all the code over, everything works except for my Settings activity (PreferenceActivity). I have a few…
Brian Tacker
  • 1,091
  • 2
  • 18
  • 37
6
votes
1 answer

How to resolve a "java.lang.InstantiationException"?

I'm parsing in an XML file using SAX but when I call the class loader on the class, a java.lang.InstantiationException is thrown. I debugged this by the reason for the exception, 'Thrown when an application tries to create an instance of a class…
Brian Var
  • 6,029
  • 25
  • 114
  • 212
5
votes
2 answers

java.lang.InstantiationException: can't instantiate class?

I'm trying to make an Android application with automatic form generation http://labs.makemachine.net/2010/04/android-form-generator/ I've been reading a lot of topic about the "InstantiationException" but none solve my problem. Here is my Activity …
Jishin
  • 113
  • 2
  • 5
  • 12
4
votes
3 answers

Android BroadcastReceiver: Unable to instantiate receiver - no empty constructor

I have a problem with a BroadcastReceiver. If I declare the action in the manifest in this way:
Luca S.
  • 1,132
  • 2
  • 16
  • 31
3
votes
1 answer

Android "java.lang.RuntimeException: Unable to instantiate activity" exception

I am getting this error. Problem is that the "caused by" clause doesnt seem to give any more information. 12-25 19:34:05.050: E/AndroidRuntime(28888): Uncaught handler: thread main exiting due to uncaught exception 12-25 19:34:05.070:…
theblitz
  • 6,683
  • 16
  • 60
  • 114
3
votes
1 answer

InstantiationException on newInstance of generated anonymous class

Update: this is more-or-less a dupe, and it turns out to be compiler magic adding a constructor to pass in the local variable in build2. Given an interface like such: public interface IFoo { public int get(); } The code below prints 1, 1, 2…
David
  • 479
  • 3
  • 10
3
votes
1 answer

java.lang.InstantiationException android

hi ı have a problem and did not find resolve i write android service and that exception get "java.lang.InstantiationException" My logcat is that 05-23 09:44:20.164 10374-10374/? E/AndroidRuntime﹕ FATAL EXCEPTION: main …
RAMAZAN CESUR
  • 317
  • 1
  • 3
  • 9
3
votes
1 answer

java.lang.Instantiation exception while using XMLEncoder

I am trying to use XMLEncoder in my Java program but i am getting an java.lang.InstantiationException. Follwing is my code that i am using: /* Method for serialization. */ public void serializeToXml(Object obj) throws…
user3686864
  • 337
  • 2
  • 5
  • 13
3
votes
2 answers

How to fix InstantiationException, unable to instantiate Fragment?

This is my first post, so I apologize in advance... I'm trying to compile a simple Drawer sample/practice app. When I click on the items in the listview, however, it crashes. Logcat says that it's not able to instantiate from android.app.Fragment.…
1
2 3 4 5