i am trying to make a simple piano app. I found this tutorial ;http://www.martinhoeller.net/2012/01/13/developing-a-musical-instrument-app-for-android/ .
I downloaded the file on this link and import it. I run the app and there are 4 buttons on it which plays 4 different notes that are loaded in assets files.
And then i tried to modify this project to make a piano app.
At first i deleted these red buttons from xml.
I added a piano image to background.
And then i created buttons on each key.
The xml file is ;
<?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"
android:layout_gravity="fill_vertical"
android:background="#drawable/images"
android:orientation="vertical" >
<Button
android:id="#+id/buttonC4"
android:layout_width="294dp"
android:layout_height="60dp"
android:background="#android:color/transparent"
android:gravity="center_vertical|center_horizontal" />
<Button
android:id="#+id/buttonD4"
android:layout_width="294dp"
android:layout_height="60dp"
android:background="#android:color/transparent"
android:gravity="center_vertical|center_horizontal" />
<Button
android:id="#+id/buttonE4"
android:layout_width="294dp"
android:layout_height="60dp"
android:background="#android:color/transparent"
android:gravity="center_vertical|center_horizontal" />
<Button
android:id="#+id/buttonF4"
android:layout_width="294dp"
android:layout_height="58dp"
android:background="#android:color/transparent"
android:gravity="center_vertical|center_horizontal" />
<Button
android:id="#+id/buttonG4"
android:layout_width="294dp"
android:layout_height="58dp"
android:background="#android:color/transparent"
android:gravity="center_vertical|center_horizontal" />
<Button
android:id="#+id/buttonA4"
android:layout_width="294dp"
android:layout_height="60dp"
android:background="#android:color/transparent"
android:gravity="center_vertical|center_horizontal" />
<Button
android:id="#+id/buttonB4"
android:layout_width="294dp"
android:layout_height="58dp"
android:background="#android:color/transparent"
android:gravity="center_vertical|center_horizontal" />
<Button
android:id="#+id/buttonC5"
android:layout_width="294dp"
android:layout_height="58dp"
android:background="#android:color/transparent"
android:gravity="center_vertical|center_horizontal" />
<Button
android:id="#+id/buttonD5"
android:layout_width="294dp"
android:layout_height="58dp"
android:background="#android:color/transparent"
android:gravity="center_vertical|center_horizontal" />
<Button
android:id="#+id/buttonE5"
android:layout_width="294dp"
android:layout_height="58dp"
android:background="#android:color/transparent"
android:gravity="center_vertical|center_horizontal" />
</LinearLayout>
Then i found notes on internet and download them .
I upload these note files to assets folder.
Each of them is in the wav format.
Then i added these codes to PianoTest Activity ;
buttons = new ArrayList<View>();
buttons.add(findViewById(R.id.buttonC4));
buttons.add(findViewById(R.id.buttonD4));
buttons.add(findViewById(R.id.buttonF4));
buttons.add(findViewById(R.id.buttonG4));
buttons.add(findViewById(R.id.buttonA4));
buttons.add(findViewById(R.id.buttonB4));
buttons.add(findViewById(R.id.buttonC5));
buttons.add(findViewById(R.id.buttonD5));
buttons.add(findViewById(R.id.buttonE5));
And then i modified this function ;
private void toggleButtonSound(View button, boolean down)
{
String note = null;
switch (button.getId())
{
case R.id.buttonC4:
note = "C4";
break;
case R.id.buttonD4:
note = "D4";
break;
case R.id.buttonE4:
note = "E4";
break;
case R.id.buttonF4:
note = "F4";
break;
case R.id.buttonG4:
note = "G4";
break;
case R.id.buttonA4:
note = "A4";
break;
case R.id.buttonB4:
note = "B4";
break;
case R.id.buttonC5:
note = "C5";
break;
case R.id.buttonD5:
note = "D5";
break;
case R.id.buttonE5:
note = "E5";
break;
}
Then i changed AudioTrack class . I changed the format to wav file ;
public void run()
{
try
{
String path = note + ".wav";
Everything else is the same as in the original project.
But the app doesnt work properly.
When i run the app and click one the transparent buttons on a key , it plays a sound but it is not the same sound as it is.
It sounds something different.I can say that an elektronic version of a note.
And when i click some other keys the application crashes . It says the application stopped unexpectedly.
What is wrong ? What should i do to make it work ? The reason can be the files i dpwnloaded. What kind of notes do i need to find ? Is there any special format in terms of their bits or time durations for this project ?
This is very important for me , if you can download the file from the link and run , you can see how it works. You can suggest me the ways to modify it. I hope you can help me.
This is the logcat :
05-13 19:49:55.580: D/AndroidRuntime(485): Shutting down VM
05-13 19:49:55.580: W/dalvikvm(485): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-13 19:49:55.600: E/AndroidRuntime(485): FATAL EXCEPTION: main
05-13 19:49:55.600: E/AndroidRuntime(485): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.martinhoeller/net.martinhoeller.PianoTestActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class ButtonView
05-13 19:49:55.600: E/AndroidRuntime(485): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
05-13 19:49:55.600: E/AndroidRuntime(485): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-13 19:49:55.600: E/AndroidRuntime(485): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-13 19:49:55.600: E/AndroidRuntime(485): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-13 19:49:55.600: E/AndroidRuntime(485): at android.os.Handler.dispatchMessage(Handler.java:99)
05-13 19:49:55.600: E/AndroidRuntime(485): at android.os.Looper.loop(Looper.java:123)
05-13 19:49:55.600: E/AndroidRuntime(485): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-13 19:49:55.600: E/AndroidRuntime(485): at java.lang.reflect.Method.invokeNative(Native Method)
05-13 19:49:55.600: E/AndroidRuntime(485): at java.lang.reflect.Method.invoke(Method.java:521)
05-13 19:49:55.600: E/AndroidRuntime(485): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-13 19:49:55.600: E/AndroidRuntime(485): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-13 19:49:55.600: E/AndroidRuntime(485): at dalvik.system.NativeStart.main(Native Method)
05-13 19:49:55.600: E/AndroidRuntime(485): Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class ButtonView
05-13 19:49:55.600: E/AndroidRuntime(485): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
05-13 19:49:55.600: E/AndroidRuntime(485): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
05-13 19:49:55.600: E/AndroidRuntime(485): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
05-13 19:49:55.600: E/AndroidRuntime(485): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
05-13 19:49:55.600: E/AndroidRuntime(485): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
05-13 19:49:55.600: E/AndroidRuntime(485): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
05-13 19:49:55.600: E/AndroidRuntime(485): at android.app.Activity.setContentView(Activity.java:1647)
05-13 19:49:55.600: E/AndroidRuntime(485): at net.martinhoeller.PianoTestActivity.onCreate(PianoTestActivity.java:23)
05-13 19:49:55.600: E/AndroidRuntime(485): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-13 19:49:55.600: E/AndroidRuntime(485): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-13 19:49:55.600: E/AndroidRuntime(485): ... 11 more
05-13 19:49:55.600: E/AndroidRuntime(485): Caused by: java.lang.ClassNotFoundException: android.view.ButtonView in loader dalvik.system.PathClassLoader[/data/app/net.martinhoeller-1.apk]
05-13 19:49:55.600: E/AndroidRuntime(485): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
05-13 19:49:55.600: E/AndroidRuntime(485): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
05-13 19:49:55.600: E/AndroidRuntime(485): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
05-13 19:49:55.600: E/AndroidRuntime(485): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
05-13 19:49:55.600: E/AndroidRuntime(485): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
05-13 19:49:55.600: E/AndroidRuntime(485): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
05-13 19:49:55.600: E/AndroidRuntime(485): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
05-13 19:49:55.600: E/AndroidRuntime(485): ... 20 more
05-13 19:52:22.293: D/AndroidRuntime(513): Shutting down VM
05-13 19:52:22.293: W/dalvikvm(513): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
05-13 19:52:22.309: E/AndroidRuntime(513): FATAL EXCEPTION: main
05-13 19:52:22.309: E/AndroidRuntime(513): java.lang.ArrayIndexOutOfBoundsException
05-13 19:52:22.309: E/AndroidRuntime(513): at net.martinhoeller.PianoTestActivity.onTouchEvent(PianoTestActivity.java:66)
05-13 19:52:22.309: E/AndroidRuntime(513): at android.app.Activity.dispatchTouchEvent(Activity.java:2089)
05-13 19:52:22.309: E/AndroidRuntime(513): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1655)
05-13 19:52:22.309: E/AndroidRuntime(513): at android.view.ViewRoot.handleMessage(ViewRoot.java:1785)
05-13 19:52:22.309: E/AndroidRuntime(513): at android.os.Handler.dispatchMessage(Handler.java:99)
05-13 19:52:22.309: E/AndroidRuntime(513): at android.os.Looper.loop(Looper.java:123)
05-13 19:52:22.309: E/AndroidRuntime(513): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-13 19:52:22.309: E/AndroidRuntime(513): at java.lang.reflect.Method.invokeNative(Native Method)
05-13 19:52:22.309: E/AndroidRuntime(513): at java.lang.reflect.Method.invoke(Method.java:521)
05-13 19:52:22.309: E/AndroidRuntime(513): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-13 19:52:22.309: E/AndroidRuntime(513): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-13 19:52:22.309: E/AndroidRuntime(513): at dalvik.system.NativeStart.main(Native Method)
You seem to have a number of issues. Let's try and fix the layout inflate crash first.
List<Button> buttons;
...
buttons = new ArrayList<Button>();
buttons.add((Button)findViewById(R.id.buttonC4));
buttons.add((Button)findViewById(R.id.buttonD4));
...
for (Button button : buttons) {
button.setOnClickListener(this);
}
That will properly cast your layout's Button Views and set an OnClickListener for each.
Your Activity will need to implement View.OnClickListener to use setOnClickListener(this). Replace with the appropriate class if you have your click handling separated, that class will implement OnClickListener instead of your Activity in that case.
Related
2022-05-16 22:50:33.506 3520-3520/com.example.skinapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.skinapp, PID: 3520
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.skinapp/com.example.skinapp.HomepageActivity}: java.lang.ClassCastException: androidx.appcompat.widget.AppCompatTextView cannot be cast to android.widget.Button
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.ClassCastException: androidx.appcompat.widget.AppCompatTextView cannot be cast to android.widget.Button
at com.example.skinapp.HomepageActivity.onCreate(HomepageActivity.java:40)
at android.app.Activity.performCreate(Activity.java:8000)
at android.app.Activity.performCreate(Activity.java:7984)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
im new in building apps idk what's going on , i open this page yesterday and today i just changed the design of the layout and that what happened
I have a problem while i run app, no coding error but the app has stopped while i run. Maybe like this.
2022-05-23 21:49:21.065 29057-29057/org.d3if0063.garbageanywhere E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.d3if0063.garbageanywhere, PID: 29057
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.d3if0063.garbageanywhere/org.d3if0063.garbageanywhere.MainActivity}: java.lang.IllegalStateException: Activity org.d3if0063.garbageanywhere.MainActivity#c36f0b5 does not have a NavController set on 2131362096
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: java.lang.IllegalStateException: Activity org.d3if0063.garbageanywhere.MainActivity#c36f0b5 does not have a NavController set on 2131362096
at androidx.navigation.Navigation.findNavController(Navigation.kt:50)
at androidx.navigation.ActivityKt.findNavController(Activity.kt:31)
at org.d3if0063.garbageanywhere.MainActivity.onCreate(MainActivity.kt:26)
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)
Whenever I tried to open the Image Asset Studio on android/app/src/main/res and then right-click new>image asset it always says "IDE error occurred" and logs this message
java.lang.NullPointerException
at com.android.tools.idea.configurations.ConfigurationManager.create(ConfigurationManager.java:158)
at com.android.tools.idea.configurations.ConfigurationManager.getConfiguration(ConfigurationManager.java:135)
at com.android.tools.idea.editors.theme.ThemeEditorUtils.getConfigurationForModule(ThemeEditorUtils.java:86)
at com.android.tools.idea.npw.assetstudio.DrawableRenderer.<init>(DrawableRenderer.java:72)
at com.android.tools.idea.npw.assetstudio.wizard.GenerateImageAssetPanel.<init>(GenerateImageAssetPanel.java:210)
at com.android.tools.idea.npw.assetstudio.wizard.NewImageAssetStep.<init>(NewImageAssetStep.java:39)
at com.android.tools.idea.actions.NewImageAssetAction.createWizard(NewImageAssetAction.kt:33)
at com.android.tools.idea.actions.AndroidAssetStudioAction.actionPerformed(AndroidAssetStudioAction.java:108)
at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:265)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:282)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.lambda$actionPerformed$0(ActionMenuItem.java:292)
at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:265)
at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:107)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:282)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$fireActionPerformed$0(ActionMenuItem.java:111)
at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:82)
at com.intellij.openapi.application.TransactionGuardImpl.lambda$submitTransaction$1(TransactionGuardImpl.java:106)
at com.intellij.openapi.application.TransactionGuardImpl.submitTransaction(TransactionGuardImpl.java:115)
at com.intellij.openapi.application.TransactionGuard.submitTransaction(TransactionGuard.java:121)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:111)
at com.intellij.ui.plaf.beg.BegMenuItemUI.doClick(BegMenuItemUI.java:524)
at com.intellij.ui.plaf.beg.BegMenuItemUI.access$300(BegMenuItemUI.java:35)
at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:546)
at java.awt.Component.processMouseEvent(Component.java:6550)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3325)
at java.awt.Component.processEvent(Component.java:6315)
at java.awt.Container.processEvent(Container.java:2239)
at java.awt.Component.dispatchEventImpl(Component.java:4899)
at java.awt.Container.dispatchEventImpl(Container.java:2297)
at java.awt.Component.dispatchEvent(Component.java:4721)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4535)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
at java.awt.Container.dispatchEventImpl(Container.java:2283)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4721)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:766)
at java.awt.EventQueue.access$500(EventQueue.java:98)
at java.awt.EventQueue$3.run(EventQueue.java:715)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
at java.awt.EventQueue$4.run(EventQueue.java:739)
at java.awt.EventQueue$4.run(EventQueue.java:737)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:736)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:878)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:823)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:466)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:704)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:465)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
I've tried reinstalling Android Studio but the error persist, what should I o?
The Error is as below:
02-11 13:24:31.561 5262-5262/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.vicky.project, PID: 5262
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.vicky.project/com.example.vicky.project.MainActivity}:
java.lang.ClassCastException:
android.support.v7.widget.AppCompatTextView cannot be cast to
android.widget.EditText
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:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.ClassCastException:
android.support.v7.widget.AppCompatTextView cannot be cast to
android.widget.EditText
at com.example.vicky.project.MainActivity.onCreate(MainActivity.java:30)
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:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Look at this carefully
{android.support.v7.widget.AppCompatTextView cannot be cast to android.widget.EditText at com.example.vicky.project.MainActivity.onCreate(MainActivity.java:30) }
You may did this
{TextView tv = (EditText/*change this to TextView*/) findViewById (R.id.textView)}
If you are sure your code is correct then change ID of view in layout.xml then clean project from under the build options and rebuild it.
Class cast Exception because you're trying to cast TextView to EditText.
i have an EAR containing a web module exposing SOAP services developed with jaxws.
Everything works fine but when i have an error, i throw typically new BusinessFault(...).
Then i'm getting the below error.
The EAR is deployed on WLS 12.1 with glassfish.jaxws.rt_2.0.0.0_2-2-5.jar.
As the error message is completely useless.
I'll provide more details if necessary.
Thanks in advance
java.lang.ClassCastException: org.eclipse.persistence.jaxb.JAXBContext cannot be cast to org.eclipse.persistence.jaxb.JAXBContext
at com.sun.xml.ws.db.toplink.JAXBContextWrapper.(JAXBContextWrapper.java:78)
at com.sun.xml.ws.db.toplink.JAXBContextFactory.newContext(JAXBContextFactory.java:115)
at com.sun.xml.ws.spi.db.BindingContextFactory.create(BindingContextFactory.java:146)
at com.sun.xml.ws.message.jaxb.JAXBMessage.create(JAXBMessage.java:161)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createSOAP11Fault(SOAPFaultBuilder.java:423)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createSOAPFaultMessage(SOAPFaultBuilder.java:200)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createSOAPFaultMessage(SOAPFaultBuilder.java:188)
at com.sun.xml.ws.server.sei.TieHandler.createResponse(TieHandler.java:272)
at com.sun.xml.ws.server.sei.TieHandler.serializeResponse(TieHandler.java:338)
at com.sun.xml.ws.db.DatabindingImpl.serializeResponse(DatabindingImpl.java:200)
at com.sun.xml.ws.db.DatabindingImpl.serializeResponse(DatabindingImpl.java:264)
at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:106)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:892)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:841)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:804)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:706)
at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:430)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:640)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:265)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:163)
at weblogic.wsee.jaxws.WLSServletAdapter.handle(WLSServletAdapter.java:171)
at weblogic.wsee.jaxws.HttpServletAdapter$AuthorizedInvoke.run(HttpServletAdapter.java:708)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
at weblogic.wsee.util.ServerSecurityHelper.authenticatedInvoke(ServerSecurityHelper.java:103)
at weblogic.wsee.jaxws.HttpServletAdapter$3.run(HttpServletAdapter.java:311)
at weblogic.wsee.jaxws.HttpServletAdapter.post(HttpServletAdapter.java:336)
at weblogic.wsee.jaxws.JAXWSServlet.doRequest(JAXWSServlet.java:99)
at weblogic.servlet.http.AbstractAsyncServlet.service(AbstractAsyncServlet.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:242)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:216)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:132)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:352)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:235)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3284)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3254)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2163)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2089)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2074)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1512)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
03-Apr-2014 12:16:00 com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit handle
SEVERE: org.eclipse.persistence.jaxb.JAXBContext cannot be cast to org.eclipse.persistence.jaxb.JAXBContext
java.lang.ClassCastException: org.eclipse.persistence.jaxb.JAXBContext cannot be cast to org.eclipse.persistence.jaxb.JAXBContext
at com.sun.xml.ws.db.toplink.JAXBContextWrapper.(JAXBContextWrapper.java:78)
at com.sun.xml.ws.db.toplink.JAXBContextFactory.newContext(JAXBContextFactory.java:115)
at com.sun.xml.ws.spi.db.BindingContextFactory.create(BindingContextFactory.java:146)
at com.sun.xml.ws.message.jaxb.JAXBMessage.create(JAXBMessage.java:161)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createSOAP11Fault(SOAPFaultBuilder.java:423)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createSOAPFaultMessage(SOAPFaultBuilder.java:200)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createSOAPFaultMessage(SOAPFaultBuilder.java:188)
at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:436)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:640)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:265)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:163)
at weblogic.wsee.jaxws.WLSServletAdapter.handle(WLSServletAdapter.java:171)
at weblogic.wsee.jaxws.HttpServletAdapter$AuthorizedInvoke.run(HttpServletAdapter.java:708)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
at weblogic.wsee.util.ServerSecurityHelper.authenticatedInvoke(ServerSecurityHelper.java:103)
at weblogic.wsee.jaxws.HttpServletAdapter$3.run(HttpServletAdapter.java:311)
at weblogic.wsee.jaxws.HttpServletAdapter.post(HttpServletAdapter.java:336)
at weblogic.wsee.jaxws.JAXWSServlet.doRequest(JAXWSServlet.java:99)
at weblogic.servlet.http.AbstractAsyncServlet.service(AbstractAsyncServlet.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:242)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:216)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:132)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:352)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:235)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3284)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3254)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2163)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2089)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2074)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1512)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)