L lorebarita Member Licensed User Longtime User Dec 4, 2014 #1 Hi. I am trying to create a library that extends Activity. Such that when user clicks a certain button I call StartActivity(activity_in_library). I have seen similar libraries that works the same. Using SLC I am able to create the library successfully with the package name of my java project being (com.weight.example). I then created a B4A project with the same package name(com.weight.example) and in the manifest I added AddApplicationText(<activity android:name="WeightCaptureActivity"> <intent-filter> <action android:name="com.weight.example.WeightCaptureActivity" /> </intent-filter> </activity>) to register the activity that I want to start in my library. To start my activity I just call StartActivity("WeightCaptureActivity") but I get the following error. java.lang.ClassNotFoundException: com.weight.example.weightcaptureactivity at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:217) at java.lang.Class.forName(Class.java:172) at anywheresoftware.b4a.keywords.Common.getComponentIntent(Common.java:757) at anywheresoftware.b4a.keywords.Common.StartActivity(Common.java:679) at com.weight.example.main._button1_click(main.java:316) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:163) at anywheresoftware.b4a.BA.raiseEvent(BA.java:159) at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:66) at android.view.View.performClick(View.java:4212) at android.view.View$PerformClick.run(View.java:17476) at android.os.Handler.handleCallback(Handler.java:800) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5371) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NoClassDefFoundError: com/weight/example/weightcaptureactivity ... 23 more Caused by: java.lang.ClassNotFoundException: Didn't find class "com.weight.example.weightcaptureactivity" on path: DexPathList[[zip file "/data/app/com.weight.example-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.weight.example-1, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53) at java.lang.ClassLoader.loadClass(ClassLoader.java:501) at java.lang.ClassLoader.loadClass(ClassLoader.java:461) ... 23 more java.lang.ClassNotFoundException: com.weight.example.weightcaptureactivity Please help. I have attached the library and the b4a sample example. Attachments lib that extends activity.zip lib that extends activity.zip 344.2 KB · Views: 455
Hi. I am trying to create a library that extends Activity. Such that when user clicks a certain button I call StartActivity(activity_in_library). I have seen similar libraries that works the same. Using SLC I am able to create the library successfully with the package name of my java project being (com.weight.example). I then created a B4A project with the same package name(com.weight.example) and in the manifest I added AddApplicationText(<activity android:name="WeightCaptureActivity"> <intent-filter> <action android:name="com.weight.example.WeightCaptureActivity" /> </intent-filter> </activity>) to register the activity that I want to start in my library. To start my activity I just call StartActivity("WeightCaptureActivity") but I get the following error. java.lang.ClassNotFoundException: com.weight.example.weightcaptureactivity at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:217) at java.lang.Class.forName(Class.java:172) at anywheresoftware.b4a.keywords.Common.getComponentIntent(Common.java:757) at anywheresoftware.b4a.keywords.Common.StartActivity(Common.java:679) at com.weight.example.main._button1_click(main.java:316) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:163) at anywheresoftware.b4a.BA.raiseEvent(BA.java:159) at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:66) at android.view.View.performClick(View.java:4212) at android.view.View$PerformClick.run(View.java:17476) at android.os.Handler.handleCallback(Handler.java:800) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5371) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NoClassDefFoundError: com/weight/example/weightcaptureactivity ... 23 more Caused by: java.lang.ClassNotFoundException: Didn't find class "com.weight.example.weightcaptureactivity" on path: DexPathList[[zip file "/data/app/com.weight.example-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.weight.example-1, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53) at java.lang.ClassLoader.loadClass(ClassLoader.java:501) at java.lang.ClassLoader.loadClass(ClassLoader.java:461) ... 23 more java.lang.ClassNotFoundException: com.weight.example.weightcaptureactivity Please help. I have attached the library and the b4a sample example.
vpires Member Licensed User Longtime User Dec 4, 2014 #2 Not tested, but... Code: Dim i As Intent i.Initialize("","") i.SetComponent("com.weight.example/com.weight.example.WeightCaptureActivity") StartActivity(i) and in the manifest, this should be enough : Code: AddApplicationText( <activity android:name="com.weight.example.WeightCaptureActivity"> </activity>)
Not tested, but... Code: Dim i As Intent i.Initialize("","") i.SetComponent("com.weight.example/com.weight.example.WeightCaptureActivity") StartActivity(i) and in the manifest, this should be enough : Code: AddApplicationText( <activity android:name="com.weight.example.WeightCaptureActivity"> </activity>)
L lorebarita Member Licensed User Longtime User Dec 4, 2014 #3 You must be heaven sent it worked perfectly well. Thanks soo much.