ottengo questo messaggio di errore, quando ho aperto ancora una volta un App chiuso tramite App-pulsante Cambia:Frammento - InstantiationException: nessun vuoto Costruttore -> Google Maps v2?
Caused by: java.lang.InstantiationException: can't instantiate class com.*.FragmentContact$1; no empty constructor
Ho trovato diversi suggerimenti in merito a Inner-Classes e di renderli ecc statico Ma questo è un FragmentContact public classe in un * .java-file e ha un costruttore vuoto pubblico. Sto usando Google Maps Api v2 in questo progetto e faccio un trucco da qualche parte da Internet per configurare il mio MapView. Guarda qui:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_contact, null);
try {
MapsInitializer.initialize(this.getActivity().getApplicationContext());
} catch (GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}
fragment = new SupportMapFragment() {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mMap = fragment.getMap();
if (mMap != null) {
setupMap();
}
}
};
getFragmentManager().beginTransaction().replace(R.id.fragment_orte_map_parent, fragment).commit();
return v;
}
Quando ho tagliato questo oggetto di MapView tutto funziona correttamente. Forse qualcuno può spiegare cosa sto sbagliando.
mia completa Stacktrace:
04-17 16:15:22.115: E/AndroidRuntime(22182): FATAL EXCEPTION: main
04-17 16:15:22.115: E/AndroidRuntime(22182): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.*/com.*.MainActivity}: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.*.FragmentContact$1: make sure class name exists, is public, and has an empty constructor that is public
04-17 16:15:22.115: E/AndroidRuntime(22182): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2307)
04-17 16:15:22.115: E/AndroidRuntime(22182): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2357)
04-17 16:15:22.115: E/AndroidRuntime(22182): at android.app.ActivityThread.access$600(ActivityThread.java:153)
04-17 16:15:22.115: E/AndroidRuntime(22182): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
04-17 16:15:22.115: E/AndroidRuntime(22182): at android.os.Handler.dispatchMessage(Handler.java:99)
04-17 16:15:22.115: E/AndroidRuntime(22182): at android.os.Looper.loop(Looper.java:137)
04-17 16:15:22.115: E/AndroidRuntime(22182): at android.app.ActivityThread.main(ActivityThread.java:5226)
04-17 16:15:22.115: E/AndroidRuntime(22182): at java.lang.reflect.Method.invokeNative(Native Method)
04-17 16:15:22.115: E/AndroidRuntime(22182): at java.lang.reflect.Method.invoke(Method.java:511)
04-17 16:15:22.115: E/AndroidRuntime(22182): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
04-17 16:15:22.115: E/AndroidRuntime(22182): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
04-17 16:15:22.115: E/AndroidRuntime(22182): at dalvik.system.NativeStart.main(Native Method)
04-17 16:15:22.115: E/AndroidRuntime(22182): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.*.FragmentContact$1: make sure class name exists, is public, and has an empty constructor that is public
04-17 16:15:22.115: E/AndroidRuntime(22182): at android.support.v4.app.Fragment.instantiate(Fragment.java:405)
04-17 16:15:22.115: E/AndroidRuntime(22182): at android.support.v4.app.FragmentState.instantiate(Fragment.java:97)
04-17 16:15:22.115: E/AndroidRuntime(22182): at android.support.v4.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1767)
04-17 16:15:22.115: E/AndroidRuntime(22182): at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:208)
04-17 16:15:22.115: E/AndroidRuntime(22182): at com.*.MainActivity.onCreate(MainActivity.java:20)
04-17 16:15:22.115: E/AndroidRuntime(22182): at android.app.Activity.performCreate(Activity.java:5104)
04-17 16:15:22.115: E/AndroidRuntime(22182): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
04-17 16:15:22.115: E/AndroidRuntime(22182): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2261)
04-17 16:15:22.115: E/AndroidRuntime(22182): ... 11 more
04-17 16:15:22.115: E/AndroidRuntime(22182): Caused by: java.lang.InstantiationException: can't instantiate class com.*.FragmentContact$1; no empty constructor
04-17 16:15:22.115: E/AndroidRuntime(22182): at java.lang.Class.newInstanceImpl(Native Method)
04-17 16:15:22.115: E/AndroidRuntime(22182): at java.lang.Class.newInstance(Class.java:1319)
04-17 16:15:22.115: E/AndroidRuntime(22182): at android.support.v4.app.Fragment.instantiate(Fragment.java:394)
04-17 16:15:22.115: E/AndroidRuntime(22182): ... 18 more
la prego di pubblicare il tuo stacktrace completa? –