Android app failing to connect local host - android

Trying to connect to local Api on local server 5000 and Fail
Connecting by browser to http:/127.0.0.1:5000/user/1
works fine.
connecting to external api also work fine.
trying to connect to same address with android retrofit ,
keep getting
Skipped xxx frames! The application may be doing too much work on its main thread.
manifest file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android_movieapp">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<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/Theme.AndroidmovieApp">
<activity
android:name=".MovieListActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Problem solved by
url = 10.0.2.2
add android:usesCleartextTraffic="true"
to manifest application tag.

Android Emulator is an emulated separate device. Localhost addresses like 127.0.0.1 will therefore resolve to the localhost of the Android emulator NOT your computer that you are running it on.
You should instead use the address
10.0.2.2
https://developer.android.com/studio/run/emulator-networking

Related

Apk installs but won't start only on Android 4

My application works fine on Android 4, 5 and 6, when I plug devices to computer. But when I get .apk file from app/build/outputs/apk directory and install it directly, application crashes on Android 4 on start. Only on Android 4. Why? And how to fix it?
Here is my manifest file:
<manifest package="ru.pussy_penetrator.chgk"
xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".QuestionGridActivity"/>
<activity
android:name=".QuestionPagerActivity"/>
</application>
Disable the Instant Run and Build the APK. Instant Run uses the device cache to hot swap the changes you make in the project. Also it optimizes the code to run on the platform that your testing device has.
You can also generate Signed apk for distributing across all the supported Android versions

Android Studio - Compiling option

I developed an android app with android studio selectiong the lowest androis os version. i tested the app on my samsung s4 and it works correctly, now i tested the same apk file on another device (LG g2) and when i open the app it close immediately. my app is very simple and i don't think to have used high version library, so i wanted to know if it was possible to compile my application for that specific device (LG g2) so that my app works on that phone (android 4.4.2). if not possible does someone know why that error?
this is manifest code
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.tommaso.progetto">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

app neither installing not running on emulator

I have created My First Android Hello World on Android Studio . but when I run it on emulator , it is not running neither installing it on Emulator .. Every time is only shows session '' Error only in log .. i have done restart several times . no use ,
this is my emulator Setting
My Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.administrator.facebooklogin" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I have changed the device and skins as well , but no use i have not found proper solution for session '' error .
Since you have just started, Explore Genymotion, a faster and better alternative to Android virtual devices for Android Development.

Why can't connect my Android REST client to my REST service?

I have a java REST service which works fine, I'm trying to access to it through an Android client, but the connection is never made. This is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ipn.escom.clientRest.activity"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name="com.mx.ipn.escom.clientRest.activity.ClientRestActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
This is my client class that is trying to access my service TemaClient. This is my logcat output LogCat, I don't understand why the connection is never made.
My REST service is in a Windows XP computer and the IP address I'm using to access to it is the one that ipconfig shows me, if I put that same IP on a web browser I get a response, but the Android client never makes the connection. What am I doing wrong?
It seams you are accessing network behind a proxy, to use network behind a proxy start emulator by
emulator -avd avdname -http-proxy http://192.168.1.1:8080
I am assuming avdname is avdname and proxy gateway ip is 192.168.1.1
Fixed this problem, I had to make sure my Android device was connecting to the same network as my REST service.

Why usbManager.getAcccessoryList(); always returns null?

I am testing my app in Samsung Galaxy S2 with Android 2.3.4
I am following
http://developer.android.com/guide/topics/usb/accessory.html
instructions.
When ever I try to run it, usbManager.getAcccessoryList(); giving null.
Even I tried by connecting OTG cabel and pendrive to it.
My manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-feature android:name="android.hardware.usb.accessory" />
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="#drawable/icon"
android:label="#string/app_name" >
<uses-library android:name="com.android.future.usb.accessory" />
<activity
android:name=".SplashScreen"
android:clearTaskOnLaunch="true"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Advanced"
android:label="#string/app_name"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".Edit"
android:label="#string/app_name"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".Add"
android:label="#string/app_name"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="Main"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"
android:resource="#xml/accessory_filter" />
</activity>
</application>
</manifest>
I had the same problem but my tablet has ICS. If try what I did, might work. I've been searching a lot for this, and couldn't find it, but thanks to all the people who have spent a few moments answering our questions, and the wiki resources on the web, I figured it out.
There are some missing files in some android builds, like the AINOL NOVO 7 PALADIN. I think this would work in any ICS tablet with the same issue. I understand that the Galaxy Tab has the same issue but as I don't have one I can't confirm this. If you do, let me know if it works for you.
So lets push the files in and see how it goes.
Copy some missing files into system drive:
$ adb remount
$ adb push AINOL_FIX/system/etc/permissions/android.hardware.usb.host.xml /system/etc/permissions
$ adb push AINOL_FIX/system/etc/permissions/android.hardware.usb.accessory.xml /system/etc/permissions
NOTE: If an error appears displaying Out of Memory, it's right and you must delete some files from system drive. I recommend some live wallpapers from system/app.
I understand that for writing system drive you should have root access, I already had it when I did this so if it doesn't work, root it.
You can get the files from android source builds or from a tablet where USB-HOST API is actually working. I got them from linaro's ICS build for pandaboard.
Now, you should try finding those files but for Gingerbread and you'll also need to push the
future.usb.accesory.jar into system/framework, if it isn't there already.
$ adb push AINOL_FIX/system/framework/com.android.future.usb.accessory.jar /system/framework
A cite from http://developer.android.com/guide/topics/usb/accessory.html: "Set the minimum SDK of the application to API Level 10 if you are using the add-on library or 12 if you are using the android.hardware.usb package."
You are using the android.hardware.usb package. So, you have to put the version to 12.
An error is found :-)
And don't forget to really change SDK version to 12, not only declare it!
Use com.android.future.usb package instead, according to docs.

Categories

Resources