which adb.exe to chose? - android

Im having trouble getting adb to work, i keep getting ''adb' is not recognized as an internal or external command, operable program or batch file', I found out i need to set my system path so i tried to locate adb.exe
I found it in three folfder:
C:\Users\Sven\AppData\Local\Android\sdk\platform-tools
C:\Users\Sven\AppData\Local\Android\sdk1\platform-tools
C:\Users\Sven\AppData\Local\Android\sdk2\platform-tools
How do i know which one to add to PATH? the date created looks almost the same.

Doesn't make much difference..
You can use whichever you like..I would suggest- C:\Users\Sven\AppData\Local\Android\sdk2\platform-tools since this looks to to be latest if you go with "sdk2"

Related

System can't find specifed path ndkbuild in android

I want to build an ocr app in android.For that i am using tessaract library.I am following this turorial ocr tutoial it says follow below steps
Download the NDK & extract to C:\ drive-Done
Set NDK Path & Android SDK path to PATH variable in Enviorment Variable.-Done
Download tessaract library and extract it to C:-Done
open command line & go inside tessract folder ibn downloaded library.-
Write ndk-build-Not Done
When i write ndk-build it says the system can't find the specified path.
Please tell me how to resolve this issue.I have already spent lot of hard time on this.
Thanks in advance.
If you re-read the link you posted, you may notice this line from the author:
Attention: if you fail at any of the above steps, you are not ready for this shit yet. Better grab an introduction to android development course, read a book, then come back to this tutorial. You’ll just waste time and nerves and you’ll bitch about it in the comments that this crash, this doesn’t work. (PS. no, I will not send you the source code on your email, stop spamming k thx.)
You should seriously consider his advice - working with the Android NDK only gets more difficult from here.
You're probably getting that error message because cmd couldn't find the ndk-build program, which is located inside the root of android-ndk-r10e. Possible causes:
You made an error when editing your PATH variable - make sure each file path is separated by a semicolon and that you provided the full path to your NDK install.
Your PATH is too long - the max length is 260 characters. See this page for more info. tl;dr: prefix \?\ to your PATH to get around this length limit.
You had cmd open when you set the variables - try restarting the cmd
program or even restarting your machine.

Hunting a memory leak with Eclipse and Mat, stuck converting the hprof file

This seems to be a question asked many times. I'm using Eclipse to write an Android app, in OS X. So far, no problem, except the app crashes sometimes, and I want to see whats going on so I can fix the problem. (Its probably related to bitmaps or variables not recycling correctly. But I don't know where else to start to look into it.)
I used the DDMS tool (in eclipse) to create a dump file. Then I downloaded the MemoryAnalyzer application to open it. Here is where I have been stuck for an hour: I have to convert the file first because Eclipse writes the hprof file in a different format. How do I convert it?
The answers to this question, error openning HPROF file, directly address my question. The top answer is the same as the reference for the hprof-conv tool.
The hprof file you get from Android has android specific format. You should convert hprof >file take from Android OS into standard hprof format. For this you can use hprof-conv tool >that is located at AndrodiSDK/tools/hprof-conv.
For example:
hprof-conv android.hprof mat.hprof
And then open mat.hprof in Memory Analyzer.
I have a couple problems with this.
when I open the hprof-conv tool, it shows a handful of lines about it then says "[Process completed]". And there is no place to enter any text. The only relevant info on the screen is this:
Usage: hprof-conf infile outfile
I'm in Terminal, so I open "new command..." or tried using the shell thats also open. Then when I run "hprof-conv dump1.hprof dump1a.hprof" I get the error "command not found". So I think I'm off track. I also tried "hprof-conf", instead of "hprof-conv", the way it suggests in point 1. Same error. Also tried various paths to the file, no change.
if I was on the right track, how do I correctly point this command to the file location? I have it on my desktop, and its named dump1.hprof. I'm not very experienced with Terminal.
Thanks in advance for an answer, or perhaps another suggestion on how to hunt down a memory leak.
If you are on mac add a ./ before the command :
./hprof-conv infile.hprof outfile.hprof
Hello and sorry for a late response. I just went through exactly this problem and wrote some instructions here: http://spragucm.wordpress.com/2013/11/21/debugging-android-project-ddms-heap-dump-in-eclipse/
Method 1: Use the Standalone MAT
go into c:...\sdk-tools\tools and copy hprof-conv.exe
go to whatever folder you saved your dump1.hprof file and paste the .exe file
open a terminal and change directory to the folder with your dump and .exe file (e.g. if folder is c:\Users\YourName\DumpFolder then type cd c:\Users\YourName\DumpFolder)
When you're in the folder type the following in the command prompt and hit enter: hprof-conf infile.hprof outfile.hprof
NOTE: If you get an error about directory not found, you're not in the correct directory in the command prompt
The outfile.hprof file should be in the same folder as the other files.
Method 2: Using MAT in Eclipse
Install the plug-in for MAT in Eclipse
Select to get heap dump as before
Go to Window->Open Perspective->other->Memory Analysis
Look through your tabs for a window with a blue disk icon in top left and expand the tab (this will have some crazy name on it with a very long string of numbers)
Done...you are looking at the heap dump in Eclipse

LogCat error: Error opening trace file: No such file or directory (2) [duplicate]

I am getting the above error:
error opening trace file: No such file or directory (2)
when I run my android application on the emulator. Can someone tell me what could be the possible reason for this?
I am using android-sdk-20 and below lines are added to AndroidManifest.xml
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="15" />
I have also added the line:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
since I thought that there may be some issue with writing to the sd card.
It happens because you have not installed the minSdkVersion or targetSdkVersion in you’re computer. I've tested it right now.
For example, if you have those lines in your Manifest.xml:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
And you have installed only the API17 in your computer, it will report you an error. If you want to test it, try installing the other API version (in this case, API 8).
Even so, it's not an important error. It doesn't mean that your app is wrong.
Sorry about my expression. English is not my language.
Bye!
I think this is the problem
A little background
Traceview is a graphical viewer for execution logs that you create by using the Debug class to log tracing information in your code. Traceview can help you debug your application and profile its performance. Enabling it creates a .trace file in the sdcard root folder which can then be extracted by ADB and processed by traceview bat file for processing. It also can get added by the DDMS.
It is a system used internally by the logger. In general unless you are using traceview to extract the trace file this error shouldnt bother you. You should look at error/logs directly related to your application
How do I enable it:
There are two ways to generate trace logs:
Include the Debug class in your code and call its methods such as startMethodTracing() and stopMethodTracing(), to start and stop
logging of trace information to disk. This option is very precise
because you can specify exactly where to start and stop logging trace
data in your code.
Use the method profiling feature of DDMS to generate trace logs. This option is less precise because you do not modify code, but rather
specify when to start and stop logging with DDMS. Although you have
less control on exactly where logging starts and stops, this option is
useful if you don't have access to the application's code, or if you
do not need precise log timing.
But the following restrictions exist for the above
If you are using the Debug class, your application must have
permission to write to external storage (WRITE_EXTERNAL_STORAGE).
If you are using DDMS: Android 2.1 and earlier devices must have an SD
card present and your application must have permission to write to the
SD card. Android 2.2 and later devices do not need an SD card. The
trace log files are streamed directly to your development machine.
So in essence the traceFile access requires two things
1.) Permission to write a trace log file i.e. WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE for good measure
2.) An emulator with an SDCard attached with sufficient space. The doc doesnt say if this is only for DDMS but also for debug, so I am assuming this is also true for debugging via the application.
What do I do with this error:
Now the error is essentially a fall out of either not having the sdcard path to create a tracefile or not having permission to access it. This is an old thread, but the dev behind the bounty, check if are meeting the two prerequisites. You can then go search for the .trace file in the sdcard folder in your emulator. If it exists it shouldn't be giving you this problem, if it doesnt try creating it by adding the startMethodTracing to your app.
I'm not sure why it automatically looks for this file when the logger kicks in. I think when an error/log event occurs , the logger internally tries to write to trace file and does not find it, in which case it throws the error.Having scoured through the docs, I don't find too many references to why this is automatically on.
But in general this doesn't affect you directly, you should check direct application logs/errors.
Also as an aside Android 2.2 and later devices do not need an SD card for DDMS trace logging. The trace log files are streamed directly to your development machine.
Additional information on Traceview:
Copying Trace Files to a Host Machine
After your application has run
and the system has created your trace files .trace on
a device or emulator, you must copy those files to your development
computer. You can use adb pull to copy the files. Here's an example
that shows how to copy an example file, calc.trace, from the default
location on the emulator to the /tmp directory on the emulator host
machine:
adb pull /sdcard/calc.trace /tmp Viewing Trace Files in Traceview To
run Traceview and view the trace files, enter traceview
. For example, to run Traceview on the example files
copied in the previous section, use:
traceview /tmp/calc Note: If you are trying to view the trace logs of
an application that is built with ProGuard enabled (release mode
build), some method and member names might be obfuscated. You can use
the Proguard mapping.txt file to figure out the original unobfuscated
names. For more information on this file, see the Proguard
documentation.
I think any other answer regarding positioning of oncreate statements or removing uses-sdk are not related, but this is Android and I could be wrong. Would be useful to redirect this question to an android engineer or post it as a bug
More in the docs
Try removing the uses-sdk part form AndroidManifest.xml file. it worked for me!
Don't use the Android Virtual Device with too low configuration. Let it be medium.
Write all your code below this 2 lines:-
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
It worked for me without re-installing again.
I didn't want to reinstall everything because I have so many SDK versions installed and my development environment is set up just right. Getting it set up again takes way too long.
What worked for me was deleting, then re-creating the Android Virtual Device, being certain to put in a value for SD Card Size (I used 200 MiB).
Additional information:
while the above does fix the problem temporarily, it is recurring. I just tried my application within Android Studio and saw this in the output log which I did not notice before in Eclipse:
"/Applications/Android Studio.app/sdk/tools/emulator" -avd AVD_for_Nexus_S_by_Google -netspeed full -netdelay none
WARNING: Data partition already in use. Changes will not persist!
WARNING: SD Card image already in use: /Users/[user]/.android/avd/AVD_for_Nexus_S_by_Google.avd/sdcard.img
ko:Snapshot storage already in use: /Users/[user]/.android/avd/AVD_for_Nexus_S_by_Google.avd/snapshots.img
I suspect that changes to the log are not saving to the SD Card, so when LogCat tries to access the logs, they aren't there, causing the error message. The act of deleting the AVD and re-creating it removes the files, and the next launch is a fresh launch, allowing LogCat to access the virtual SD Card.
You will not have access to your real sd card in emulator. You will have to follow the steps in this tutorial to direct your emulator to a directory on your development environment acting as your SD card.
Actually, the problem is that either /sys/kernel/debug is not mounted, or that the running kernel has no ftrace tracers compiled in so that /sys/kernel/debug/tracing is unavailable. This is the code throwing the error (platform_frameworks_native/libs/utils/Trace.cpp):
void Tracer::init() {
Mutex::Autolock lock(sMutex);
if (!sIsReady) {
add_sysprop_change_callback(changeCallback, 0);
const char* const traceFileName =
"/sys/kernel/debug/tracing/trace_marker";
sTraceFD = open(traceFileName, O_WRONLY);
if (sTraceFD == -1) {
ALOGE("error opening trace file: %s (%d)", strerror(errno), errno);
sEnabledTags = 0; // no tracing can occur
} else {
loadSystemProperty();
}
android_atomic_release_store(1, &sIsReady);
}
}
The log message could definitely be a bit more informative.

Error opening trace file: No such file or directory (2) in logcat [duplicate]

I am getting the above error:
error opening trace file: No such file or directory (2)
when I run my android application on the emulator. Can someone tell me what could be the possible reason for this?
I am using android-sdk-20 and below lines are added to AndroidManifest.xml
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="15" />
I have also added the line:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
since I thought that there may be some issue with writing to the sd card.
It happens because you have not installed the minSdkVersion or targetSdkVersion in you’re computer. I've tested it right now.
For example, if you have those lines in your Manifest.xml:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
And you have installed only the API17 in your computer, it will report you an error. If you want to test it, try installing the other API version (in this case, API 8).
Even so, it's not an important error. It doesn't mean that your app is wrong.
Sorry about my expression. English is not my language.
Bye!
I think this is the problem
A little background
Traceview is a graphical viewer for execution logs that you create by using the Debug class to log tracing information in your code. Traceview can help you debug your application and profile its performance. Enabling it creates a .trace file in the sdcard root folder which can then be extracted by ADB and processed by traceview bat file for processing. It also can get added by the DDMS.
It is a system used internally by the logger. In general unless you are using traceview to extract the trace file this error shouldnt bother you. You should look at error/logs directly related to your application
How do I enable it:
There are two ways to generate trace logs:
Include the Debug class in your code and call its methods such as startMethodTracing() and stopMethodTracing(), to start and stop
logging of trace information to disk. This option is very precise
because you can specify exactly where to start and stop logging trace
data in your code.
Use the method profiling feature of DDMS to generate trace logs. This option is less precise because you do not modify code, but rather
specify when to start and stop logging with DDMS. Although you have
less control on exactly where logging starts and stops, this option is
useful if you don't have access to the application's code, or if you
do not need precise log timing.
But the following restrictions exist for the above
If you are using the Debug class, your application must have
permission to write to external storage (WRITE_EXTERNAL_STORAGE).
If you are using DDMS: Android 2.1 and earlier devices must have an SD
card present and your application must have permission to write to the
SD card. Android 2.2 and later devices do not need an SD card. The
trace log files are streamed directly to your development machine.
So in essence the traceFile access requires two things
1.) Permission to write a trace log file i.e. WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE for good measure
2.) An emulator with an SDCard attached with sufficient space. The doc doesnt say if this is only for DDMS but also for debug, so I am assuming this is also true for debugging via the application.
What do I do with this error:
Now the error is essentially a fall out of either not having the sdcard path to create a tracefile or not having permission to access it. This is an old thread, but the dev behind the bounty, check if are meeting the two prerequisites. You can then go search for the .trace file in the sdcard folder in your emulator. If it exists it shouldn't be giving you this problem, if it doesnt try creating it by adding the startMethodTracing to your app.
I'm not sure why it automatically looks for this file when the logger kicks in. I think when an error/log event occurs , the logger internally tries to write to trace file and does not find it, in which case it throws the error.Having scoured through the docs, I don't find too many references to why this is automatically on.
But in general this doesn't affect you directly, you should check direct application logs/errors.
Also as an aside Android 2.2 and later devices do not need an SD card for DDMS trace logging. The trace log files are streamed directly to your development machine.
Additional information on Traceview:
Copying Trace Files to a Host Machine
After your application has run
and the system has created your trace files .trace on
a device or emulator, you must copy those files to your development
computer. You can use adb pull to copy the files. Here's an example
that shows how to copy an example file, calc.trace, from the default
location on the emulator to the /tmp directory on the emulator host
machine:
adb pull /sdcard/calc.trace /tmp Viewing Trace Files in Traceview To
run Traceview and view the trace files, enter traceview
. For example, to run Traceview on the example files
copied in the previous section, use:
traceview /tmp/calc Note: If you are trying to view the trace logs of
an application that is built with ProGuard enabled (release mode
build), some method and member names might be obfuscated. You can use
the Proguard mapping.txt file to figure out the original unobfuscated
names. For more information on this file, see the Proguard
documentation.
I think any other answer regarding positioning of oncreate statements or removing uses-sdk are not related, but this is Android and I could be wrong. Would be useful to redirect this question to an android engineer or post it as a bug
More in the docs
Try removing the uses-sdk part form AndroidManifest.xml file. it worked for me!
Don't use the Android Virtual Device with too low configuration. Let it be medium.
Write all your code below this 2 lines:-
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
It worked for me without re-installing again.
I didn't want to reinstall everything because I have so many SDK versions installed and my development environment is set up just right. Getting it set up again takes way too long.
What worked for me was deleting, then re-creating the Android Virtual Device, being certain to put in a value for SD Card Size (I used 200 MiB).
Additional information:
while the above does fix the problem temporarily, it is recurring. I just tried my application within Android Studio and saw this in the output log which I did not notice before in Eclipse:
"/Applications/Android Studio.app/sdk/tools/emulator" -avd AVD_for_Nexus_S_by_Google -netspeed full -netdelay none
WARNING: Data partition already in use. Changes will not persist!
WARNING: SD Card image already in use: /Users/[user]/.android/avd/AVD_for_Nexus_S_by_Google.avd/sdcard.img
ko:Snapshot storage already in use: /Users/[user]/.android/avd/AVD_for_Nexus_S_by_Google.avd/snapshots.img
I suspect that changes to the log are not saving to the SD Card, so when LogCat tries to access the logs, they aren't there, causing the error message. The act of deleting the AVD and re-creating it removes the files, and the next launch is a fresh launch, allowing LogCat to access the virtual SD Card.
You will not have access to your real sd card in emulator. You will have to follow the steps in this tutorial to direct your emulator to a directory on your development environment acting as your SD card.
Actually, the problem is that either /sys/kernel/debug is not mounted, or that the running kernel has no ftrace tracers compiled in so that /sys/kernel/debug/tracing is unavailable. This is the code throwing the error (platform_frameworks_native/libs/utils/Trace.cpp):
void Tracer::init() {
Mutex::Autolock lock(sMutex);
if (!sIsReady) {
add_sysprop_change_callback(changeCallback, 0);
const char* const traceFileName =
"/sys/kernel/debug/tracing/trace_marker";
sTraceFD = open(traceFileName, O_WRONLY);
if (sTraceFD == -1) {
ALOGE("error opening trace file: %s (%d)", strerror(errno), errno);
sEnabledTags = 0; // no tracing can occur
} else {
loadSystemProperty();
}
android_atomic_release_store(1, &sIsReady);
}
}
The log message could definitely be a bit more informative.

Can not open draw9patch.bat normally

i installed the newest version of Android SDK,and use SDK Tool Revision 20.0.3, and then i double click the 'draw9patch.bat',i hope it can show me an UI,unfortunately, the bat file just run flashing past, does not show the UI. And then i try to double click 'hierarchyviewer.bat', the program doesn't show an UI either. I don't know why and i can get the ways to solve this problem from the Internet, so i turn to your guys for help.
Make sure you set environment path for java . Open command prompt and navigate to android-sdk\tools\lib folder and type java -jar draw9patch.jar press enter . now you could get see UI screen if no problem with this .jar file .
Probably, "find_java.bat" and it's associated crap exe are failing miserably at doing the one thing it's supposed to do. I don't know how it's supposed to work or why it's failing, and I don't really care. Java is installed and this exe is a failure - so purge the damn dependency and be done with it. Who knows, maybe find_java.exe is some damn NSA virus - never worked for me before (maybe it can't find 64-bit Java... worthless rubbish).
Ahem, yeah, anyway...
Go to draw9patch.bat and change these three lines:
set java_exe=
call lib\find_java.bat
if not defined java_exe goto :EOF
to this (use your Java path):
set java_exe=C:\Program Files\Java\jdk1.7.0_21\bin\java.exe
Then you should even be able to run draw9patch.bat with another bat file wherever you want to place it for convenience, by doing something like this inside the new bat:
call "C:\Program Files (x86)\Android\android-sdk\tools\draw9patch.bat"
No idea why this 'answer' wasn't here a year ago. Open a command prompt... please. :P

Categories

Resources