Android : ClassNotFoundException - android-studio

I'm getting this wierd error. When I came back to work yesterday night, I was facing this error. What I didn't understand is that I never changed anything in the code. It feels like it came out of the blue.
07-21 01:23:52.051 27020-27020/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.thinkinetics.rob.routinebuilder, PID: 27020
java.lang.RuntimeException: Unable to instantiate service com.thinkinetics.rob.RoutineWatchface: java.lang.ClassNotFoundException: Didn't find class "com.thinkinetics.rob.RoutineWatchface" on path: DexPathList[[zip file "/data/app/com.thinkinetics.rob.routinebuilder-2/base.apk"],nativeLibraryDirectories=[/data/app/com.thinkinetics.rob.routinebuilder-2/lib/arm, /vendor/lib, /system/lib]]
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2862)
at android.app.ActivityThread.-wrap4(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1427)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5422)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.thinkinetics.rob.RoutineWatchface" on path: DexPathList[[zip file "/data/app/com.thinkinetics.rob.routinebuilder-2/base.apk"],nativeLibraryDirectories=[/data/app/com.thinkinetics.rob.routinebuilder-2/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2859)
at android.app.ActivityThread.-wrap4(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1427) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5422) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Suppressed: java.lang.ClassNotFoundException: Didn't find class "com.thinkinetics.rob.RoutineWatchface" on path: DexPathList[[dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-support-annotations-23.0.0_46201fc775bd6a2a1b3e71eae86ef67f12babd28-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-internal_impl-23.0.0_93b2086be48ba8bf011786c70052b2e5db3ad593-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-com.google.android.support-wearable-1.3.0_c1d538a0bc8f53c23014746aa746d7950ae7bc3a-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-com.google.android.gms-play-services-wearable-8.4.0_921a6b02116cb3c5229600c4895d4c7fb55e5cef-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-com.google.android.gms-play-services-basement-8.4.0_3194cc3fb6ccb6c92a69d7fc4ace71b161b64889-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-com.google.android.gms-play-services-base-8.4.0_30a8813ef567e92576c485da70ce277d4fc2397e-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-com.android.support-support-v4-23.0.0_7bc710f5526f9681c52eb6e494ababfb
Note: I did search for other questions with the same issue and I did find some. However, I followed every advice on those posts and it did not help me. After wasting my whole night I thought it would be a good idea to post here.
I'm not sure which parts of my code, if any, I should post along with this so I'll look at this actively and edit if necessary.
Here is the manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.thinkinetics.rob">
<uses-feature android:name="android.hardware.type.watch" />
<!-- Required to act as a custom watch face. -->
<uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#android:style/Theme.DeviceDefault">
<service
android:name=".RoutineWatchface"
android:label="#string/my_digital_name"
android:permission="android.permission.BIND_WALLPAPER">
<meta-data
android:name="android.service.wallpaper"
android:resource="#xml/watch_face" />
<meta-data
android:name="com.google.android.wearable.watchface.preview"
android:resource="#drawable/preview_digital" />
<meta-data
android:name="com.google.android.wearable.watchface.preview_circular"
android:resource="#drawable/preview_digital_circular" />
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
<category android:name="com.google.android.wearable.watchface.category.WATCH_FACE" />
</intent-filter>
</service>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
</manifest>
Thank you.

I encountered the same issue just now. I uninstalled the app from device, rebuilt the project and then installed again. This time I did not face the problem, and it worked fine.
It might be some intermittent bug with instant-run feature in studio.

Related

Android app adding toolbar causes exception

I thought I should add a toolbar as I'll need a settings button.
So I added this to my main_activity.xml
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="PSA MFD"
app:subtitle="Multi functional display for Citroen and Peugeot"
app:logo="#android:drawable/ic_menu_call"
app:navigationIcon="#drawable/ic_fan"
/>
But now my app won't run because:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rwb.psamfd/com.rwb.psamfd.MainActivity}: android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class android.support.v7.widget.Toolbar
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class android.support.v7.widget.Toolbar
Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class android.support.v7.widget.Toolbar
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.Toolbar" on path: DexPathList[[zip file "/data/app/com.rwb.psamfd-2/base.apk"],nativeLibraryDirectories=[/data/app/com.rwb.psamfd-2/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.view.LayoutInflater.createView(LayoutInflater.java:609)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.rwb.psamfd.MainActivity.onCreate(MainActivity.kt:31)
at android.app.Activity.performCreate(Activity.java:6662)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
What do I ned to do? I have absolutely no idea. (I'm new to Android development -- and it's very difficult compared to C#).
Method 1:
Add the following to your dependencies in build.gradle file:
dependencies {
...
**implementation 'androidx.appcompat:appcompat:1.0.0'**
}
And change your toolbar as:
<androidx.appcompat.widget.Toolbar
....
Your contents
....>
<androidx.appcompat.widget.Toolbar/>
Method 2:
You can migrate to androidx directly.
Hope you will find the solution.

Can't run the app after migration to androidX: android.view.InflateException

It took a lot of effort to migrate to androidX, but after all that I am still unable to resolve one issue.
When I try to run my app I get this error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{studio.dookola.zgkim/studio.dookola.zgkim.MainActivity}: android.view.InflateException: Binary XML file line #12: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: android.view.InflateException: Binary XML file line #12: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.widget.CoordinatorLayout" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/base.apk", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_dependencies_apk.apk", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_resources_apk.apk", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_slice_0_apk.apk", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_slice_1_apk.apk", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_slice_2_apk.apk", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_slice_3_apk.apk", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_slice_4_apk.apk", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_slice_5_apk.apk", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_slice_6_apk.apk", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_slice_7_apk.apk", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_slice_8_apk.apk", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/lib/x86, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.view.LayoutInflater.createView(LayoutInflater.java:606)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:965)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:859)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
2019-07-21 22:15:47.519 18965-18965/studio.dookola.zgkim E/AndroidRuntime: at studio.dookola.zgkim.MainActivity.onCreate(MainActivity.java:72)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Suppressed: java.io.IOException: No original dex files found for dex location /data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_resources_apk.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:354)
at dalvik.system.DexFile.<init>(DexFile.java:101)
at dalvik.system.DexFile.<init>(DexFile.java:75)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:394)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:354)
at dalvik.system.DexPathList.<init>(DexPathList.java:164)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:74)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:74)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:40)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:727)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:810)
at android.app.LoadedApk.getResources(LoadedApk.java:1032)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2345)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5749)
at android.app.ActivityThread.access$1100(ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
... 6 more
The pointed line 72 of MainActivity: setContentView(R.layout.activity_main);
My MainActivity .xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start"
layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<include
layout="#layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<com.google.android.material.navigation.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_main"
app:menu="#menu/activity_main_drawer"
/>
</androidx.drawerlayout.widget.DrawerLayout>
I have no idea what causes the problem.
I've searched stack overflow, but found no solution.
Any suggestion would be appreciated.
Caused by: android.view.InflateException: Binary XML file line #12: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
From these, I would guess that you haven't changed your dependencies and XML tags when migrating to AndroidX. The Refactor > Migrate to AndroidX tool doesn't do that for you, unfortunately, it only changes Java references. See this for more information. When you are done changing the Gradle dependencies, please change all older Android support tags to newer AndroidX tags in your XML files.

Oozie Spark2 Action throws "Attempt to add ({dependencyJar}) multiple times to the distributed cache."

Getting the below error while trying to load the dependency jar for oozie spark2 action. Added workflow.xml below.
Error:
2019-06-12 07:00:35,140 WARN SparkActionExecutor:523 -
SERVER[manager-0] USER[root] GROUP[-] TOKEN[] APP[spark-wf]
JOB[0000068-190611183932696-oozie-root-W]
ACTION[0000068-190611183932696-oozie-root-W#spark-node] Launcher
ERROR, reason: Main class [org.apache.oozie.action.hadoop.SparkMain],
main() threw exception,
Attempt to add (hdfs://${nameNode}/${workflowAppUri}/lib/${dependencyJar})
multiple times to the distributed cache.
workflow.xml
<workflow-app xmlns="uri:oozie:workflow:0.3" name="spark-wf">
<start to="spark-node"/>
<action name="spark-node">
<spark xmlns="uri:oozie:spark-action:0.1">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>${queueName}</value>
</property>
</configuration>
<master>yarn-cluster</master>
<name>test_spark</name>
<class>${className}</class>
<jar>${workflowAppUri}/lib/${executableJar}</jar>
<spark-opts>--jars ${workflowAppUri}/lib/${dependencyJar}</spark-opts>
<arg>${arg1}</arg>
<arg>${arg2}</arg>
</spark>
<ok to="end"/>
<error to="fail"/>
</action>
<kill name="fail">
<message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<end name="end"/>
</workflow-app>
This is not the same issue related to duplicate jars in oozie and spark2 sharelib directory. Have removed the duplicate jars in spark2 sharelib. But that doesn't help.
What could be the reason for this?
Please help me with this!!!
If we add jars in the lib directory of the application root directory, oozie automatically distributing the jars to it's distributed cache. In my case, I have tried to add the jar which is already in the lib directory. So, I just need to remove the below line from my workflow definition.
<spark-opts>--jars ${workflowAppUri}/lib/${dependencyJar}</spark-opts>
And also I have tested that if you want to attach the jars that are not available in your lib directory, you can mention like below in your workflow definition.
<spark-opts>--jars ${nameNode}/tmp/{someJar}</spark-opts>

Android Crashes on start up

Here is my code while having instant run enabled
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.alondra.positive1">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".RegisterActivity" />
<activity android:name=".MainActivity"/>
</application>
</manifest>
StackTrace
05-03 04:47:23.906 6489-6489/com.example.alondra.positive1
E/AndroidRuntime: FATAL EXCEPTION: main Process:
com.example.alondra.positive1, PID: 6489 java.lang.RuntimeException:
Unable to instantiate activity
ComponentInfo{com.example.alondra.positive1/com.example.alondra.positive1.LoginActivity}:
java.lang.ClassNotFoundException: Didn't find class
"com.example.alondra.positive1.LoginActivity" on path:
DexPathList[[zip file
"/data/app/com.example.alondra.positive1-2/base.apk", zip file
"/data/app/com.example.alondra.positive1-2/split_lib_dependencies_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_0_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_1_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_2_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_3_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_4_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_5_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_6_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_7_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_8_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/vendor/lib,
/system/lib]] at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2236)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151) at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102) at
android.os.Looper.loop(Looper.java:135) at
android.app.ActivityThread.main(ActivityThread.java:5254) at
java.lang.reflect.Method.invoke(Native Method) at
java.lang.reflect.Method.invoke(Method.java:372) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) Caused
by: java.lang.ClassNotFoundException: Didn't find class
"com.example.alondra.positive1.LoginActivity" on path:
DexPathList[[zip file
"/data/app/com.example.alondra.positive1-2/base.apk", zip file
"/data/app/com.example.alondra.positive1-2/split_lib_dependencies_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_0_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_1_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_2_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_3_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_4_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_5_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_6_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_7_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_8_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/vendor/lib,
/system/lib]] at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at
java.lang.ClassLoader.loadClass(ClassLoader.java:469) at
android.app.Instrumentation.newActivity(Instrumentation.java:1066) at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2226)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151) at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102) at
android.os.Looper.loop(Looper.java:135) at
android.app.ActivityThread.main(ActivityThread.java:5254) at
java.lang.reflect.Method.invoke(Native Method) at
java.lang.reflect.Method.invoke(Method.java:372) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Suppressed: java.lang.NoClassDefFoundError:
com.example.alondra.positive1.LoginActivity at
dalvik.system.DexFile.defineClassNative(Native Method) at
dalvik.system.DexFile.defineClass(DexFile.java:226) at
dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219) at
dalvik.system.DexPathList.findClass(DexPathList.java:321) at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
... 14 more Suppressed: java.io.IOException: Failed to open dex file
'/data/app/com.example.alondra.posit
and after disabling it
05-03 08:37:18.568 14647-14647/? E/libprocessgroup: failed to make and
chown /acct/uid_10059: Read-only file system 05-03 08:37:18.568
14647-14647/? W/Zygote: createProcessGroup failed, kernel missing
CONFIG_CGROUP_CPUACCT? 05-03 08:37:18.569 14647-14647/? I/art: Not
late-enabling -Xcheck:jni (already on) 05-03 08:37:18.677
14647-14647/com.example.alondra.positive1 I/InstantRun: starting
instant run server: is main process 05-03 08:37:18.679
14647-14647/com.example.alondra.positive1 I/art: Rejecting re-init on
previously-failed class
java.lang.Class 05-03
08:37:18.679 14647-14647/com.example.alondra.positive1
D/AndroidRuntime: Shutting down VM 05-03 08:37:18.681
14647-14647/com.example.alondra.positive1 E/AndroidRuntime: FATAL
EXCEPTION: main
Process: com.example.alondra.positive1, PID: 14647
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.example.alondra.positive1/com.example.alondra.positive1.LoginActivity}:
java.lang.ClassNotFoundException: Didn't find class
"com.example.alondra.positive1.LoginActivity" on path:
DexPathList[[zip file
"/data/app/com.example.alondra.positive1-2/base.apk", zip file
"/data/app/com.example.alondra.positive1-2/split_lib_dependencies_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_0_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_1_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_2_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_3_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_4_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_5_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_6_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_7_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_8_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/vendor/lib,
/system/lib]]
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2236)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.ClassNotFoundException: Didn't find class
"com.example.alondra.positive1.LoginActivity" on path:
DexPathList[[zip file
"/data/app/com.example.alondra.positive1-2/base.apk", zip file
"/data/app/com.example.alondra.positive1-2/split_lib_dependencies_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_0_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_1_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_2_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_3_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_4_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_5_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_6_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_7_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_8_apk.apk",
zip file
"/data/app/com.example.alondra.positive1-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/vendor/lib,
/system/lib]]
at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.Instrumentation.newActivity(Instrumentation.java:1066)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2226)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 
at android.app.ActivityThread.access$800(ActivityThread.java:151) 
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5254) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
Suppressed: java.lang.NoClassDefFoundError:
com.example.alondra.positive1.LoginActivity
at dalvik.system.DexFile.defineClassNative(Native Method)
at dalvik.system.DexFile.defineClass(DexFile.java:226)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
at dalvik.system.DexPathList.findClass(DexPathList.java:321)
at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
... 14 more
Suppressed: java.io.IOException: Failed to open dex file
'/data/app/com.example.alondra.posi 05-03 08:37:22.100 14647-14647/?
I/Process: Sending signal. PID: 14647 SIG: 9
If you need me to post a code please specify what code to post as I have 5 java and 3 xml so it would be a bit tedious
Have you declared your activity in Manifest?
Please check your manifest file, if LoginActivity is declared or not.If not please declare your activity in manifest and then try again.
Thanks.

Spring jms failing to connect to Websphere MQ - Resource Exception

Issue: Getting resource exception at runtime attempting to connect to a websphere mq to get a jms message using spring. I just can't determine what I am missing?
Description:
Attempting to set up the example here. Spring MDP Activation Spec for Websphere MQ.
http://stackoverflow.com/questions/14523572/spring-jms-and-websphere-mq
Maven Dependencies
Note: Version numbers for the ibm jars looks odd because I created a local repo in my project to add the 3rd party libraries. I'm taking the ibm jars from my local Websphere SDP version for Websphere 7.5 . I also tried directly adding the jar dependencies on the STS spring package and had the same error.
Spring Config XML
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-jms="http://www.springframework.org/schema/integration/jms"
xmlns:jms="http://www.springframework.org/schema/jms"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-4.1.xsd
http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms-4.1.xsd
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-4.1.xsd">
<bean id="messageListener" class="myproject.spring.integration.mq.SpringMdp" />
<bean id="messageListener" class="com.rohid.samples.SpringMdp" />
<bean class="org.springframework.jms.listener.endpoint.JmsMessageEndpointManager">
<property name="activationSpec">
<bean class="com.ibm.mq.connector.inbound.ActivationSpecImpl">
<property name="destinationType" value="javax.jms.Queue"/>
<property name="destination" value="QUEUE1"/>
<property name="hostName" value="A.B.C"/>
<property name="queueManager" value="QM_"/>
<property name="port" value="1414"/>
<property name="channel" value="SYSTEM.ADMIN.SVNNN"/>
<property name="transportType" value="CLIENT"/>
<property name="userName" value="abc"/>
<property name="password" value="jabc"/>
</bean>
</property>
<property name="messageListener" ref="messageListener"/>
<property name="resourceAdapter" ref="myResourceAdapterBean"/>
</bean>
<bean id="myResourceAdapterBean" org.springframework.jca.support.ResourceAdapterFactoryBean">
<property name="resourceAdapter">
<bean class="com.ibm.mq.connector.ResourceAdapterImpl">
<property name="maxConnections" value="50"/>
</bean>
</property>
<property name="workManager">
<bean class="org.springframework.jca.work.SimpleTaskWorkManager"/>
</property>
</bean>
</beans>
Stack Trace:
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.jms.listener.endpoint.JmsMessageEndpointManager#0' defined in class path resource [context.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/resource/ResourceException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1101)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1046)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at myproject.spring.integration.mq.Main.main(Main.java:9)
Caused by: java.lang.NoClassDefFoundError: javax/resource/ResourceException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getDeclaredConstructor(Unknown Source)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:80)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1094)
... 13 more
Caused by: java.lang.ClassNotFoundException: javax.resource.ResourceException
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 19 more
Updated- Solution: Required IBM Jar dependencies required.
Generally the easiest way to get the classpath right in RAD or other IBM tools for applications that are ultimately going to be deployed to WAS is to load the server runtime library of the WAS version into your app.
It is very easy. Go to the app properties page, go to build path, libraries tab and click add Library. You will see the screen shot below. Choose server runtimes and as long as you have installed the correct WAS versions as part of RAD, you will see their runtimes.
This is generally the best way to go since it allows you to keep you WAS libraries separate from your app, but to still make them available for compilation. The worst thing you can do is embed WAS libraries as part of your app. If you do this and you deploy your app to different versions of WAS, then you will get weird classpath or weird runtime errors. On top of that, things that were working might stop working after fixpacks get applied or other software adjustments.
If you add the server runtime library, then this is what your app will look like in RAD.
Looks like you are missing some dependencies here. Can you try to add javaee-api to your pom file?
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version> <!-- or take version 7.0 if needed -->
</dependency>

Resources