android apk stopped working even on AVD all is good - java

I have written some program, which takes streaming data from host. I used this example: https://code.google.com/p/streamscraper/ It works fine on my Android Virtual Device (2.3.3 API level 10) but when I created .apk and installed on Galaxy S4 and LG P710 and I get error unfortunately, has stopped. Whats is wrong? How do I debug this?

Based on your comment you get the exception android.os.NetworkOnMainThreadException: In new Android APIs, You should put any code that access network or internet inside different Thread.
Try this
new Thread(new Runnable() {
#Override
public void run() {
//Put your code here
}
}).start();
Edit 1:
You can use any background threading construct that comes with Android. Thread inside Service, Thread (as mentioned) or AsyncTask. Each has pros and crons. You should investigate this. Small hint, if you play this inside this activity and access the activity user interface some how, Use AsycnTask.

To debug it on your device, you have to use ADB with your smartphone device. To do so, enable USB Debugging on the device, connect it to the computer and make sure (if on Windows) that USB drivers are installed. Finally launch Eclipse or Android Studio and launch your project in debug mode. You should see a console output, where the full stacktrace of your device is visible.
If you do not have the possibility to debug with your computer <-> smartphone, try to use BugSense. Its free and including its library into your project it sends a full stack trace to you if errors do occur.

Setup your device do be debuggable: Link.
Start a debug from Eclipse, choosing your device.
check the output in the LogCat View in Eclipse. There you will see the Exception Stack Trace.

Why don't you directly run the apk file on your device instead running on the emulator.??

Check this in manifest file that you have set
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />

Related

Android Studio can't detect my android POS Terminal [duplicate]

After installing android studio, I installed ADB as well. However, for some reason ADB doesn't detect my device. To make a note I think I have done all the basic stuff I found online, i.e.:
Set device in Developer mode and enable USB debugging
Cable works well (Android file transfer automatically opens when I connect the device)
Installed Java JDK 8
I have done 'adb kill-server', restarted my device and Mac but still not working
I'm using Android Studio 2.2 and running Mac OS X Sierra on my Laptop, and the android phone is running Android 5.0.1 (on an LG Phone)
NB: I have tried the other solutions on stack overflow but thats not the problem.
ADB (is installed) and works from the command line, but when I run :
'adb usb' command, it says 'error: no devices/emulators found'
'adb devices' command, it prints 'List of devices attached' with an empty line beneath.
I believe this is a specific issue and the general solutions to install ADB or restart doesn't work here as I have tried all that.
I have removed and reinstalled android studio, still not working.
I have removed and reinstalled adb and adb & fastboot, still not working.
I have restarted my device, disabled and re-enabled developer mode, still not working.
Obviously, I have unplugged and plugged the cable back in several times, still not working (only Android File Transfer keeps coming up)
Just in case, I have rooted my device, could that be the problem or that doesn't matter?
You basically need to set the USB mode to PTP mode instead of Media Transfer Protocol (MTP) mode.
When I connected the device via USB the USB icon and Debugging Mode Icon appeared on the status bar on the device.
If you open control center by swiping down from the top, you should see a "Media device MTP" - Tap for more USB options. Tap it and switch the mode to "Send Images (PTP)" mode and it should ask you if you want to enable USB debugging. Enable it and the device should be recognized by ADB and Android Studio now.
I just clean installed my MBP and encountered the same issue. I tried the things suggested here but nothing worked.
What I had to do to fix it was "Revoke USB debugging authorizations" from the Developer options.
Once I did that, it offered up the usual "did you want to allow debugging on this device" option, and everything was back to normal.
Go to developer options and enable USB Debugging:
Settings > More > Developer Options > Debugging > USB Debugging.
Note:
You have to enable developer mode on your phone first
I was already in USB debugging enabled state and also had switched USB configuration to PTP. It was still in always charging mode no matter what I do. I had even reinstalled all Android related stuff, tried on multiple devices to find a fix. Finally what worked for me was getting a new cable.
I had posted a question here (now marked as duplicate) since these answers didn't suffice my situation.
If anyone is still having problems, consider the cable you are using. Not all USB cables are created equal! Some will charge but not allow data transfer. See this post.
In my case, the problem was that developer mode went away after doing an Android system update. Double-check developer mode and USB debugging settings.
I tried everything on my MBP but failed to fix the issue. Finally, with the least expectation, I reset my MBP's SMC, and everything is back to normal!!!
https://support.apple.com/en-us/HT201295
Make sure no other services are trying to access the device via adb. For me, I was using chrome inspect for checking the network requests. When I closed that window studio automatically detected the device.
Yeah, this one's tricky! Enabling Developer Options on your device is just a half of the procedure. Now you need to go to:
Settings > System > Advanced > Developer Options > Revoke USB Debugging Authorizations
Also check the cable - some are just for charging, no data can pass trough.
Please use the correct USB-C cable that came with the phone/device. Also, this can happen if incompatible converter is used, but this is less likely.
Add “platform-tools” to your PATH variable by invoking the following in the Terminal (make sure to change the file path to reflect where you placed the folder “platform-tools” on your system):
echo 'export PATH=$PATH:~/SDKs/android-sdk-macosx/platform-tools/' >> ~/.bash_profile
Execute the following command to reload your bash profile (this applies the change to the PATH variable):
source ~/.bash_profile
Note: The PATH variable is the search path for commands. It is a list of directories, each separated by a colon, in which the shell looks for commands. To see what values are currently in your PATH variable, use the following:
echo $PATH
adb devices
It should return something like this (if you have one Android device attached):
List of devices attached
212304114c28b9e device
I tried all of the above and the only thing that helped me was
to change the USB port and also change the data cable.
I was actually using a converter from USB type to C type at the connecting end to mac port
I think the converter corrupted the mac port. This was for Macbook Pro
update
I also tried doing a soft reset of the SMC and worked like a charm after that.
I face the same problem with my One+ device and after trying everything mentioned above , still was not able to conenct . But finally after enabling "OTG storage" option in System , it works.
it might be different for different custom devices . so ultimately you have to look for an option which gives a notification in device when you conenct and disconenct your device with system.
This happened to me on initial setup. I noticed that Gradle sync was taking a long time, so I waited for it to fully sync, then my device magically became available!
ADB was detecting the device but AS wasn't, I went to Preferences > Build, Execut

Could not open Selected VM debug port (8700). Make sure you do not have another instance of DDM

I have tried every tip to solve this problem but it simply do not work. The problem accured after update of android studio to 3.01 + gradle. I have older dependencies and gradle + android studio on my laptop and it works without any problem. I just want get access to Android device monitor to look up into my sqlite database files.
I tried simply kill, restart adb process, use different port then 8701, edit host file but without any progress into resolving this issue.
Everything except Device monitor works fine. I am able to launch application on emulator and actual phone. Maybe someone met this issue after updating program and have some sort of magic solution.
Found a problem earlier but forgot to post it here. It appears to be a issue with platform level 24 and above. You need to work on level 23 in order to use android device monitor.

Trouble running android wear app on emulator

I cannot seem to run this application which is supposedly ready to go to run on the Android Wear emulator.
Appreciate if someone can help me as to why this app does not actually get deployed to Watch emulator. I can see that the unaligned APK gets generated though.
I am following this guide:
http://toastdroid.com/2014/07/18/developing-watchfaces-for-android-wear/
Code is available at:
https://github.com/twotoasters/watchface-template
To install watchface you need to generate signed APK and push it to phone that is connected to that emulator, and install it there. After 1-2 minutes watchface should appear on the Wear device - if doesn't sync apps by companion app.
Also make sure that package for phone contains 'wear' part.
The key here is that you're using the emulator. If you run WatchfaceActivity.java from the Wear module on the emulator, you will see the watch appear on screen, but as an activity that can be dismissed.
If you then try to select it as the default watch face, you will be met with a black screen. I have only seen the emulator display the custom watch face (as a watch face, not a running activity) once and it seemed to have been a fluke.
The best way to develop custom watch faces is to run them as stand alone activities until it appears to be done, then go through the trouble of exporting a signed APK and run it on a real device connected to a real watch. At that point you can fix any small issues that remain.
please run you application on phone which has 4.3 or above platform.
install Android wear launcher apk on phone .
then connect wear emulator and phone using adb command.
adb -d forward tcp:5601 tcp:5601

Android Processing programming will not run application on device. How do I fix this?

I'm currently working with Processing, and I would like to code an android app. I have succeeded in being able to launch may application in the android emulator, but I am not able to get it to launch on my Galaxy 2.0 tab. I click run device, but every time I do I get a message at the end that says "waiting for device to become available". I'm thinking that I may need to point Processing to my android tablet somehow. Any ideas as to what I'm doing wrong. I'm on Windows 7.
It means your device is not being detected in the eclipse debugger tool. Did you check in Tab "Developer Options", make sure USB debugging is enabled. please refer other links you may get answer.
Click here
Device not detected in Eclipse when connected with USB cable

android and 3rd party jars

I have a jar file I use it to use TOC protocol (AOL servers).That jar file works fine totaly fine with my java application but when I use it in my android app,it never runs.I don't know the problem at all and I ma newbie to android development.plz help and guide me on how to debug android app or get console prints from android app IF YOU PLEASE.
Best regards
Android prints to its "console" using the Log utility. You can read about how it works at http://developer.android.com/reference/android/util/Log.html.
Basically you use a line like Log.e("AppName", "Message to print"), then go the the Debug view in eclipse and look at the window called LogCat. If you are running on an actual device instead of an emulator you can view this log through ADB. I also sometimes use a free app from the market called aLogCat to quickly check the log on the device its self.

Categories

Resources