magnusja / libaums

Open source library to access USB Mass Storage devices on Android without rooting your device
Apache License 2.0
1.28k stars 272 forks source link

libaums fails to compile with error in cmake... (android studio 4.0.2) #274

Closed vittalk closed 4 years ago

vittalk commented 4 years ago

I downloaded the libaums-master and opened it in android Studio 4.0.2 .. while trying to build it, I go this error. I am trying to compile this libaums so that I can try out the sample code included... Do I need to add libusb? if so please let me know where do I need to them and how. I am an IOS programmer and newbie to both Android and libaums. So any help will be much appreciated. thanks, -Vittal
email dot vittal at gmail dot com

Problem

debug|x86 :-- Detecting CXX compile features - done debug|x86 :Using libusb path null debug|x86 :-- Configuring done debug|x86 :CMake Error at CMakeLists.txt:11 (add_library): debug|x86 : Cannot find source file: debug|x86 : null/libusb/core.c debug|x86 : Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp debug|x86 : .hxx .in .txx debug|x86 :CMake Error: CMake can not determine linker language for target: libusb debug|x86 :-- Generating done

Expected behavior

Actual behavior

Stacktrace of Excpetion

(if exists)

Code where problem occurs

depau commented 4 years ago

Hi, Documentation for the libusb module is here: https://github.com/magnusja/libaums/tree/develop/libusbcommunication

If you build the whole project you need to download libusb and add it to your local.properties.

For example: https://github.com/magnusja/libaums/blob/develop/.travis.yml#L24-L26

vittalk commented 4 years ago

HI Davide, Thank you. Your suggestion helped me to compile the code. But now I have a different problem. It fails to install, I get the conflicting provider error.. I have tried various suggestions from the internet.. none of them have worked.. Greatly appreciate any help.

Installation did not succeed. The application could not be installed: INSTALL_FAILED_CONFLICTING_PROVIDER

List of apks: [0] '/Users/vittal/AndroidStudioProjects/LIBAUMS_work/libaums-master/app/build/outputs/apk/debug/app-debug.apk' Installation failed due to: 'null'

Thanks and Best Regards, -Vittal

On Sun, Oct 11, 2020 at 4:06 PM Davide Depau notifications@github.com wrote:

Closed #274 https://github.com/magnusja/libaums/issues/274.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/magnusja/libaums/issues/274#event-3864177717, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGZ3ESWBNAR2KGWZBNLUPLSKI275ANCNFSM4SLVGONA .

vittalk commented 4 years ago

To continue, i can send whatever files you want to inspect , or the whole folder (24MB) if you want to load it on android studio and see ..

Thanks and Best Regards, -Vittal

On Mon, Oct 19, 2020 at 1:32 AM Vittal Krishnamurthy email.vittal@gmail.com wrote:

HI Davide, Thank you. Your suggestion helped me to compile the code. But now I have a different problem. It fails to install, I get the conflicting provider error.. I have tried various suggestions from the internet.. none of them have worked.. Greatly appreciate any help.

Installation did not succeed. The application could not be installed: INSTALL_FAILED_CONFLICTING_PROVIDER

List of apks: [0] '/Users/vittal/AndroidStudioProjects/LIBAUMS_work/libaums-master/app/build/outputs/apk/debug/app-debug.apk' Installation failed due to: 'null'

Thanks and Best Regards, -Vittal

On Sun, Oct 11, 2020 at 4:06 PM Davide Depau notifications@github.com wrote:

Closed #274 https://github.com/magnusja/libaums/issues/274.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/magnusja/libaums/issues/274#event-3864177717, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGZ3ESWBNAR2KGWZBNLUPLSKI275ANCNFSM4SLVGONA .

magnusja commented 4 years ago

Do you have another app using libaums on that device?

Try deleting that part https://github.com/magnusja/libaums/blob/develop/storageprovider/src/main/AndroidManifest.xml#L10-L20

vittalk commented 4 years ago

Gentlemen, Thank you very much. I was able to compile and load the libaums. Greatly appreciated

Thanks and Best Regards, -Vittal

On Mon, Oct 19, 2020 at 5:05 AM magnus notifications@github.com wrote:

Do you have another app using libaums on that device?

Try deleting that part https://github.com/magnusja/libaums/blob/develop/storageprovider/src/main/AndroidManifest.xml#L10-L20

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/magnusja/libaums/issues/274#issuecomment-712111009, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGZ3ETUIE4EGUHMPUTWJCDSLQTRTANCNFSM4SLVGONA .

vittalk commented 4 years ago

Hi Davide, Magnus, Thank for your help. I am able to load the USB drive and display the directory contents.... I have another question to ask.

I need to read a JSON file stored in the USB flash drive. I am using Google's GSON library to read the json file and analyze the content. Below is the code. As you can see, 'reader' is used as a parameter to gson.fromJson(). and reader holds the content of the file extData.json. I've been trying to make this code work with your UsbFileInputStream but I am unable to do so. Any suggestions please? Greatly appreciate your help

try { // create Gson instance val gson = Gson()

// create a reader

 Reader reader = Files.newBufferedReader(Paths.get("extData.json"));
// ------------convert JSON file to map ----------
val map: Map<*, *> = gson.fromJson(reader, MutableMap::class.java)

val SID_tag : String = "SID"

// print map entries
for ((key, value) in map) {
    println(key.toString() + "  =   " + value)
    val tempString : String  = key.toString() + " = " + value
    Log.i("json file content:   ", tempString)
    if (key.toString() == SID_tag) {
        ssID.text = "SID: " + value.toString()
        Log.i("Found SID IS:----  ", value.toString())
    }

}

// close reader
reader.close()

} catch (ex: Exception) { ex.printStackTrace() }

Thanks and Best Regards, -Vittal

On Mon, Oct 19, 2020 at 4:54 PM Vittal Krishnamurthy email.vittal@gmail.com wrote:

Gentlemen, Thank you very much. I was able to compile and load the libaums. Greatly appreciated

Thanks and Best Regards, -Vittal

On Mon, Oct 19, 2020 at 5:05 AM magnus notifications@github.com wrote:

Do you have another app using libaums on that device?

Try deleting that part https://github.com/magnusja/libaums/blob/develop/storageprovider/src/main/AndroidManifest.xml#L10-L20

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/magnusja/libaums/issues/274#issuecomment-712111009, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGZ3ETUIE4EGUHMPUTWJCDSLQTRTANCNFSM4SLVGONA .

vittalk commented 4 years ago

Hi Gentlemen, To summarize my request, I need to read and write a JSON file present in the USB stick. I might later need to copy and transfer files(for which you have sample code already available). I am using GSON now, I am open to use any other library if you can recommend..

Thanks and Best Regards, -Vittal

On Wed, Oct 21, 2020 at 10:39 PM Vittal Krishnamurthy < email.vittal@gmail.com> wrote:

Hi Davide, Magnus, Thank for your help. I am able to load the USB drive and display the directory contents.... I have another question to ask.

I need to read a JSON file stored in the USB flash drive. I am using Google's GSON library to read the json file and analyze the content. Below is the code. As you can see, 'reader' is used as a parameter to gson.fromJson(). and reader holds the content of the file extData.json. I've been trying to make this code work with your UsbFileInputStream but I am unable to do so. Any suggestions please? Greatly appreciate your help

try { // create Gson instance val gson = Gson()

// create a reader

 Reader reader = Files.newBufferedReader(Paths.get("extData.json"));
// ------------convert JSON file to map ----------
val map: Map<*, *> = gson.fromJson(reader, MutableMap::class.java)

val SID_tag : String = "SID"

// print map entries
for ((key, value) in map) {
    println(key.toString() + "  =   " + value)
    val tempString : String  = key.toString() + " = " + value
    Log.i("json file content:   ", tempString)
    if (key.toString() == SID_tag) {
        ssID.text = "SID: " + value.toString()
        Log.i("Found SID IS:----  ", value.toString())
    }

}

// close reader
reader.close()

} catch (ex: Exception) { ex.printStackTrace() }

Thanks and Best Regards, -Vittal

On Mon, Oct 19, 2020 at 4:54 PM Vittal Krishnamurthy < email.vittal@gmail.com> wrote:

Gentlemen, Thank you very much. I was able to compile and load the libaums. Greatly appreciated

Thanks and Best Regards, -Vittal

On Mon, Oct 19, 2020 at 5:05 AM magnus notifications@github.com wrote:

Do you have another app using libaums on that device?

Try deleting that part https://github.com/magnusja/libaums/blob/develop/storageprovider/src/main/AndroidManifest.xml#L10-L20

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/magnusja/libaums/issues/274#issuecomment-712111009, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGZ3ETUIE4EGUHMPUTWJCDSLQTRTANCNFSM4SLVGONA .

magnusja commented 4 years ago

This should help you out https://github.com/google/gson/issues/187

vittalk commented 4 years ago

Thank you so very much. This worked.. Greatly appreciated

Thanks and Best Regards, -Vittal

On Thu, Oct 22, 2020 at 1:28 AM magnus notifications@github.com wrote:

This should help you out google/gson#187 https://github.com/google/gson/issues/187

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/magnusja/libaums/issues/274#issuecomment-714325245, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGZ3EWGMQYYAIYZ4WANBSLSL7ULDANCNFSM4SLVGONA .