Skip to content

Unable to apply changes on device: xxxxxxxxxxxxxx Error is: Socket connection timed out.. #4029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
szgozcan opened this issue Oct 14, 2018 · 15 comments

Comments

@szgozcan
Copy link

Environment
No issues were detected.
✔ Your ANDROID_HOME environment variable is set and points to correct directory.
✔ Your adb from the Android SDK is correctly installed.
✔ The Android SDK is installed.
✔ A compatible Android SDK for compilation is found.
✔ Javac is installed and is configured properly.
✔ The Java Development Kit (JDK) is installed and is configured properly.
✔ Xcode is installed and is configured properly.
✔ xcodeproj is installed and is configured properly.
✔ CocoaPods are installed.
✔ CocoaPods update is not required.
✔ CocoaPods are configured properly.
✔ Your current CocoaPods version is newer than 1.0.0.
✔ Python installed and configured correctly.
✔ The Python 'six' package is found.
✔ Xcode version 9.4.1 satisfies minimum required version 9.
✔ Getting NativeScript components versions information...
✔ Component nativescript has 5.0.0-2018-10-12-12481 version and is up to date.
✔ Component tns-core-modules has 4.2.1 version and is up to date.
✔ Component tns-android has 4.2.0 version and is up to date.
✔ Component tns-ios has 4.2.0 version and is up to date.

Describe the bug
When I run my apps I started to get

` Project successfully built.

Installing on device 192.168.57.101:5555...

Successfully installed on device with identifier '192.168.57.101:5555'.

 Unable to apply changes on device: 192.168.57.101:5555. Error is: Socket connection timed out..`

I deleted the platforms, hooks, package-lock.json and node modules folders and when I re-run the app it is not even opening. Then I upgraded to next CLI and faced the same issue. The problem started when Google Mobile SDK version 17.0.0 was released last week.

In order to test, I created a blank project and ran with an emulator. It worked fine, then I only ran tns plugin add nativescript-admob command and when I debug without adding anything to code, the app failed with Unable to apply changes on device: 192.168.57.101:5555. Error is: Socket connection timed out..`output. The app doesn't open and you can't delete it. You have to uninstall the app from settings.
So I believe that there must be some kind of problem with the latest release of Google Mobile SDK version 17.0.0 and admob plugin. Any help is appreciated.

To Reproduce

Expected behavior

Sample project

Additional context

@skopekreep
Copy link

+1

Having the exact same issue. Performed the same test by creating a blank project with, and without, the nativescript-admob plugin installed. As in the OP, the plugin does not need to even be called in code. I also agree on the timing of the start of the problem with the OP.

@Fatme
Copy link
Contributor

Fatme commented Oct 16, 2018

Hey @szgozcan, @skopekreep,

Thank you for investigating the problem.

You're absolute right that the problem is caused by Google Mobile Ads SDK version 17.0.0. Actually version 17.0.0 of Google Mobile Ads SDK requires <meta-data> tag in AndroidManifest.xml. You can find more info here https://developers.google.com/admob/android/quick-start#update_your_androidmanifestxml.

In order to successfully run your app on device using local builds, you need to change the following code inside ./node_modules/nativescript-admob/platforms/android/include.gradle file.

def googlePlayServicesVersion = project.hasProperty('googlePlayServicesVersion') ? project.googlePlayServicesVersion : '16.0.0'

This way {N} CLI will fallback to version 16.0.0 of Google Mobile Ads SDK.

In case you're using cloud builds, you need to refer nativescript-admob plugin from local folder inside your project. (The plugin should contain the changes described above).

We're working on a fix that will be applied directly from plugin on install step. Meanwhile, you can use the described approach above.

Let me know if this works for you.

@szgozcan
Copy link
Author

Hi,
Thank you very much for your contribution Fatme, the socket connection timed out issue seems resolved, but there happens to be another problem which looks related to that issue.
The apps come back to life again and nativescript admob plugin seems working fine. Yesterday I made the changes you mentioned but today when I add the admob plugin, it made changes you referred,

The problem I encounter is, the app looks running fine and I see the sample admob ads but when I use back buttons successively and navigate among the pages I get that error.

 ` An uncaught Exception occurred on "main" thread.
  com.tns.NativeScriptException: 
 Calling js method onCreateView failed
  Error: java.lang.IllegalStateException: The ad unit ID can only be set once on AdView.
 com.google.android.gms.internal.ads.zzly.setAdUnitId(Unknown Source:8)
com.google.android.gms.ads.BaseAdView.setAdUnitId(Unknown Source:2)
com.google.android.gms.ads.AdView.setAdUnitId(Unknown Source:0)
com.tns.Runtime.callJSMethodNative(Native Method)
com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1116)
com.tns.Runtime.callJSMethodImpl(Runtime.java:996)
com.tns.Runtime.callJSMethod(Runtime.java:983)
com.tns.Runtime.callJSMethod(Runtime.java:967)
com.tns.Runtime.callJSMethod(Runtime.java:959)
com.tns.FragmentClass.onCreateView(FragmentClass.java:45)
android.app.Fragment.performCreateView(Fragment.java:2611)
android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1276)
android.app.FragmentManagerImpl.addAddedFragments(FragmentManager.java:2415)
android.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2194)
android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2148)
android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2049)
android.app.FragmentManagerImpl$1.run(FragmentManager.java:718)
android.os.Handler.handleCallback(Handler.java:789)
android.os.Handler.dispatchMessage(Handler.java:98)
android.os.Looper.loop(Looper.java:164)
android.app.ActivityThread.main(ActivityThread.java:6541)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
 File: "file:///data/data/org.nativescript.IngilizceBesinciSinif/files/app/bannerview.js, line: 11, column: 15

   StackTrace: 
Frame: function:'loadBanner',   file:'file:///data/data/org.nativescript.IngilizceBesinciSinif/files/app/bannerview.js', line: 11, column: 16
Frame: function:'onLoaded', file:'file:///data/data/org.nativescript.IngilizceBesinciSinif/files/app/views/unit2-page/unit2-page.js', line: 156, column: 18
Frame: function:'Observable.notify', file:'file:///data/data/org.nativescript.IngilizceBesinciSinif/files/app/tns_modules/tns-core-modules/data/observable/observable.js', line: 110, column: 23
Frame: function:'Observable._emit', file:'file:///data/data/org.nativescript.IngilizceBesinciSinif/files/app/tns_modules/tns-core-modules/data/observable/observable.js', line: 127, column: 18
Frame: function:'ViewBase.onLoaded', file:'file:///data/data/org.nativescript.IngilizceBesinciSinif/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 236, column: 14
Frame: function:'View.onLoaded', file:'file:///data/data/org.nativescript.IngilizceBesinciSinif/files/app/tns_modules/tns-core-modules/ui/core/view/view.js', line: 213, column: 35
Frame: function:'Page.onLoaded', file:'file:///data/data/org.nativescript.IngilizceBesinciSinif/files/app/tns_modules/tns-core-modules/ui/page/page.js', line: 43, column: 35
Frame: function:'', file:'file:///data/data/org.nativescript.IngilizceBesinciSinif/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 311, column: 90
Frame: function:'ViewBase.callFunctionWithSuper', file:'file:///data/data/org.nativescript.IngilizceBesinciSinif/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 304, column: 9
Frame: function:'ViewBase.callLoaded', file:'file:///data/data/org.nativescript.IngilizceBesinciSinif/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 311, column: 14
Frame: function:'FragmentCallbacksImplementation.onCreateView', file:'file:///data/data/org.nativescript.IngilizceBesinciSinif/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 605, column: 18
Frame: function:'FragmentClass.onCreateView', file:'file:///data/data/org.nativescript.IngilizceBesinciSinif/files/app/tns_modules/tns-core-modules/ui/frame/fragment.js', line: 27, column: 38


at com.tns.Runtime.callJSMethodNative(Native Method)
at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1116)
at com.tns.Runtime.callJSMethodImpl(Runtime.java:996)
at com.tns.Runtime.callJSMethod(Runtime.java:983)
at com.tns.Runtime.callJSMethod(Runtime.java:967)
at com.tns.Runtime.callJSMethod(Runtime.java:959)
at com.tns.FragmentClass.onCreateView(FragmentClass.java:45)
at android.app.Fragment.performCreateView(Fragment.java:2611)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1276)
at android.app.FragmentManagerImpl.addAddedFragments(FragmentManager.java:2415)
at android.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2194)
at android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2148)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2049)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:718)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
     Caused by: java.lang.IllegalStateException: The ad unit ID can only be set once on AdView.
at com.google.android.gms.internal.ads.zzly.setAdUnitId(Unknown Source:8)
at com.google.android.gms.ads.BaseAdView.setAdUnitId(Unknown Source:2)
at com.google.android.gms.ads.AdView.setAdUnitId(Unknown Source:0)`

Then I went through another test, I pulled out all banner stuff out of my app and tested the release app with robo test in firebase. No issue detected. Then I tested the app with real device and no issue detected either.

Since I have been using as a ads code for nativescript describen in https://github.com/nikolay-diyanov/sample-googleads-bannerview-mod/blob/master/app/bannerview.android.js
I thought the problem would be with my code.

But then I tested the code sample of Eddy https://github.com/EddyVerbruggen/nativescript-admob and I encountered an error as well. I built a release apk of Eddy's sample code and ran it with firebase. I got the following error.
java.lang.NullPointerException: Attempt to read from field 'android.app. Activity android.app.ActivityThread$ActivityClientRecord.activity' on a null object reference FATAL EXCEPTION: main Process: org.nativescript.english5, PID: 9237 java.lang.NullPointerException: Attempt to read from field 'android.app. Activity android.app.ActivityThread$ActivityClientRecord.activity' on a null object reference at android.app.ActivityThread.handleStopActivity(ActivityThread.java:4137) at android.app.ActivityThread.-wrap24(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1627) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6541) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

So I tested my with meta data tag and without, also with sample ADMOB AP ID and real ADMOB ID, in all cases after navigating among pages, especially using back button after and after I get the
Error: java.lang.IllegalStateException: The ad unit ID can only be set once on AdView. error.

Finally, I do not get the socket timeout issue anymore and in first look app looks running but when I tested the app in emulator, real device and firebase test lab I get the error described above,

Any help is greatly appreciated,

I post below my banner js file, sample xml, sample js and android manifest xml.
AndroidManifest.pdf
bannerview.pdf
sample js file.pdf
sample xml file.pdf

@skopekreep
Copy link

@szgozcan , the latest patch for nativescript-admob (2.0.1) implements @Fatme's suggestion above, which is a fix that restricts the plugin's use to Google Mobile Ads SDK version 16 only. Version 16 does NOT require adding the <meta-data> tag in AndroidManifest.xml, and if you do (like you have) it will cause issues. Your solution is to remove the <meta-data> tag for now, until a new version of nativescript-admob is released that is compatible with Google Mobile Ads SDK version 17. When that happens, there will be instructions given in the README for all users to manually put the <meta-data> tag in AndroidManifest.xml, and the plugin will at that time start using SDK 17.

@szgozcan
Copy link
Author

Hi,
I tested your suggestion with two apps, one already running and one newly created. I used test banner AdUnit Id. I did not put any data in AndroidManifest.xml. Apps run and show the test banner ads, no more socket timeout issue but when using back button successively I get that error below. I have apps in play store with admob and I use the same coding in these apps as well. So I still believe that the issue might be related with 17.0.0 upgrade change. Thx many for your response. help needed,

`An uncaught Exception occurred on "main" thread.
 com.tns.NativeScriptException: 
 Calling js method onCreateView failed
 Error: java.lang.IllegalStateException: The ad unit ID can only be set once on AdView.
com.google.android.gms.internal.ads.zzly.setAdUnitId(Unknown Source:8)
com.google.android.gms.ads.BaseAdView.setAdUnitId(Unknown Source:2)
com.google.android.gms.ads.AdView.setAdUnitId(Unknown Source:0)
com.tns.Runtime.callJSMethodNative(Native Method)
com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1116)
com.tns.Runtime.callJSMethodImpl(Runtime.java:996)
com.tns.Runtime.callJSMethod(Runtime.java:983)
com.tns.Runtime.callJSMethod(Runtime.java:967)
com.tns.Runtime.callJSMethod(Runtime.java:959)
com.tns.FragmentClass.onCreateView(FragmentClass.java:45)
android.app.Fragment.performCreateView(Fragment.java:2611)
android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1276)
android.app.FragmentManagerImpl.addAddedFragments(FragmentManager.java:2415)
android.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2194)
   
    android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2148)
android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2049)
android.app.FragmentManagerImpl$1.run(FragmentManager.java:718)
android.os.Handler.handleCallback(Handler.java:789)
android.os.Handler.dispatchMessage(Handler.java:98)
android.os.Looper.loop(Looper.java:164)
android.app.ActivityThread.main(ActivityThread.java:6541)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
File: "file:///data/data/org.nativescript.mine/files/app/bannerview.js, line: 10, column: 15

 StackTrace: 
Frame: function:'loadBanner', file:'file:///data/data/org.nativescript.mine/files/app/bannerview.js', line: 10, column: 16
Frame: function:'onLoaded', file:'file:///data/data/org.nativescript.mine/files/app/views/unit1- page/unit1-page.js', line: 174, column: 18
Frame: function:'Observable.notify', file:'file:///data/data/org.nativescript.mine/files/app/tns_modules/tns-core-modules/data/observable/observable.js', line: 110, column: 23
Frame: function:'Observable._emit', file:'file:///data/data/org.nativescript.mine/files/app/tns_modules/tns-core-modules/data/observable/observable.js', line: 127, column: 18
Frame: function:'ViewBase.onLoaded', file:'file:///data/data/org.nativescript.mine/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 236, column: 14
Frame: function:'View.onLoaded', file:'file:///data/data/org.nativescript.mine/files/app/tns_modules/tns-core-modules/ui/core/view/view.js', line: 213, column: 35
Frame: function:'Page.onLoaded', file:'file:///data/data/org.nativescript.mine/files/app/tns_modules/tns-core-modules/ui/page/page.js', line: 43, column: 35
Frame: function:'', file:'file:///data/data/org.nativescript.mine/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 311, column: 90
Frame: function:'ViewBase.callFunctionWithSuper', file:'file:///data/data/org.nativescript.mine/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 304, column: 9
Frame: function:'ViewBase.callLoaded', file:'file:///data/data/org.nativescript.mine/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js', line: 311, column: 14
Frame: function:'FragmentCallbacksImplementation.onCreateView', file:'file:///data/data/org.nativescript.mine/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 605, column: 18
Frame: function:'FragmentClass.onCreateView', file:'file:///data/data/org.nativescript.mine/files/app/tns_modules/tns-core-modules/ui/frame/fragment.js', line: 27, column: 38


at com.tns.Runtime.callJSMethodNative(Native Method)
at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1116)
at com.tns.Runtime.callJSMethodImpl(Runtime.java:996)
at com.tns.Runtime.callJSMethod(Runtime.java:983)
at com.tns.Runtime.callJSMethod(Runtime.java:967)
at com.tns.Runtime.callJSMethod(Runtime.java:959)
at com.tns.FragmentClass.onCreateView(FragmentClass.java:45)
at android.app.Fragment.performCreateView(Fragment.java:2611)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1276)
at android.app.FragmentManagerImpl.addAddedFragments(FragmentManager.java:2415)
at android.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2194)
at android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2148)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2049)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:718)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
    Caused by: java.lang.IllegalStateException: The ad unit ID can only be set once on AdView.
at com.google.android.gms.internal.ads.zzly.setAdUnitId(Unknown Source:8)
at com.google.android.gms.ads.BaseAdView.setAdUnitId(Unknown Source:2)
at com.google.android.gms.ads.AdView.setAdUnitId(Unknown Source:0)`

@szgozcan
Copy link
Author

Last problem I have been struggling through is gone as well. Thanx everyone for the help.

@alereisan
Copy link

I also have this "Socket connection timed out.." Error since a few days.
After upgrading my nativescript-angular app, to the latest versions, it worked for some hours. But now again, I cannot start my app: Error is: Socket connection timed out..

@szgozcan
Copy link
Author

szgozcan commented Nov 7, 2018

If you have the old version of nativescrip-admob plugin, that would be the problem. Removing the old one and adding the new plugin solves the problem (with the correct change in androidmanifest.xml) Hopefully it works.

@alereisan
Copy link

alereisan commented Nov 7, 2018

My app does not even use nativescript-admob :(

@alereisan
Copy link

@NickIliev why is this issue closed?

@Fatme
Copy link
Contributor

Fatme commented Nov 13, 2018

@alereisan,

If your app does not use nativescript-admob plugin, it is not related to this thread. So I'll reopen your original issue - NativeScript/NativeScript#6534.

Socket connection timeout error can happen when the app is not started on device for some reason. One possible reason could be if the application throws an exception on startup. To check if this is the case you can start logcat process and see if any error will be printed from your application.

@shineklbm
Copy link

My app does not even use nativescript-admob :(

Then probably its due to some other issue, in my case I changed the app name in package.json file but forgot to change the same in app/App_Resources/Android/app.gradle file. That's why I was getting this error. Please make sure you are not having the same issue.

@rakoc001
Copy link

My app does not even use nativescript-admob :(

Then probably its due to some other issue, in my case I changed the app name in package.json file but forgot to change the same in app/App_Resources/Android/app.gradle file. That's why I was getting this error. Please make sure you are not having the same issue.

I don't have the app name in my app.gradle file.

@wpatter6
Copy link

@Fatme I am using [email protected] with tns version 6.1.2. I added the meta-data tag into the AndroidManifest.xml and I'm receiving this error when I try to debug. What is the solution that closed this issue?

@wpatter6
Copy link

Nevermind, I figured it out. In the manifest you must replace / with ~ in the value and it will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants