I am dealing with a strange problem connecting to my MySQL database on Amazon RDS using JDBC. I have two different Android phones on the same network running the same code. One connects without any problems. The other is giving me the following exception:
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1014)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2547)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2283)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:822)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:404)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:317)
at java.sql.DriverManager.getConnection(DriverManager.java:175)
at java.sql.DriverManager.getConnection(DriverManager.java:209)
at edu.ucsb.cs.epsilon.ucsb360.DatabaseManager.Connect(DatabaseManager.java:32)
at edu.ucsb.cs.epsilon.ucsb360.Global.applicationResumed(Global.java:31)
at edu.ucsb.cs.epsilon.ucsb360.MainActivity.onResume(MainActivity.java:54)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1236)
at android.app.Activity.performResume(Activity.java:4625)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2834)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2889)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:5045)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1190)
at java.net.InetAddress.lookupHostByName(InetAddress.java:394)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:245)
at java.net.InetAddress.getAllByName(InetAddress.java:220)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:249)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:305)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2461)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2498)
The database only shows 1 active connection, so I know it is not because of too many open connections. I have tried rebooting the server, but it didn't help. I am using the MySQL JDBC Connector/J version 5.1.23. The phone that works is running Android version 2.3.5 and the one that doesn't work is running Android version 4.0.4. Does anyone have any ideas as to what might be wrong?
Thanks!
Caused by: android.os.NetworkOnMainThreadException
You can't do network IO on the main thread. Move it to an AsyncTask or thread.
Related
I was trying to run an app that requires MultiDex using Android Studio 3.0 on an API 16 device and when the app is finally trying to launch, it crashes.
The same occurs on other low APIs (eg.: 17, 18, 19)
But, when I tried to run the app using the Android Studio 3.1 (beta version), no crashes occur.
Is there any way this crash can be fixed?
FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at android.support.multidex.MultiDexApplication.<init>(MultiDexApplication.java:35)
at MY_APP_PATH.MY_CUSTOM_APPLICATION_CLASS.<init>(MY_CUSTOM_APP_CLASS.java:23)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1319)
at android.app.Instrumentation.newApplication(Instrumentation.java:997)
at android.app.Instrumentation.newApplication(Instrumentation.java:982)
at android.app.LoadedApk.makeApplication(LoadedApk.java:496)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4170)
at android.app.ActivityThread.access$1400(ActivityThread.java:134)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4867)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1306]: 1674 cannot locate '__isnanf'...
at java.lang.Runtime.loadLibrary(Runtime.java:370)
at java.lang.System.loadLibrary(System.java:535)
at com.android.tools.profiler.support.ProfilerService.<clinit>(ProfilerService.java:41)
at android.support.multidex.MultiDexApplication.<init>(MultiDexApplication.java:35)
at MY_APP_PATH.MY_CUSTOM_APPLICATION_CLASS.<init>(MY_CUSTOM_APPLICATION_CLASS.java:23)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1319)
at android.app.Instrumentation.newApplication(Instrumentation.java:997)
at android.app.Instrumentation.newApplication(Instrumentation.java:982)
at android.app.LoadedApk.makeApplication(LoadedApk.java:496)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4170)
at android.app.ActivityThread.access$1400(ActivityThread.java:134)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4867)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
at dalvik.system.NativeStart.main(Native Method)
Issue should be about enabling "advanced profiling" feature in AS 3.0, if you've done so just disable it:
Go to "Edit Configurations...",
Select your app configuration under "Android App",
Then go "Profiling" tab and
Uncheck "Enable advanced profiling"
Problem should be gone.
I have an application available on Google Play. Some people told me they were having an issue. When they open the application, it directly crashes and says "Unfortunately, [application name] has stopped".
When I started to program my project, I had the same problem with an Android 4.2.2. I just told me that it was a problem only for this version of Android, because when I used my bother's phone and my friends' phone everything worked. But finally not. People are having the same issue with and Android 5.0 or Android 5.0.2, and maybe some more.
I have few other red lines, but I will show you only the biggest part, which seems suspect. When I launch my app, I get this :
08-19 21:27:35.135 26504-26504/com.histoire_horreur E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.histoire_horreur.Listener.ScrollListener
at com.histoire_horreur.MainActivity.createView(MainActivity.java:59)
at com.histoire_horreur.MainActivity.onCreate(MainActivity.java:47)
at android.app.Activity.performCreate(Activity.java:5122)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1150)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2315)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2403)
at android.app.ActivityThread.access$600(ActivityThread.java:165)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1373)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5391)
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)
Android Studio doesn't underline any line in my code to tell me that this class is not found. ScrollListener is a class I created and it exists. I imported it. Anyway... I decided to delete line 59 to see what happens. When I did, I get a new error :
08-19 21:33:09.317 26953-26953/com.histoire_horreur E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: android.support.v7.view.menu.MenuBuilder
at android.support.v7.app.AppCompatDelegateImplV7.initializePanelMenu(AppCompatDelegateImplV7.java:1232)
at android.support.v7.app.AppCompatDelegateImplV7.preparePanel(AppCompatDelegateImplV7.java:1296)
at android.support.v7.app.AppCompatDelegateImplV7.doInvalidatePanelMenu(AppCompatDelegateImplV7.java:1591)
at android.support.v7.app.AppCompatDelegateImplV7.access$100(AppCompatDelegateImplV7.java:91)
at android.support.v7.app.AppCompatDelegateImplV7$1.run(AppCompatDelegateImplV7.java:130)
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:5391)
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)
This error is a mystery for me. I didn't even use MenuBuilder somewhere.
Can you help me because I now don't know where to focus. I searched a lot on StackOverflow and nothing solved my problem. There are a lot of similar errors but with a different log. Some people who had the same issue said it was just a problem of Android 4.2.2. But it is not.
About MenuBuilder problem, you need to change your build.gradle file as I did there :
Then it worked with my Wiko 4.2.2.
About ScrollListener problem, I will create a new subject.
The following error is obtained when running my app using the Kinvey client library:
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.google.api.client.http.apache.ApacheHttpTransport
at com.kinvey.android.Client$Builder.newCompatibleTransport(Client.java:555)
at com.kinvey.android.Client$Builder.<init>(Client.java:609)
at ch.ethz.nervousnet.trialapp04.MainActivity.onCreate(MainActivity.java:94)
at android.app.Activity.performCreate(Activity.java:5122)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2337)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2425)
at android.app.ActivityThread.access$600(ActivityThread.java:162)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5422)
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:837)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:604)
at dalvik.system.NativeStart.main(Native Method)
The Line in MainActivity class it points to is the following:
Global.setmKinveyClient(new Client.Builder(this.getApplicationContext()).build());
// Client if a library class, not the one I have created
It works on most phones, but on some phones does not work, what could be the cause?
Here is a screen shot of all the libs I have in the project :
Any help is appreciated, thank you.
LoveMeow,
What is the Android version on phones where it is not working? Is it the same version or happens randomly?
Since it is working for you on some phones, all the dependent libraries seem to be added properly. Are there any other warnings that are being thrown?
Thanks,
Pranav
Kinvey Support
My app crashes on LG devices when I am clicking the ad (from admob)!. What's the problem?
android.view.InflateException: Binary XML file line #21: Error inflating class <unknown> at
android.view.LayoutInflater.createView(LayoutInflater.java:613) at
com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) at
android.view.LayoutInflater.onCreateView(LayoutInflater.java:660) at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685) at
android.view.LayoutInflater.inflate(LayoutInflater.java:466) at
android.view.LayoutInflater.inflate(LayoutInflater.java:396) at
android.view.LayoutInflater.inflate(LayoutInflater.java:352) at
com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:3090) at
com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3150) at
com.android.internal.policy.impl.PhoneWindow.getDecorView(PhoneWindow.java:1737) at
android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2683) at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2124) at
android.app.ActivityThread.access$600(ActivityThread.java:138) at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1204) at
android.os.Handler.dispatchMessage(Handler.java:99) at
android.os.Looper.loop(Looper.java:137) at
android.app.ActivityThread.main(ActivityThread.java:4952) at
java.lang.reflect.Method.invokeNative(Native Method) at
java.lang.reflect.Method.invoke(Method.java:511) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794) at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:561) at
dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException at
java.lang.reflect.Constructor.constructNative(Native Method) at
java.lang.reflect.Constructor.newInstance(Constructor.java:417) at
android.view.LayoutInflater.createView(LayoutInflater.java:587) ... 21 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=7; index=-1 at
android.view.View.<init>(View.java:3638) at
android.view.ViewGroup.<init>(ViewGroup.java:427) at
android.widget.LinearLayout.<init>(LinearLayout.java:176) at
android.widget.LinearLayout.<init>(LinearLayout.java:172) ... 24 more
..................................................................................................
It's issue with LG Optimus L9 P760 device. It occurs only on version 4.1.2, I see it every now and then in my apps. If your application is available on any store and it's serious problem to you remember that you can always disable this device from supported devices.
I don't think there's anything to worry about. In my case the layout isn't complicated so the solution proposed by #Kishan with flattening view hierarchy will not work. It's just manufacturer fault.
This same error was there in my previous application. its because of the internal memory stack of the device (Some thing like RAM) is full. so for overcoming this error see the hierarchy of layout. and see the time of inflating in the hierarchy view if android eclipse IDE. and decrease the hierarchy of the layout. i have solved my issue with this. so you can check this if you can solve by the same solution.
Hope you can understand this solution.
Does anyone have this problem? I am not quite understand how to fix it. Not sure is that my code cause this exception or a bug on a webview.
java.lang.NullPointerException at
android.webkit.WebViewClassic$WebViewInputConnection.setNewText(WebViewClassic.java:587)
at
android.webkit.WebViewClassic$WebViewInputConnection.setComposingText(WebViewClassic.java:327)
at
android.webkit.WebViewClassic$WebViewInputConnection.commitText(WebViewClassic.java:343)
at
com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:279)
at
com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:77)
at android.os.Handler.dispatchMessage(Handler.java:107) 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)
Hi That's an BUG in the AdMob's new GooglePlayServices Library integrated to our latest updates.
I got this from an admob SDK team member from Amy Quispe(AdMob SDK Team)
java.lang.NullPointerException
at android.webkit.WebViewClassic$WebViewInputConnection.setNewText(WebViewClassic.java:587)
at android.webkit.WebViewClassic$WebViewInputConnection.setComposingText(WebViewClassic.java:327)
at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:333)
I got the same error yesterday, I think it is generated from lib of new google-play-services.jar.
If you observe the snippet, admob update is mandatory to mitigate the issue.