yashsingh1/xdaforums huggingface dataset:
[Android Software Development] Beatsleigher:
You're reading but not listening to the error message. You're attempting to access a method you're not allowed to access without creating an object first:

If you check the docs, you won't see any static (VB: Shared) methods, only instance methods.

public static void Main(string[] args) {
// Get AndroidController instance and first connected device
var acInstance = AndroidController.Instance;
var device = acInstance.GetConnectedDevice();

// Get FileSystem object
var fileSystem = device.FileSystem;

// Now you can access the GetFilesAndDirectories()-method
var fsEntries = fileSystem.GetFilesAndDirectories("/");
}

Public Shared Sub Main(args As String())
' Get AndroidController instance and first connected device'
Dim acInstance = AndroidController.Instance
Dim device = acInstance.GetConnectedDevice()

' Get FileSystem object'
Dim fileSystem = device.FileSystem

' Now you can access the GetFilesAndDirectories()-method'
Dim fsEntries = fileSystem.GetFilesAndDirectories("/")
End Sub
[Android Software Development] andi205:
Thank you.

Unfortunately the acInstance.GetConnectedDevice-Method returns Nothing. My samsung s5 mini is visible in windows explorer. Usb-connecting is set as MTP.

What's my mistake?
[Android Software Development] Beatsleigher:
Maybe you should read some tutorials on software development and Android before continuing.

You need to enable Developer Mode on your device and authorise your computer on your smartphone before you can see it using ADB.
[Android Software Development] andi205:
Thank you for support, but i give up. It's too difficult at this moment for me.
[Android Software Development] Beatsleigher:
As I just said. Read some tutorials on the matter before trying any projects that you don't/can't understand.

Learn to program, and basic Android "hacking", and then combine the two.
[Android Software Development] baran21:
Readinfo adb command

Readinfo device adb writte Rictextbox.text
[Android Software Development] Arun H:
push operation on Device

Hi,

I am not able to do push operation on Device

My source file path is given as it is shown in explorer "C:\image.jpg"

Similarly, for destination "Computer\Galaxy J7 Prime\Phone\DCIM"

is there anything I am missing on ?
[Android Software Development] Beatsleigher:
The first path is the path on the computer.

The second path is the path on the device.
[Android Software Development] Arun H:
Yeah, Not able to figure out why push operation is not working.

FYI, I have not enabled Developer Mode on the Mobile device. I don't want to do that since I can't expect the user to do that.
[Android Software Development] Beatsleigher:
Then we've found your problem. Developer Mode needs to be enabled, and the second path applies only to the file system on the device.
[Android Software Development] etwalgade:
Getting back no directories or files from android using GetFilesAndDirectories

I am having an issue trying to get a listing of files and directories off my device.

I have a rooted GS5 with USB Debugging enabled. I am able to successfully connect to the android device using AndroidLib, and retrieve things like serial number, root status, etc.

I am writing a little windows application, that among other things, I want to be able to list the files and folders on the android device. The issue I am having is that every time I call "GetFilesAndDirectories", I get nothing.

Here is the code in my test app:

var deviceFiles = connectedDroid.FileSystem;

var dirs = deviceFiles.GetFilesAndDirectories("/"); // just try to list root directory

Debugging down into AndroidLIb's source, I discovered I was getting data back from the device, but the Regx command was filtering them out.

So for debugging purposes, I commented this out to see what I would get. Modified GetFilesAndDirectories code snippet:

using (StringReader reader = new StringReader(Adb.ExecuteAdbCommand(cmd)))

{

string line = null;

while (reader.Peek() != -1)

{

line = reader.ReadLine();

if (!string.IsNullOrEmpty(line) /*&& !Regex.IsMatch(line, @"\s")*/)

{

filesAndDirs.Add(line, line.EndsWith("/") ? ListingType.DIRECTORY : ListingType.FILE );

}

}

}

When I did that, this is the output I got back (This is just a partial listing of the output I got back):

total 2344 - FILE

drwxr-xr-x 27 0 0 0 Jan 4 2014 [1;34m.[0m/ - DIRECTORY

drwxr-xr-x 27 0 0 0 Jan 4 2014 [1;34m..[0m/ - DIRECTORY

drwxr-xr-x 2 0 0 0 Jan 4 2014 [1;34m.system[0m/ - DIRECTORY

drwxr-xr-x 3 0 0 0 Jan 4 2014 [1;34macct[0m/ - DIRECTORY

drwxrwx--- 5 1000 2001 4096 Jun 17 11:30 [1;34mcache[0m/ - DIRECTORY

drwxr--r-- 3 1000 1000 4096 Jan 1 1970 [1;34mcarrier[0m/ - DIRECTORY

dr-x------ 2 0 0 0 Jan 4 2014 [1;34mconfig[0m/ - DIRECTORY

lrwxrwxrwx 1 0 0 17 Jan 4 2014 [1;36md[0m -> [1;34m/sys/kernel/debug[0m/ - DIRECTORY

drwxrwx--x 38 1000 1000 4096 Jun 18 20:57 [1;34mdata[0m/ - DIRECTORY

drwxrwxrwx 2 0 2000 0 Jan 4 2014 [1;34mdatamedia[0m/ - DIRECTORY

-rw-r--r-- 1 0 0 264 Jan 1 1970 [0;0mdefault.prop[0m - FILE

drwxr-xr-x 17 0 0 16200 Jan 4 2014 [1;34mdev[0m/ - DIRECTORY

drwxrwx--x 13 1000 1001 4096 Feb 19 01:43 [1;34mefs[0m/ - DIRECTORY

I can see the actual folder names embedded in there, but I am also getting allot of other stuff.

Any ideas?
[Android Software Development] k1ll3r8e:
Heyho,

just came across this thread, u can use my regex:

ls

INODE, TYPE, PERM, INCLUDES, OWNER, GROUP, ID, SIZE, DATE, TIME, NAME, SYMLINK, SUBTYPE
^\s{0,}((?<INODE>[0-9]{1,})\s{1,})?(?<TYPE>(-|b|c|d|l|s|p){1})(?<PERM>((-|r|s|t|w|x){9}|[0-9]{4}))(\s{1,}(?<INCLUDES>[0-9]{1,}))?\s{1,}(?<OWNER>.*?)\s{1,}(?<GROUP>.*?)(\s{1,}(?<ID>[0-9]{1,},))?\s{1,}(?<SIZE>[0-9]{1,})?\s{1,}(?<DATE>.*?)\s{1,}(?<TIME>[0-9:\.]{4,13})\s{1,}(\e\[([0-9]{1,};)?[0-9]{1,}m(=)?)?(?<NAME>.*?)(\e\[([0-9]{1,};)?[0-9]{1,}m(=)?)?(\s{1,}->\s{1,}(\e\[([0-9]{1,};)?[0-9]{1,}m(=)?)?(?<SYMLINK>.*?)(\e\[([0-9]{1,};)?[0-9]{1,}m(=)?)?)?(?<SUBTYPE>(\*|\/){1})?$

df

NAME, SIZE, USED, FREE, BLOCKSIZE, USE, PATH
^(df:\s{1,})?(?<NAME>(.*?))(:)?(\s{1,}(?<SIZE>([0-9]{1,}[a-zA-Z\.]?){1,}))?(\s{1,}total,)?(\s{1,}(?<USED>([0-9]{1,}[a-zA-Z\.]?){1,}))?(\s{1,}used,)?(\s{1,}(?<FREE>([0-9]{1,}[a-zA-Z\.]?){1,}))?(\s{1,}available\s{1,}\(block size)?(\s{1,}(?<BLOCKSIZE>[0-9]{1,}(\.[0-9]{1,}[a-zA-Z]{1,})?))?(\))?(\s{1,}(?<USE>([0-9]{1,})%))?(\s{1,}(?<PATH>(.*?)))?$

Regards,

Sebastian
[Android Software Development] Elildar:
Hi,

I'm trying to use the AndroidLib to get files from my Android phone.

I followed the example code, so I have the following working fine :

device = android.GetConnectedDevice(serial);
this.label2.Text = device.SerialNumber;

After that I tried to pull the directory with many path and had none working. Example :

device.PullDirectory("Ordinateur/MyPhone/Phone/Android/data/myfolder", "C:/temp")

I used the same path than in the windows browser, but I don't even know if it's the right thing to do.

I also tried to use this :

device.FileSystem.GetFilesAndDirectories("Ordinateur/MyPhone/Phone/Android")

But I have an exception because device.HasRoot is false.

Maybe the answer is in the documentation, but all the links provided are dead.

Does someone have any answer or example working?

Thx, Elildar

Edit: I finally found my solution after many many tries and research on ADB. The address had to be "/storage/sdcard0/Android/data/myfolder/".
[Android Software Development] piggycenter:
Where can i download the androidlib.dll

Hello,

I have find all place on #1 post but didn't find where is the androidlib.dll download link. Anyone help me please
[Android Software Development] asgharSo:
hi

I use this code for the timer

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
android.UpdateDeviceList()
If (android.HasConnectedDevices) Then
PictureBox2.BackColor = Color.Lime
Label1.Text = "device connected"
Else
PictureBox2.BackColor = Color.Maroon
Label1.Text = "Status : None"
End If

But the software hangs while debug

help please
[Android Software Development] dt_matthews:
Probably because you are doing that on the main UI thread and causing it to lock up when this runs;

android.UpdateDeviceList()
[Android Software Development] asgharSo:
I will delete this command line but the problem will not be fixed :(
[Android Software Development] dt_matthews:
In that case I suppose it must be:

android.HasConnectedDevices

locking the UI thread?
[Android Software Development] asgharSo:
Unfortunately I could not solve it

This is all code

Imports RegawMOD.Android

Public Class Form1
Dim android As AndroidController
Dim device As Device

Private Sub ShowAdbDevicesToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ShowAdbDevicesToolStripMenuItem.Click
If PictureBox2.BackColor = Color.Lime Then
Dim test = Adb.ExecuteAdbCommand(Adb.FormAdbCommand("device"))
MsgBox(test)
Else
Label1.Text = "State: no device connected"
End If
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
android = AndroidController.Instance
Timer1.Start()
End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
'android.UpdateDeviceList()
If (android.HasConnectedDevices) Then
PictureBox2.BackColor = Color.Lime
Label1.Text = "device connected"
Else
PictureBox2.BackColor = Color.Maroon
Label1.Text = "Status : None"
End If
End Sub

Private Sub StartAdbServerToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles StartAdbServerToolStripMenuItem.Click
Adb.ExecuteAdbCommandNoReturn(Adb.FormAdbCommand("Start-server"))
Label1.Text = "statuse: server start..."
End Sub

Private Sub KillServerToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles KillServerToolStripMenuItem.Click
Adb.ExecuteAdbCommandNoReturn(Adb.FormAdbCommand("kill-server"))
Label1.Text = "statuse: Adb server stop..."
End Sub

Private Sub RebootNormalToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles RebootNormalToolStripMenuItem.Click
If PictureBox2.BackColor = Color.Lime Then
Adb.ExecuteAdbCommand(Adb.FormAdbCommand("reboot"))
Label1.Text = "statuse: device Rebooting..."
Else
Label1.Text = "statuse: device not connected"
End If
End Sub

Private Sub RebootRecoveryToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles RebootRecoveryToolStripMenuItem.Click
If PictureBox2.BackColor = Color.Lime Then
Adb.ExecuteAdbCommand(Adb.FormAdbCommand("Reboot recovery"))
Label1.Text = "statuse: rebooting recovery ..."
Else
Label1.Text = "statuse: device not connected"
End If
End Sub

Private Sub RebootBootloaderToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles RebootBootloaderToolStripMenuItem.Click
If PictureBox2.BackColor = Color.Lime Then
Adb.ExecuteAdbCommand(Adb.FormAdbCommand("reboot bootloader"))
Label1.Text = "rebooting to bootloader ...!"
Else
Label1.Text = "statuse:device not connected..."
End If
End Sub

Private Sub FastbootToAndroidToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles FastbootToAndroidToolStripMenuItem.Click

Fastboot.ExecuteFastbootCommand(Fastboot.FormFastbootCommand("reboot"))
Label1.Text = "statuse: fastboot rebooting..."
End Sub
End Class
[Android Software Development] dt_matthews:
What happens when you remove the second line then?
[Android Software Development] asgharSo:
Sorry the problem was from my Windows, I changed the windows problem was solved. ;)

Thanks
[Android Software Development] steefzz:
What have you changed exactly? Your Windows OS?

I'm having same issue, when running even the sample app it hangs.
[Android Software Development] asgharSo:
win 10

i reinstall windows for fix problem, Is your problem a timer?
[Android Software Development] asgharSo:
Solved !
[Android Software Development] asgharSo:
hi dears

how to move file into system partition

We use androidlib by the following command, but it does not work

Adb.ExecuteAdbCommand(Adb.FormAdbCommand("shell", "su", "-c", "mount -o remount, rw /system"))

Adb.ExecuteAdbCommand(Adb.FormAdbCommand("shell", "su", "-c", "cat /data/local/tmp/build2.prop > /system/build.prop"))

This command executes the read-only file system error

Is there a better command?

solved --------------------------------------------------

i change premission file to 755 and work this code

thanks
[Android Software Development] asgharSo:
hi dears

for example

i use this code for Write File to Device in Fastboot mode

TextBox1.AppendText(Environment.NewLine & Fastboot.ExecuteFastbootCommand(Fastboot.FormFastbootCommand("flash boot", textboxboot.Text)))

He is currently working in the background and application can not be accessed(hangs app) shows the output after it's finished

How can we do to not hang up And show the output during the wtire process?
[Android Software Development] ExCx:
Hi ,thanks for this great library. We had to find an offline way to manipulate our kiosk Android app and it would be impossible without this.

We got a problem though. Sometimes when we rebuild our winforms project and try to get "AndroidController.HasConnectedDevices" property (which runs UpdateDeviceList method) it throws a Win32Exception.

After some search we found that the "C:\Users\UserName\AppData\Local\Temp\RegawMOD\AndroidLib\fastboot.exe" is deleted somehow, so we must copy the file manually from the library. But eventually it happens again.

Why is this happening and is there a way to prevent it?

Thanks in advance.
[Android Software Development] foil:
Hey [MENTION=2326081]regaw_leinad[/MENTION] long time no talk! :)

I was wondering if I could possibly host the documentation to AndroidLib on my site?

edit: I see that you haven't been on here since August 2018, so I'll go ahead and host it for everyone else to have access to, and if you have any issue with it, please contact me here or on gtalk if you still have my contact info on there!

Also, [MENTION=4320277]beatsleigher [/MENTION] I saw that you're the one that recompiled it, so it is your copy that I'm hosting. Same applies - if you don't want me to, or want me to take it down/modify it, I will do so. :)

url is: http://androidlib.f0il.com
[Android Software Development] SixSigmaGuy:
Can I use AndroidLib.dll from Excel VBA?
[Android Software Development] wcyap:
C# AndroidLib.

Hi sir , you are a legend, a lot of thanks ! However, i am having some question, how do i make my combobox update automatically when it detects the android state : plug in/removed/change state?
[Android Software Development] Mrc527:
Yes, I still have the same problem with 1.0.0.2.

BTW the 1.0.0.1 is working great! I implemented multithreading myself, or better, I call actions with your lib on a separated thread.

And...Bluetooth support? Is planned in the future or is impossible? :D

Is possible to fire an event when a phone is connected? Like to open a window when I attach the phone....it would be great!
[Android Software Development] drcell:
Thanks for your example but didnt run. Please look at the picture. I didn't change anything from your sample code.

Thanks again...
[Android Software Development] regaw_leinad:
well that's odd, considering you can see in the Form1_Load method, it does in fact create a new instance of AndroidController. I just ran the sample on my computer and it works fine.

I'm rewriting (again) the internal device manager, this time on the main thread again, but under much less load, so it should be way faster. I'll post a new version today, with samples.
[Android Software Development] Mrc527:
Hello!

I have a problem with a GalaxyS2 with custom MOD (CM9) and custom Kernel (Siyah).

With stock CM9 kernel it was working, now with ADB I can see the device connected, I can forward ports and everything works.

But your LIB not.

I receive an error like this:

Eccezione non gestita di tipo 'System.ArgumentException' in mscorlib.dll

Informazioni aggiuntive: Impossibile trovare il valore 'TY' richiesto.

It's in Italian, it says: Unhandled exception of type 'System.ArgumentException' in mscorlib.dll. Additional informations: Impossible to find value 'TY' required.

Bye.
[Android Software Development] regaw_leinad:
I have a new build I'm putting through the tests right now, It's going to release with my RegawMOD Hero Rooter in a little bit, then I'll post the zip here.
[Android Software Development] regaw_leinad:
Updated to 1.1.0.0. Please check out the new documentation and Getting Started guide in the zip! There are a few things different having to do with how you create a new Device instance. Also, the samples have been updated in post #2 as well, so take a look at them for a start! (I haven't written in Visual Basic before, but I tried my best, and both the C# and VB demos should be EXACTLY the same)
[Android Software Development] Mrc527:
Ok, now it works!:D:D
[Android Software Development] regaw_leinad:
I am in the process of either creating a Google Docs Form, or a separate program to run on the computer, that I would like users of different phones to use to help the development of this project. I will have the links shortly. And also, if you do release a project using AndroidLib, post a link in here so I can put your project in the second post to show it off as a project that uses this library! Also, sample project links were moved to their own section in the first post.
[Android Software Development] Mrc527:
Hello, I use your library into my application "Android SMS", here is the link: http://www.kernel-xp.net/index.php/en/progetti/8-androidsms

It is a PC application that let the user to read and write SMS from PC.

I have an xda thread too, Here is the link

Bye and compliments for your great work!

P.S., I own a Galaxy Nexus, a Desire Z, an LG Optimus One and all 3 are working with your lib! :-)

Inviato dal mio Galaxy Nexus usando Tapatalk
[Android Software Development] Tasssadar:
Nice work, keep it up :)

Is the source code available? Github repo perhaps...?
[Android Software Development] drcell:
Please help me. I posted my problem before but couldn't solve it. Why your sample code doesn't work on my computer? I am getting an error like this;

Tell me what can i do...
[Android Software Development] regaw_leinad:
First I'll start by asking what type of phone do you have? Right now I don't have full support on every phone, because I only have 5 types that I have tested on. I'm currently writing a small program to help me add support to more phones in this project. Let me know what phone you have and I can help out.
[Android Software Development] drcell:
Thanks for your quick reply. I have HTC Sensation with Android Revolution HD 6.6.1 Rom.

Best regards...
[Android Software Development] regaw_leinad:
Ok cool. I'm about to go to sleep here in Seattle.. 4:50am ftw lol

I'll be finishing up my "AndroidLibExpansion" project tomorrow, which will help add support to more phones. Also, you can try setting a debug breakpoint at that line, and follow the code by pressing F-11 for each code line, then find out where the code actually fails.
[Android Software Development] codemonkey85:
@regaw_leinad: Just wanted to say that you, sir, are a champion. As a .Net developer and an Android superfan, I cannot express how awesome this is. Thank you so much!
[Android Software Development] filmaker:
omg thanks..no more writing bat files for everything
[Android Software Development] TarekNajem04:
Error When Create New Instance From [AndroidController]

when i create new instance from [AndroidController] Like this:

AndroidController DevController = new AndroidController();

I see this error:

System.ArgumentOutOfRangeException was unhandled

HResult=-2146233086

Message=Length cannot be less than zero.

Parameter name: length

Source=mscorlib

ParamName=length

StackTrace:

at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)

at System.String.Substring(Int32 startIndex, Int32 length)

at RegawMOD.Android.AndroidController.UpdateDeviceList()

at RegawMOD.Android.AndroidController..ctor()

when I go to folder that you extracted resoures to it and execute command from adb I see this output:

C:\Users\Tarek Najem\AppData\Local\Temp\RMResources>adb devices

adb server is out of date. killing...

* daemon started successfully *

List of devices attached

0123456789ABCDEF device

My device is HD2 leo Android TBD room

Microsoft Visual Studio 2010

Windows 7 x64

Tested with .net fw 3, 3.5, 4, 4.5 [same error].

I am sorry for reflect yout cod "But I think the error"

Your Code:

using (StringReader reader = new StringReader(this.deviceList))

{

while (reader.Peek() != -1)

{

string item = reader.ReadLine();

if ((!item.StartsWith("List") && !item.StartsWith("\r\n")) && !(item.Trim() == ""))

{

item = item.Substring(0, item.IndexOf("\t"));

this.connectedDevices.Add(item);

}

}

}

In this line you search to Tab Key but if see adb outpu first line not have tab key

I thin this line can you rewrit to avoid error

item = item.Substring(0, item.IndexOf("\t"));

Try this code

int TabIndex = item.IndexOf("\t");

if (TabIndex != 0)

{

item = item.Substring(0, TabIndex);

this.connectedDevices.Add(item);

}
[Android Software Development] regaw_leinad:
Ok good to know. I'm working on updating this for more support to more phones. In a few hours I will have a a program out called "AndroidLibExpansion" that will help me to write more support in for more phones (actually, help make it more universal, more than writing code for each phone in). For the time being, try stepping through the init of AndroidController with a debug breakpoint and see exactly where it fails.
[Android Software Development] regaw_leinad:
EDIT: This also might just have to do with you running android on your Windows Mobile phone, and your serial number scheme is probably different in length.

The problem with decompiling this is that the decompiled code is not always exactly the same visually as I wrote it. In this case, it is close, but not the same. Also, when you post my decompiled source in the thread, please try to do so using the CODE bracket so it's not so disorganized and spread out.

Your Decompiled Version:

using (StringReader reader = new StringReader(this.deviceList))
{
while (reader.Peek() != -1)
{
string item = reader.ReadLine();
if ((!item.StartsWith("List") && !item.StartsWith("\r\n")) && !(item.Trim() == ""))
{
item = item.Substring(0, item.IndexOf("\t"));
this.connectedDevices.Add(item);
}
}
}

My Version:

if (deviceList.Length > 29)
{
using (StringReader s = new StringReader(this.deviceList))
{
string line;

while (s.Peek() != -1)
{
line = s.ReadLine();

if (line.StartsWith("List") || line.StartsWith("\r\n") || line.Trim() == "")
continue;

line = line.Substring(0, line.IndexOf("\t"));
this.connectedDevices.Add(line);
}
}
}

The code

if (deviceList.Length > 29)

skips the checking if there are no devices connected, because the binary I am using outputs 29 bytes if there are no devices attached.

The code

if (line.StartsWith("List") || line.StartsWith("\r\n") || line.Trim() == "")
continue;

skips every line that is does not display devices. And there is a '\t' character after the device serial number before the device state.

And in the case of your added code

if (TabIndex != 0)

I assume you mean this?:

if (TabIndex != -1)

because it returns -1 if a tab is not found.

I'm pretty sure my code covers everything here, unless your serial number is in fact '0123456789ABCDEF' and there is no '\t' between that and your state.

Try running

adb start-server
adb devices > "%UserProfile%\Desktop\Devices.txt"

and open it in Notepad++ (or similar) and check that there is in fact a '\t' after your serial number.
[Android Software Development] drcell:
Same error with Visual Basic 2010.
[Android Software Development] TarekNajem04:
output

List of devices attached
0123456789ABCDEF	device

and error not in variable name line or item error in line:

line = line.Substring(0, line.IndexOf("\t"));

try this

int TabIndex = line.IndexOf("\t");
if (TabIndex != -1)
{
line = line.Substring(0, TabIndex);
this.connectedDevices.Add(line);
}
[Android Software Development] regaw_leinad:
I have just posted my AndroidLib Expansion project . This project will help collect information to expand support to many more phones in AndroidLib. Please go check it out and download/run the exe. The source code for that is posted as well.

Thanks everyone, the more phones that is run with, the better support AndroidLib will have!

-regaw