El proyecto de la Biblioteca de Android dice nullpointerexception
Tengo un proyecto de la biblioteca de android my_lib
básicamente my_lib
tiene la list activity
dice MyListActivity
tiene recursos y cosas. Cuando corro como aplicación de Android 'MyListActivity' funciona bien.
Pero cuando creo otro proj
decir test_proj
y hacer my_lib
como proyecto de biblioteca de android y añadir a test_proj
como biblioteca y agregó actividad MyListActivity
en AndroidManifest
y ejecutar Estoy recibiendo NullPoiterException
en MyListActivity
, es decir, en findViewById(R.id.list)
está devolviendo null. Cómo puedo arreglar esto
- Android - java.lang.SecurityException: Permiso Negación: Intención inicial
- Cómo crear una versión de paquete de biblioteca de Android (aar) en Android Studio (no depurar)
- Hormiga reconstruyendo proyectos de biblioteca cada vez
- Dalvik desorden con el código de la biblioteca y el proyecto ya no se puede ejecutar
- Carpeta de dependencias androide eliminada accidentalmente
El código es el siguiente
OnCreate de MyListActivity
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.activity_main); initData(); rowItems = new ArrayList<RowItem>(); for (int i = 0; i < titles.length; i++) { RowItem item = new RowItem(images[i], titles[i], descriptions[i], packageNames[i]); rowItems.add(item); } listView = (ListView) findViewById(R.id.list); CustomListViewAdapter adapter = new CustomListViewAdapter(this, R.layout.list_item, rowItems); listView.setAdapter(adapter); listView.setOnItemClickListener(this);
}
OnCreate de MainActivity de prueba proj
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); startActivity(new Intent(this, ImageTextListViewActivity.class)); }
El registro de errores es el siguiente
D/AndroidRuntime( 778): Shutting down VM E/AndroidRuntime( 778): FATAL EXCEPTION: main E/AndroidRuntime( 778): java.lang.NoSuchFieldError: com.mass.applist.R$id.list E/AndroidRuntime( 778): at com.mass.applist.MyListActivity.onCreate(MyListActivity.java:55) E/AndroidRuntime( 778): at android.app.Activity.performCreate(Activity.java:5104) E/AndroidRuntime( 778): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) E/AndroidRuntime( 778): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144) E/AndroidRuntime( 778): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) E/AndroidRuntime( 778): at android.app.ActivityThread.access$600(ActivityThread.java:141) E/AndroidRuntime( 778): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) E/AndroidRuntime( 778): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime( 778): at android.os.Looper.loop(Looper.java:137) E/AndroidRuntime( 778): at android.app.ActivityThread.main(ActivityThread.java:5041) E/AndroidRuntime( 778): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 778): at java.lang.reflect.Method.invoke(Method.java:511) E/AndroidRuntime( 778): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) E/AndroidRuntime( 778): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) E/AndroidRuntime( 778): at dalvik.system.NativeStart.main(Native Method)
- Android-spinnerwheel - Pestaña individual dibujable
- Iniciar una actividad en la aplicación principal desde un módulo de la biblioteca de Android
- Android studio agregar proyecto externo a build.gradle
- Se encontraron 2 versiones de android-support-v4.jar en la lista de dependencias appcompat en android
- NoClassDefFoundError cuando la versión descendente Androod admite lib de 23.2.0 a 23.1.1
- No se puede depurar proyectos de biblioteca con ADT v14 - Origen no encontrado
- Gradle: pros / contras añadiendo dependencias
- Error al exportar la aplicación después de actualizar a Proguard 4.8
SetContentView (R.layout.activity_main);
Asegúrese de que el diseño en lib y su actividad de ejemplo no tenga el mismo nombre.
- ¿Cómo puedo dar cuatro clics de botón a la vista de la imagen?
- Android "cerrar la fuerza" lo que exactamente sucede con la memoria