Existing .so and .h files integration in android studio - android-ndk

I have one shared library and one header file.
I did one sample project there I have generated .so and header files but now my problem is how to import existing .so and .h files in android studio.
I searched in google but there they are showing how to generate but I want how to import these files. Please suggest me some links or any other examples

but now my problem is how to import existing .so and .h files in android studio
Usually, you should put your .so files inside jniLibs which is usually located at app/src/main/jniLibs, and put c/c++ source code inside app/src/main/cpp. See below directory structure.
.
├── CMakeLists.txt // Your cmake configuration files.
├── app.iml
├── build
├── build.gradle
├── libs
├── proguard-rules.pro
└── src
├── androidTest
│ └── java
├── main
│ ├── AndroidManifest.xml
│ ├── cpp // Directory to put your jni native source code.
│ │ └── native-lib.cpp
│ ├── java
│ ├── jniLibs // Directory to put your jni libs, i.e. the .so files.
│ └── res
└── test
└── java
See: https://stackoverflow.com/a/52048933/8034839

Related

geopandas read shp file with fiona.errors.DriverError when wrapping up as a package

I have a package structure like this:
├── LICENSE
├── README.md
├── main
│   ├── __init__.py
│   ├── application.py
│   ├── core_function
│   │   ├── __init__.py
│   │   └── maps
│   │   ├── Taiwan
│   │   ├── Taiwan_detailed
│   │   └── taiwan.txt
└── setup.py
I try to wrap this package by python setup.py develop.
When it runs Taiwan = gpd.read_file(pkg_resources.resource_stream(__name__, 'maps/Taiwan/COUNTY_MOI_1090820.shp')) in application.py,
fiona.errors.DriverError: '/vsimem/9b633f8a8a3f457eadf710539afd2a22' not recognized as a supported file format. or
fiona._err.CPLE_OpenFailedError: '/vsimem/9b633f8a8a3f457eadf710539afd2a22' not recognized as a supported file format. would occur.
It reads perfectly when I run it as a script on my machine, but it fails as a package.
Knowing that the shp file should be read along with all the files in that folder, in my setup.py I also include them
packages= setuptools.find_packages(),
package_data={'maps': ['main/core_function/maps/*','core_function/maps/Taiwan/*']},
I was thinking the problem is about the path, but taiwan.txt can be read.
Any suggestion is appreciated. Thanks in advance.
So far I have not found the reason.
But I instead used the to_file method and work with only one file.
.to_file("package.gpkg", driver="GPKG")
This works in my package. The problem can be due to reading multiple files.

How can I load an image from a changing path environment after building an .app with cargo-bundle?

I'm using cargo-bundle to create an .app bundle for my Rust application built with fltk-rs.
There are assets in the application like images. While I'm developing, accessing these assets is no problem.
main.rs:
let mut my_img = SharedImage::load("imgs/smiley.png").unwrap();
.
├── Cargo.lock
├── Cargo.toml
├── app_icon_design.psd
├── imgs
│ └── smiley.PNG <--get this image
├── src
│ ├── app_icon.png
│ ├── app_icon#2x.png
│ ├── icon32x32.png
│ └── main.rs
└── target
├── CACHEDIR.TAG
├── debug
└── release
I then bundle to an .app with cargo build --release which gives me the following directory structure inside of my .app:
.
├── Info.plist
├── MacOS
│ └── build_to_app_bundle <--my executable
└── Resources
└── imgs
└── smiley.PNG<--get this image now
Now my application needs to get the image file from the /Resources folder:
println!("my resources folder is: {:?}", std::env::current_exe().unwrap().parent().unwrap().join(Path::new("Resources")));
let my_resources_path = std::env::current_exe().unwrap().parent().unwrap().join(Path::new("Resources"));
How can I make it so that every time I want to load an image from a path I do not need to explicitly reference the Resources value?

Can I swap out the library used by a binary with a wrapper when building a third-party crate?

Let's say there is a vendored third-party cargo project consisting of a library plem and a binary plem_main that I want to extend with some functionality of my own. Crucially, the functionality needs to go in the library plem, not the binary plem_main (which can stay the same). I could write a wrapper my_plem around the library that offers the same interface to the binary, but with the extra functionality included. The project would be set up like this:
.
├── Cargo.toml
├── my_plem
│   ├── Cargo.toml
│   └── src
│   └── lib.rs
└── third-party
├── plem
│   ├── Cargo.toml
│   └── src
│   └── lib.rs
└── plem_main
├── Cargo.toml
└── src
└── main.rs
my_plem/src/lib.rs would depend on things in third-party/plem/src/lib.rs and reexport or overwrite the functions exported by the latter. Is there a good way to get cargo to build the binary plem_main on top of my_plem instead of plem?
"Best" here means that the solution has no or minimal merge conflicts when updating plem in my project and doesn't duplicate the code of plem_main. Ideally it does not touch third-party at all.

What are examples and what are they used for?

The directory layout of a Rust project should look like this (source)
.
├── Cargo.lock
├── Cargo.toml
├── benches
│ └── large-input.rs
├── examples
│ └── simple.rs
├── src
│ ├── bin
│ │ └── another_executable.rs
│ ├── lib.rs
│ └── main.rs
└── tests
└── some-integration-tests.rs
What is the file simple.rs under examples? How do I execute it? How should the file look like?
Examples are useful in library crates to show how the crate is used.
An example can be an executable with a main method or a library; it can either be in a single file examples/example-name.rs or consist of several files in a subdirectory examples/example-name/, with the main method in main.rs. To compile a library example you need to specify its crate type in Cargo.toml:
[[example]]
name = "example-name"
crate-type = ["lib"]
Examples are compiled by cargo test to ensure that they are up to date with the crate. You can run a specific executable example by
cargo run --example <example-name>
and selectively build any example with
cargo build --example <example-name>
This is documented in the Cargo Reference.

Gradle 1.3: build.gradle not building classes

a newb question here: I have a build.gradle file with apply plugin: java in it, and associated with a java project/package. when I run gradle build from the command line I get:
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
:assemble UP-TO-DATE
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build UP-TO-DATE
BUILD SUCCESSFUL
Total time: 4.312 secs
but when I check the build folder, there are no classes. What am I doing wrong ?
I have:
lib, reports, test-results & tmp under the folder but no classes. The src code is a class with a main method with 'Hello world' printed to console...
My tree looks like this:
.
├── build
│   ├── libs
│   │   └── gradle-sandbox.jar
│   ├── reports
│   │   └── tests
│   │   ├── base-style.css
│   │   ├── css3-pie-1.0beta3.htc
│   │   ├── index.html
│   │   ├── report.js
│   │   └── style.css
│   ├── test-results
│   └── tmp
│   └── jar
│   └── MANIFEST.MF
├── build.gradle
└── src
└── org
└── gradle
└── example
└── simple
├── HelloWorld.java
└── package-info.java
Without more information, it's hard to say. Maybe you put the source file into the wrong directory (default is src/main/java). Or the internal caches got corrupted (shouldn't happen, but try to delete the .gradle directory).
Do you get class files when you do gradle clean build? Note that a clean build is required whenever you switch between Gradle versions.
I had a similar issue where all of my classes were in src/main/java but none of the classes were showing up in the jar.
Issue was I was using Groovy. Adjusting it to src/main/groovy resolved the issue.
I had similar issue where I was already following the above hierarchy but also putted build.gradle inside the srcm/main/java/{{my project}}. Moving build.gradle to the project's root directory worked for me.
Let me know if it'll work for anyone else.

Resources