Here is the xml file of my Android widget:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="fill_parent"
android:stretchColumns="1">
<TableRow>
<!-- Some views -->
</TableRow>
<TableRow>
<!-- Some views -->
</TableRow>
</TableLayout>
</LinearLayout>
(full code here: http://pastebin.com/Kqxs5t9E)
This code is showing me some good results in Eclipse, but as soon as I sent the file to my device and try to add the widget to my homescreen I get this error code and the widget showing: "Problem Loading the Widget":
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): updateAppWidget couldn't find any view, using error view
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): android.view.InflateException: Binary XML file line #20: Error inflating class android.widget.TableLayout
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): at android.widget.RemoteViews.apply(RemoteViews.java:930)
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): at android.appwidget.AppWidgetHostView.updateAppWidget(AppWidgetHostView.java:219)
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): at android.appwidget.AppWidgetHostView.updateAppWidget(AppWidgetHostView.java:155)
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): at android.appwidget.AppWidgetHost.createView(AppWidgetHost.java:218)
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): at com.fede.launcher.Launcher.bindAppWidgets(Launcher.java:3652)
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): at com.fede.launcher.Launcher.access$22(Launcher.java:3639)
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): at com.fede.launcher.Launcher$DesktopBinder.handleMessage(Launcher.java:4625)
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): at android.os.Handler.dispatchMessage(Handler.java:99)
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): at android.os.Looper.loop(Looper.java:123)
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): at android.app.ActivityThread.main(ActivityThread.java:4627)
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): at java.lang.reflect.Method.invokeNative(Native Method)
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): at java.lang.reflect.Method.invoke(Method.java:521)
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): at dalvik.system.NativeStart.main(Native Method)
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): Caused by: android.view.InflateException: Binary XML file line #20: Class not allowed to be inflated android.widget.TableLayout
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): at android.view.LayoutInflater.failNotAllowed(LayoutInflater.java:525)
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): at android.view.LayoutInflater.createView(LayoutInflater.java:472)
08-01 22:11:26.917: WARN/AppWidgetHostView(5860): ... 20 more
So what? I cannot use a Tablelayout within a widget????
What is the best solution so? I can create a lot of relativelayout but I guess that's not a good idea.
I cannot use a Tablelayout within a
widget????
If by "widget" you mean "app widget", then, no, you cannot use a TableLayout in an app widget. There are only a few widgets that can be used in an app widget.
I can create a lot of relativelayout
but I guess that's not a good idea.
I do not know why you think RelativeLayout is bad. You may be able to replace your LinearLayout, TableLayout, and TableRow widgets with a single RelativeLayout.
Related
I have a project which uses a WelcomeActivity which extends FragmentActivity. I use the support library, so android-support-v4.jar is in the libs folder. When I run this app, there are no problems.
However, I want to add ActionBarSherlock to the project. In the ABS project I use actionbarsherlock-plugin-maps-4.1.0.jar and android-support-v4-r6-googlemaps.jar in the libs folder. In my app project I add the ABS library, and when I try to run the app, this error occurs:
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoStubImpl;
To solve this, I removed the android-support-v4.jar from my app's libs folder. When I now start my app, the app crashes with this logcat:
08-01 18:59:11.182: W/dalvikvm(13338): Unable to resolve superclass of Landroid/support/v4/app/FragmentActivity; (620)
08-01 18:59:11.182: W/dalvikvm(13338): Link of class 'Landroid/support/v4/app/FragmentActivity;' failed
08-01 18:59:11.182: W/dalvikvm(13338): Unable to resolve superclass of Lcom/myapp/welcome/WelcomeActivity; (109)
08-01 18:59:11.182: W/dalvikvm(13338): Link of class 'Lcom/myapp/welcome/WelcomeActivity;' failed
08-01 18:59:11.182: E/dalvikvm(13338): Could not find class 'com.myapp.welcome.WelcomeActivity', referenced from method com.myapp.MainDispatcherActivity.startWelcomeActivity
08-01 18:59:11.182: W/dalvikvm(13338): VFY: unable to resolve const-class 690 (Lcom/myapp/welcome/WelcomeActivity;) in Lcom/myapp/MainDispatcherActivity;
08-01 18:59:11.182: D/dalvikvm(13338): VFY: replacing opcode 0x1c at 0x0002
08-01 18:59:11.182: D/dalvikvm(13338): VFY: dead code 0x0004-000b in Lcom/myapp/MainDispatcherActivity;.startWelcomeActivity ()V
08-01 18:59:11.182: D/AndroidRuntime(13338): Shutting down VM
08-01 18:59:11.182: W/dalvikvm(13338): threadid=1: thread exiting with uncaught exception (group=0x40015560)
08-01 18:59:11.182: E/AndroidRuntime(13338): FATAL EXCEPTION: main
08-01 18:59:11.182: E/AndroidRuntime(13338): java.lang.NoClassDefFoundError: com.myapp.welcome.WelcomeActivity
08-01 18:59:11.182: E/AndroidRuntime(13338): at com.myapp.MainDispatcherActivity.startWelcomeActivity(MainDispatcherActivity.java:33)
08-01 18:59:11.182: E/AndroidRuntime(13338): at com.myapp.MainDispatcherActivity.startProperActivity(MainDispatcherActivity.java:26)
08-01 18:59:11.182: E/AndroidRuntime(13338): at com.myapp.MainDispatcherActivity.onCreate(MainDispatcherActivity.java:19)
08-01 18:59:11.182: E/AndroidRuntime(13338): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-01 18:59:11.182: E/AndroidRuntime(13338): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
08-01 18:59:11.182: E/AndroidRuntime(13338): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
08-01 18:59:11.182: E/AndroidRuntime(13338): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
08-01 18:59:11.182: E/AndroidRuntime(13338): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
08-01 18:59:11.182: E/AndroidRuntime(13338): at android.os.Handler.dispatchMessage(Handler.java:99)
08-01 18:59:11.182: E/AndroidRuntime(13338): at android.os.Looper.loop(Looper.java:130)
08-01 18:59:11.182: E/AndroidRuntime(13338): at android.app.ActivityThread.main(ActivityThread.java:3683)
08-01 18:59:11.182: E/AndroidRuntime(13338): at java.lang.reflect.Method.invokeNative(Native Method)
08-01 18:59:11.182: E/AndroidRuntime(13338): at java.lang.reflect.Method.invoke(Method.java:507)
08-01 18:59:11.182: E/AndroidRuntime(13338): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
08-01 18:59:11.182: E/AndroidRuntime(13338): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
08-01 18:59:11.182: E/AndroidRuntime(13338): at dalvik.system.NativeStart.main(Native Method)
How can I fix this?
Edit
I have another project which uses the same ABS library, and runs fine. I have no idea what I've done differently, or which settings are wrong.
It seems this error occurred because I didn't have this line in the AndroidManifest.xml file, in the <application> tag:
<uses-library android:name="com.google.android.maps" />
Click here
I think it is the same problem at the Build Path-> Configure Build Path -> Order and Export, the "android-support-v4.jar" needs to be checked.
Hope it is useful to you.
Have you set the compiler compliance for the actionbarsherlock library project? Right click on the library project, go to properties. Under java compiler, make sure compliance is set to 1.6. I had a similar issue, and found the compliance set to 1.5.
I haven't run into it myself, but I think the doc for ActionBarSherlock says you need to extend SherlockFragmentActivity rather than FragmentActivity. It may not be the problem, but it's a problem.
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I know there are many people who have the problem. I've tried many ways I can find, however still get the error.
there's only one activity and it's registered.
tried to complete .MainActivity by com.hermione.woodenfish.MainActivity, no use
clean and rebuild don't work either
really need help, thanks!!
LogCat:
08-01 12:09:33.944: E/Trace(1032): error opening trace file: No such file or directory (2)
08-01 12:09:34.384: D/AndroidRuntime(1032): Shutting down VM
08-01 12:09:34.424: W/dalvikvm(1032): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
08-01 12:09:34.465: E/AndroidRuntime(1032): FATAL EXCEPTION: main
08-01 12:09:34.465: E/AndroidRuntime(1032): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.hermione.woodenfish/com.hermione.woodenfish.MainActivity}: java.lang.NullPointerException
08-01 12:09:34.465: E/AndroidRuntime(1032): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
08-01 12:09:34.465: E/AndroidRuntime(1032): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
08-01 12:09:34.465: E/AndroidRuntime(1032): at android.app.ActivityThread.access$600(ActivityThread.java:130)
08-01 12:09:34.465: E/AndroidRuntime(1032): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
08-01 12:09:34.465: E/AndroidRuntime(1032): at android.os.Handler.dispatchMessage(Handler.java:99)
08-01 12:09:34.465: E/AndroidRuntime(1032): at android.os.Looper.loop(Looper.java:137)
08-01 12:09:34.465: E/AndroidRuntime(1032): at android.app.ActivityThread.main(ActivityThread.java:4745)
08-01 12:09:34.465: E/AndroidRuntime(1032): at java.lang.reflect.Method.invokeNative(Native Method)
08-01 12:09:34.465: E/AndroidRuntime(1032): at java.lang.reflect.Method.invoke(Method.java:511)
08-01 12:09:34.465: E/AndroidRuntime(1032): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-01 12:09:34.465: E/AndroidRuntime(1032): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-01 12:09:34.465: E/AndroidRuntime(1032): at dalvik.system.NativeStart.main(Native Method)
08-01 12:09:34.465: E/AndroidRuntime(1032): Caused by: java.lang.NullPointerException
08-01 12:09:34.465: E/AndroidRuntime(1032): at android.content.ContextWrapper.getResources(ContextWrapper.java:81)
08-01 12:09:34.465: E/AndroidRuntime(1032): at android.media.MediaPlayer.create(MediaPlayer.java:824)
08-01 12:09:34.465: E/AndroidRuntime(1032): at com.hermione.woodenfish.MainActivity.<init>(MainActivity.java:24)
08-01 12:09:34.465: E/AndroidRuntime(1032): at java.lang.Class.newInstanceImpl(Native Method)
08-01 12:09:34.465: E/AndroidRuntime(1032): at java.lang.Class.newInstance(Class.java:1319)
08-01 12:09:34.465: E/AndroidRuntime(1032): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
08-01 12:09:34.465: E/AndroidRuntime(1032): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
08-01 12:09:34.465: E/AndroidRuntime(1032): ... 11 more
08-01 12:33:02.784: E/Trace(1171): error opening trace file: No such file or directory (2)
08-01 12:33:03.125: D/AndroidRuntime(1171): Shutting down VM
08-01 12:33:03.125: W/dalvikvm(1171): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
08-01 12:33:03.154: E/AndroidRuntime(1171): FATAL EXCEPTION: main
08-01 12:33:03.154: E/AndroidRuntime(1171): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.hermione.woodenfish/com.hermione.woodenfish.MainActivity}: java.lang.NullPointerException
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.app.ActivityThread.access$600(ActivityThread.java:130)
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.os.Handler.dispatchMessage(Handler.java:99)
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.os.Looper.loop(Looper.java:137)
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.app.ActivityThread.main(ActivityThread.java:4745)
08-01 12:33:03.154: E/AndroidRuntime(1171): at java.lang.reflect.Method.invokeNative(Native Method)
08-01 12:33:03.154: E/AndroidRuntime(1171): at java.lang.reflect.Method.invoke(Method.java:511)
08-01 12:33:03.154: E/AndroidRuntime(1171): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-01 12:33:03.154: E/AndroidRuntime(1171): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-01 12:33:03.154: E/AndroidRuntime(1171): at dalvik.system.NativeStart.main(Native Method)
08-01 12:33:03.154: E/AndroidRuntime(1171): Caused by: java.lang.NullPointerException
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.content.ContextWrapper.getResources(ContextWrapper.java:81)
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.media.MediaPlayer.create(MediaPlayer.java:824)
08-01 12:33:03.154: E/AndroidRuntime(1171): at com.hermione.woodenfish.MainActivity.<init>(MainActivity.java:23)
08-01 12:33:03.154: E/AndroidRuntime(1171): at java.lang.Class.newInstanceImpl(Native Method)
08-01 12:33:03.154: E/AndroidRuntime(1171): at java.lang.Class.newInstance(Class.java:1319)
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
08-01 12:33:03.154: E/AndroidRuntime(1171): ... 11 more
MainActivity.java
package com.hermione.woodenfish;
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
public class MainActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
private MediaPlayer mp = MediaPlayer.create(this, R.raw.knok);
public void sendKnok(View view) {
if (mp.isPlaying()){
mp.stop();
}
mp.start();
}
}
Manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hermione.woodenfish"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I think the problem is here in this line,
private MediaPlayer mp = MediaPlayer.create(this, R.raw.knok);
You have tried to initialize the Context object before the onCreate(). This might be creating the problem. How about you Initialize your MediaPlayer inside your onCreate(),
private MediaPlayer mp =null; //Global Declaration
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mp = MediaPlayer.create(this, R.raw.knok);
}
Your problem is here:
08-01 12:33:03.154: E/AndroidRuntime(1171): Caused by: java.lang.NullPointerException
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.content.ContextWrapper.getResources(ContextWrapper.java:81)
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.media.MediaPlayer.create(MediaPlayer.java:824)
08-01 12:33:03.154: E/AndroidRuntime(1171): at com.hermione.woodenfish.MainActivity.<init>(MainActivity.java:23)
08-01 12:33:03.154: E/AndroidRuntime(1171): at java.lang.Class.newInstanceImpl(Native Method)
08-01 12:33:03.154: E/AndroidRuntime(1171): at java.lang.Class.newInstance(Class.java:1319)
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
08-01 12:33:03.154: E/AndroidRuntime(1171): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
08-01 12:33:03.154: E/AndroidRuntime(1171): ... 11 more
You're getting a NullPointerException. Look at line 23 in MainActivity in debug and see what's happening.
I am trying to run my application, but whenever I make a call to a native function it gives me an error and the program crashes. I'm sure it has to do with how I am naming something either in Java or in C.
Here is my call to the functions in Java :
package my.commander;
public class RelayAPIModel {
public static class NativeCalls {
static {
System.loadLibrary( "RelayAPI");
}
public native static byte InitRelayJava();
public native static void FreeRelayJava();
}
Here are the functions in the .c file:
void Java_my_commander_RelayAPIModel_FreeRelayJava( JNIEnv * env, jobject this ) {
RelayAPI_DataValid = 0;
RelayAPI_SetBaud = 0;
RelayAPI_get = 0;
RelayAPI_put = 0;
RelayAPI_flush = 0;
RelayAPI_delay = 0;
RelayAPI_initilized = 0;
}
BYTE Java_my_commander_RelayAPIModel_InitRelayJava( JNIEnv *env, jobject obj ) {
...
...
}
Here they are in the .h file :
void Java_my_commander_RelayAPIModel_FreeRelayJava( JNIEnv * env, jobject obj );
BYTE Java_my_commander_RelayAPIModel_InitRelayJava( JNIEnv *env, jobject obj );
Here is my LogCat:
08-01 09:58:21.933: E/AndroidRuntime(17170): FATAL EXCEPTION: main
08-01 09:58:21.933: E/AndroidRuntime(17170): java.lang.UnsatisfiedLinkError: InitRelayJava
08-01 09:58:21.933: E/AndroidRuntime(17170): at my.eti.commander.RelayAPIModel$NativeCalls.InitRelayJava(Native Method)
08-01 09:58:21.933: E/AndroidRuntime(17170): at my.eti.commander.MainMenu.initMain(MainMenu.java:241)
08-01 09:58:21.933: E/AndroidRuntime(17170): at my.eti.commander.MainMenu.onCreate(MainMenu.java:81)
08-01 09:58:21.933: E/AndroidRuntime(17170): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-01 09:58:21.933: E/AndroidRuntime(17170): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
08-01 09:58:21.933: E/AndroidRuntime(17170): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
08-01 09:58:21.933: E/AndroidRuntime(17170): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
08-01 09:58:21.933: E/AndroidRuntime(17170): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
08-01 09:58:21.933: E/AndroidRuntime(17170): at android.os.Handler.dispatchMessage(Handler.java:99)
08-01 09:58:21.933: E/AndroidRuntime(17170): at android.os.Looper.loop(Looper.java:130)
08-01 09:58:21.933: E/AndroidRuntime(17170): at android.app.ActivityThread.main(ActivityThread.java:3683)
08-01 09:58:21.933: E/AndroidRuntime(17170): at java.lang.reflect.Method.invokeNative(Native Method)
08-01 09:58:21.933: E/AndroidRuntime(17170): at java.lang.reflect.Method.invoke(Method.java:507)
08-01 09:58:21.933: E/AndroidRuntime(17170): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-01 09:58:21.933: E/AndroidRuntime(17170): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-01 09:58:21.933: E/AndroidRuntime(17170): at dalvik.system.NativeStart.main(Native Method)
I would like to clarify now, that I have tried changing the C method names to Java_my_commander_RelayAPIModel_NativeCalls_FreeRelayJava and Java_my_commander_RelayAPIModel_NativeCalls_InitRelayJava. The application still failed to launch and this was the LogCat for that:
08-01 11:22:10.735: E/AndroidRuntime(17441): FATAL EXCEPTION: main
08-01 11:22:10.735: E/AndroidRuntime(17441): java.lang.UnsatisfiedLinkError: InitRelayJava
08-01 11:22:10.735: E/AndroidRuntime(17441): at my.eti.commander.RelayAPIModel$NativeCalls.InitRelayJava(Native Method)
08-01 11:22:10.735: E/AndroidRuntime(17441): at my.eti.commander.MainMenu.initMain(MainMenu.java:241)
08-01 11:22:10.735: E/AndroidRuntime(17441): at my.eti.commander.MainMenu.onCreate(MainMenu.java:81)
08-01 11:22:10.735: E/AndroidRuntime(17441): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-01 11:22:10.735: E/AndroidRuntime(17441): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
08-01 11:22:10.735: E/AndroidRuntime(17441): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
08-01 11:22:10.735: E/AndroidRuntime(17441): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
08-01 11:22:10.735: E/AndroidRuntime(17441): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
08-01 11:22:10.735: E/AndroidRuntime(17441): at android.os.Handler.dispatchMessage(Handler.java:99)
08-01 11:22:10.735: E/AndroidRuntime(17441): at android.os.Looper.loop(Looper.java:130)
08-01 11:22:10.735: E/AndroidRuntime(17441): at android.app.ActivityThread.main(ActivityThread.java:3683)
08-01 11:22:10.735: E/AndroidRuntime(17441): at java.lang.reflect.Method.invokeNative(Native Method)
08-01 11:22:10.735: E/AndroidRuntime(17441): at java.lang.reflect.Method.invoke(Method.java:507)
08-01 11:22:10.735: E/AndroidRuntime(17441): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-01 11:22:10.735: E/AndroidRuntime(17441): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-01 11:22:10.735: E/AndroidRuntime(17441): at dalvik.system.NativeStart.main(Native Method)
Now, I think that the error lies in the code above. If you all think there is nothing wrong with it, I'm going to add some more information down here just in case the problem lies elsewhere.
This application that I'm creating, uses the functions above to call a library that has been being used for a while. This library was previously used to call functions in a Palm Pilot program which utilize the Palm's bluetooth capabilities. Since Android devices have different bluetooth libraries/capabilities, I am adding code to the native library to call BACK to the java code, to access the Android device's bluetooth capabilities. I do not want to post all of the code pertaining to this here, but if someone feels that it needs to be posted I will.
The error message says it's at:
my.eti.commander.RelayAPIModel$NativeCalls.InitRelayJava (Native Method)
So make sure that:
the native method declaration is indeed inside the RelayAPIModel class, not insude the RelayAPIModel.NativeCalls nested class.
the package name on Java side is my.commander as opposed to my.eti.commander
EDIT: or you can fix that on the C side. If you want to create native methods in the nested class, the proper name for it would be:
Java_my_commander_RelayAPIModel_00024NativeCalls_InitRelayJava()
The 00024 is the code of the $ character, which is the nested class delimiter in Java internals. Also, the meaning of the of second parameter (jobject Obj) will be different - instead of this pointer/class pointer for RelayAPIModel, it will be the one for the RelayAPIModel.NativeCalls. You won't be able to use it to resolve/call methods in the RelayAPIModel.
You can use javah to generate a .h file with the correctly named native files:
javah -jni -classpath bin/classes com.example.app.MyClass
i got following strange exception on only andorid simulator 2.0
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.markupartist.android.example.pulltorefresh/com.markupartist.android.example.pulltorefresh.PullToRefreshActivity}: android.view.InflateException: Binary XML file line #10: Error inflating class com.markupartist.android.widget.PullToRefreshListView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class com.markupartist.android.widget.PullToRefreshListView
at android.view.LayoutInflater.createView(LayoutInflater.java:513)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
at android.app.Activity.setContentView(Activity.java:1647)
at com.markupartist.android.example.pulltorefresh.PullToRefreshActivity.onCreate(PullToRefresh Activity.java:21)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at com.markupartist.android.widget.PullToRefreshListView. (PullToRefreshListView.java:54)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
... 21 more
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030002
at android.content.res.Resources.getValue(Resources.java:892)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:1869)
at android.content.res.Resources.getLayout(Resources.java:731)
at android.view.LayoutInflater.inflate(LayoutInflater.java:318)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.markupartist.android.widget.PullToRefreshListView.init(PullToRefreshListView.java:80)
... 25 more
when i tested on andorid 1.6 , 2.01,2.1,2.2,2.3 ,4.0 it works completely,
is this a simulator bug of 2.0
please give me some information about this
Thanks
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.falling.inairproandmark/com.falling.inairproandmark.Q9Popup}: android.view.InflateException: Binary XML file line #9: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:513)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:219)
at android.app.Activity.setContentView(Activity.java:1647)
at com.falling.inairproandmark.Q9Popup.onCreate(Q9Popup.java:36)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at android.widget.Button.<init>(Button.java:65)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
... 22 more
Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
at android.content.res.Resources.loadDrawable(Resources.java:1709)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:1885)
at android.widget.TextView.<init>(TextView.java:352)
at android.widget.Button.<init>(Button.java:69)
... 26 more
==
here's my xml layout:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button android:background="#drawable/q9popup" android:id="#+id/qnine"
android:layout_width="fill_parent" android:layout_height="fill_parent">
</Button>
<com.google.ads.AdView android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="**********"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"/>
</AbsoluteLayout>
I don't understand why I keep getting this error :S
Please help.
Thanks
Android cannot allocate the memory for the Button. Pre-Honeycomb allocates the memory for a bitmap natively, outside the Dalvik VM, using malloc and has to rely on Java finalizers to free that memory again. Unless you call Bitmap.recycle that is.
See http://www.youtube.com/watch?v=_CruQY55HOk&feature=player_detailpage#t=650s for some info on allocation of Bitmaps.
So you have to figure out why external allocation is so high in your app. Maybe AdMob is the cause. Make sure to invoke AdView.destroy in your activity's onDestroy.