I'm trying to make my Android gradle folder structure as flat as possible. I'm hoping for something on the lines of this:
─ ~/my_projects/
└─ project_a/
├─ java/
│ └─ com/me/project_a/MainActivity.java
├─ javatests/
│ └─ com/me/project_a/MainActivityTest.java
├─ res/
│ ├─ drawable/...
│ ├─ layout/...
│ └─ values/...
├─ *.gradle
└─ AndroidManifest.xml
Is there a way to structure my gradle files so that I can have a structure this flat while still building via gradle and getting Android Studio to recognize everything?
Related
Flutter Fix
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ The plugin google_maps_flutter_android requires a higher Android SDK version. │
│ Fix this issue by adding the following to the file D:\Development\ULTIMAT POS\App POS Backup\UltimatePOS_Flutter_1.7.1\pos\android\app\build.gradle: │
│ android { │
│ defaultConfig { │
│ minSdkVersion 20 │
│ } │
│ } │
│ │
│ │
│ Note that your app won't be available to users running Android SDKs below 20. │
│ Alternatively, try to find a version of this plugin that supports these lower versions of the Android SDK.
│
│ For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration
Replace minSdkVersion 20 in file build.gradle at folder Android/app/
in your project folder, look for that file:
android\app\build.gradle
open it in your editor, and search for this:
minSdkVersion flutter.minSdkVersion
replace it with this:
minSdkVersion 20
I need to identify the current connection type (etc 3G, 4G, 5G). I've used the ConnectivityManager but on some phones, the reported connection is 4G even if the download speed is so big that the phone is clearly on 5G.
Here I found a possible way to fix it. I need to check it on different devices.
I was wondering whether there is a way to use Firebase test-lab to do it. I used Firebase test-lab in the past but I was always mocking the network connection to run instrumentation tests so I don't know whether it is possible to actually use a cellular connection and whether it is possible to choose the SIM card used.
EDIT
Following the suggestion I'm using gloud beta. I run gcloud firebase test network-profiles list and I have got the following list:
┌────────────┐
│ PROFILE_ID │
├────────────┤
│ LTE │
└────────────┘
┌──────┬────────┬────────────┬───────────────────┬───────────┬───────┐
│ RULE │ DELAY │ LOSS_RATIO │ DUPLICATION_RATIO │ BANDWIDTH │ BURST │
├──────┼────────┼────────────┼───────────────────┼───────────┼───────┤
│ up │ 0.040s │ 0.001 │ │ 16000.0 │ │
│ down │ 0.040s │ 0.001 │ │ 16000.0 │ │
└──────┴────────┴────────────┴───────────────────┴───────────┴───────┘
┌────────────┐
│ LTE-poor │
└────────────┘
┌──────┬────────┬────────────┬───────────────────┬───────────┬───────┐
│ RULE │ DELAY │ LOSS_RATIO │ DUPLICATION_RATIO │ BANDWIDTH │ BURST │
├──────┼────────┼────────────┼───────────────────┼───────────┼───────┤
│ up │ 0.060s │ 0.0015 │ │ 4000.0 │ │
│ down │ 0.060s │ 0.0015 │ │ 4000.0 │ │
└──────┴────────┴────────────┴───────────────────┴───────────┴───────┘
┌────────────┐
│ HSPA │
└────────────┘
┌──────┬────────┬────────────┬───────────────────┬───────────┬───────┐
│ RULE │ DELAY │ LOSS_RATIO │ DUPLICATION_RATIO │ BANDWIDTH │ BURST │
├──────┼────────┼────────────┼───────────────────┼───────────┼───────┤
│ up │ 0.060s │ 0.001 │ │ 2000.0 │ │
│ down │ 0.060s │ 0.001 │ │ 4000.0 │ │
└──────┴────────┴────────────┴───────────────────┴───────────┴───────┘
┌────────────┐
│ HSPA-poor │
└────────────┘
┌──────┬────────┬────────────┬───────────────────┬───────────┬───────┐
│ RULE │ DELAY │ LOSS_RATIO │ DUPLICATION_RATIO │ BANDWIDTH │ BURST │
├──────┼────────┼────────────┼───────────────────┼───────────┼───────┤
│ up │ 0.100s │ 0.0015 │ │ 500.0 │ │
│ down │ 0.100s │ 0.0015 │ │ 1000.0 │ │
└──────┴────────┴────────────┴───────────────────┴───────────┴───────┘
...
5G is not in the list (yet). And the result is the same with gcloud beta firebase test network-profiles list
Devices in Firebase Test Lab are connected via WiFi by default. There's no guarantee that a device has a SIM at all, and you should not rely on that. Your best choice is to use a specific network profile, which can be configured as part of the test.
You can list all available network profiles and their settings with the command below:
$ gcloud firebase test network-profiles list
You can set the network profile by using gcloud beta, as the setting is not GA yet:
$ gcloud beta firebase test android run \
--network-profile=LTE \
<your other args>
I'm building a library module that might be used in an Android application. In a certain part of the code, I need to load a JavaScript file so the script engine runs it. My file structure looks something like this: https://i.snag.gy/R7hHPI.jpg
└───src
├───main
│ ├───java
│ │ └───calegari
│ │ └───murilo
│ │ └───qacadscrapper
│ │ │ QAcadScrapper.java
│ │ │
│ │ └───utils
│ │ Grade.java
│ │ Subject.java
│ │ User.java
│ │
│ └───resources
│ └───lib
│ Barrett.js
│ BigInt.js
│ RSA.js
│
└───test
├───java
│ └───calegari
│ └───murilo
│ └───qacadtest
│ QAcadTest.java
│
└───resources
When building the artifact, I configure it so IntelliJ puts the contents of the /resources folder on root folder of the Jar file:
https://i.snag.gy/fN4z6t.jpg
These are the contents of the .jar file: https://i.snag.gy/QPR9XK.jpg
├───calegari
│ └───murilo
│ └───qacadscrapper
│ └───utils
├───com
│ └───sun
│ └───script
│ ├───javascript
│ └───util
├───javax
│ └───script
├───lib ---> Here are the JavaScript files
├───META-INF
│ ├───maven
│ │ └───org.jsoup
│ │ └───jsoup
│ └───services
├───org
│ ├───jsoup
│ │ ├───helper
│ │ ├───internal
│ │ ├───nodes
│ │ ├───parser
│ │ ├───safety
│ │ └───select
│ └───mozilla
│ ├───classfile
│ └───javascript
│ ├───annotations
│ ├───ast
│ ├───commonjs
│ │ └───module
│ │ └───provider
│ ├───debug
│ ├───jdk13
│ ├───jdk15
│ ├───json
│ ├───optimizer
│ ├───regexp
│ ├───resources
│ ├───serialize
│ ├───tools
│ │ ├───debugger
│ │ │ └───treetable
│ │ ├───idswitch
│ │ ├───jsc
│ │ ├───resources
│ │ └───shell
│ ├───typedarrays
│ ├───v8dtoa
│ ├───xml
│ └───xmlimpl
└───sun
├───misc
├───reflect
└───security
├───action
└───util
But when I try to install the APK I receive a "INSTALL_FAILED_NO_MATCHING_ABIS" error. I'm pretty sure that what's causing it are these .js files under /lib, since the error disappears if I remove them from the .jar build.
Library is configured using Gradle.
How can I avoid this error? Hope someone can help!
Update
I made IntelliJ add the .js files alongside the Java files inside my jar package, it works when running from the .jar file, but if I try to run some tests in IntelliJ it doesn't work, since gradle isn't adding the files to the compiled code...
Solution
I was able to make it work by moving the files to inside the source path and adding this to the gradle.build file:
sourceSets {
main {
java {
srcDirs = ['src/main/java']
}
resources {
srcDir 'src/main/java'
include '**/*.js'
}
}
test {
java {
srcDirs = ['src/test/java']
}
}
}
i had this problem using bitcoinJ library (org.bitcoinj:bitcoinj-core:0.14.7) added to build.gradle(in module app) a packaging options inside the android scope. it helped me.
android {
...
packagingOptions {
exclude 'lib/x86_64/darwin/libscrypt.dylib'
exclude 'lib/x86_64/freebsd/libscrypt.so'
exclude 'lib/x86_64/linux/libscrypt.so'
}
}
I want to use a C++ shared library inside my Android App.
I tried to follow along the hello-libs example from Google's NDK samples, but somehow it doesn't work out.
It seems, that my library isn't packed into the APK. All tutorials i found are using *.mk-files, but I want to use cmake.
This is my CMakeLists.txt:
# Sets the minimum version of CMake required to build the native library.
cmake_minimum_required(VERSION 3.4.1)
# native lib
add_library(native-lib SHARED
native-lib.cpp)
set(IMPORT_DIR ${CMAKE_SOURCE_DIR}/../jniLibs)
# shared lib
add_library(shared-lib SHARED IMPORTED)
set_target_properties(shared-lib PROPERTIES IMPORTED_LOCATION
${IMPORT_DIR}/dynamic/lib/${ANDROID_ABI}/libLibrary.so)
target_include_directories(native-lib PRIVATE
${IMPORT_DIR}/dynamic/include)
# linking libs
target_link_libraries(native-lib
android
shared-lib
log)
As soon as I link the shared-lib along with the others, I get the following error, when running the app:
E/art: dlopen("/data/app/my.package.name-1/lib/arm/libnative-lib.so", RTLD_LAZY) failed: dlopen failed: library "C:/projects/HelloLibs/app/src/main/cpp/../jniLibs/dynamic/lib/armeabi-v7a/libLibrary.so" not foun
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: my.package.name, PID: 29266
java.lang.UnsatisfiedLinkError: dlopen failed: library "C:/projects/HelloLibs/app/src/main/cpp/../jniLibs/dynamic/lib/armeabi-v7a/libLibrary.so" not found
at java.lang.Runtime.loadLibrary(Runtime.java:371)
at java.lang.System.loadLibrary(System.java:988)
at my.package.name.MainActivity.<clinit>(MainActivity.java:11)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.Class.newInstance(Class.java:1690)
at android.app.Instrumentation.newActivity(Instrumentation.java:1078)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2543)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2771)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1432)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5912)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
It looks like the library is not found on the device. Otherwise it looks like the librarie's path is still the one on my local maschine.
The prebuilt libLibrary.so does not have SONAME. If for whatever reason you cannot rebuild this library with latest NDK, you may try the patchelf utility to add SONAME to existing binary.
To package the prebuilt library into your APK, you need to manually configure Gradle with the sourceSets block to include the path to your .so file. After building your APK, you can verify which libraries Gradle packages into your APK by using the APK Analyzer(Build>Analyze APK...).
android {
...
sourceSets {
main {
jniLibs.srcDirs 'imported-lib/src/', 'more-imported-libs/src/'
}
}
for more information please see here "Include prebuilt native libraries"
You don't need to use CMake to use shared libraries (.so files). Just place the libraries inside the respective directories in src/main/jniLibs directory. Then you can load the libraries directly.
Android studio may show error in the native method declarations but, your app will work fine.
Another solution for packing the prebuilt libraries into your APK - linking them to jniLibs.
For example, I don't use direct placement of libraries (because they already exist elsewhere - in my case in docker image with all required prebuilts, SDK, NDK, etc.) but instead of it I just use linking to them to put them in APK. And if such libraries are also needed at build time, cmake can simply uses find_package().
/app/src/main$ tree
.
├── jniLibs
│ ├── arm64-v8a
│ │ ├── libCommonAPI.so -> /opt/thirdparty/android-29/arm64-v8a/capicxx-core-runtime/lib/libCommonAPI.so
│ │ ├── libCommonAPI-SomeIP.so -> /opt/thirdparty/android-29/arm64-v8a/capicxx-someip-runtime/lib/libCommonAPI-SomeIP.so
│ │ ├── libvsomeip3-cfg.so -> /opt/thirdparty/android-29/arm64-v8a/vsomeip/lib/libvsomeip3-cfg.so
│ │ ├── libvsomeip3-e2e.so -> /opt/thirdparty/android-29/arm64-v8a/vsomeip/lib/libvsomeip3-e2e.so
│ │ ├── libvsomeip3-sd.so -> /opt/thirdparty/android-29/arm64-v8a/vsomeip/lib/libvsomeip3-sd.so
│ │ └── libvsomeip3.so -> /opt/thirdparty/android-29/arm64-v8a/vsomeip/lib/libvsomeip3.so
│ ├── armeabi-v7a
│ │ ├── libCommonAPI.so -> /opt/thirdparty/android-29/armeabi-v7a/capicxx-core-runtime/lib/libCommonAPI.so
│ │ ├── libCommonAPI-SomeIP.so -> /opt/thirdparty/android-29/armeabi-v7a/capicxx-someip-runtime/lib/libCommonAPI-SomeIP.so
│ │ ├── libvsomeip3-cfg.so -> /opt/thirdparty/android-29/armeabi-v7a/vsomeip/lib/libvsomeip3-cfg.so
│ │ ├── libvsomeip3-e2e.so -> /opt/thirdparty/android-29/armeabi-v7a/vsomeip/lib/libvsomeip3-e2e.so
│ │ ├── libvsomeip3-sd.so -> /opt/thirdparty/android-29/armeabi-v7a/vsomeip/lib/libvsomeip3-sd.so
│ │ └── libvsomeip3.so -> /opt/thirdparty/android-29/armeabi-v7a/vsomeip/lib/libvsomeip3.so
│ ├── x86
│ │ ├── libCommonAPI.so -> /opt/thirdparty/android-29/x86/capicxx-core-runtime/lib/libCommonAPI.so
│ │ ├── libCommonAPI-SomeIP.so -> /opt/thirdparty/android-29/x86/capicxx-someip-runtime/lib/libCommonAPI-SomeIP.so
│ │ ├── libvsomeip3-cfg.so -> /opt/thirdparty/android-29/x86/vsomeip/lib/libvsomeip3-cfg.so
│ │ ├── libvsomeip3-e2e.so -> /opt/thirdparty/android-29/x86/vsomeip/lib/libvsomeip3-e2e.so
│ │ ├── libvsomeip3-sd.so -> /opt/thirdparty/android-29/x86/vsomeip/lib/libvsomeip3-sd.so
│ │ └── libvsomeip3.so -> /opt/thirdparty/android-29/x86/vsomeip/lib/libvsomeip3.so
│ └── x86_64
│ ├── libCommonAPI.so -> /opt/thirdparty/android-29/x86_64/capicxx-core-runtime/lib/libCommonAPI.so
│ ├── libCommonAPI-SomeIP.so -> /opt/thirdparty/android-29/x86_64/capicxx-someip-runtime/lib/libCommonAPI-SomeIP.so
│ ├── libvsomeip3-cfg.so -> /opt/thirdparty/android-29/x86_64/vsomeip/lib/libvsomeip3-cfg.so
│ ├── libvsomeip3-e2e.so -> /opt/thirdparty/android-29/x86_64/vsomeip/lib/libvsomeip3-e2e.so
│ ├── libvsomeip3-sd.so -> /opt/thirdparty/android-29/x86_64/vsomeip/lib/libvsomeip3-sd.so
│ └── libvsomeip3.so -> /opt/thirdparty/android-29/x86_64/vsomeip/lib/libvsomeip3.so
.
Im trying to install a module 'eGalax, eTurboTouch CT-410/510/700 device support' and its not showing up in my kernel config menu, when I search for it is listed, I suspect it has something to do with the EXPERT option below, how do I enable this?
│ Symbol: TOUCHSCREEN_USB_EGALAX_REVERSE [=n] │
│ Type : boolean │
│ Prompt: eGalax Special reverse MSB / LSB Packet │
│ Defined at drivers/input/touchscreen/Kconfig:553 │
│ Depends on: !S390 && INPUT [=y] && INPUT_TOUCHSCREEN [=y] && TOUCHSCREEN_USB_EGALAX [=n] && EXPERT │
│ Location: │
│ -> Device Drivers │
│ -> Input device support │
│ -> Generic input layer (needed for keyboard, mouse, ...) (INPUT [=y]) │
│ -> Touchscreens (INPUT_TOUCHSCREEN [=y]) │
│ -> eGalax, eTurboTouch CT-410/510/700 device support (TOUCHSCREEN_USB_EGALAX [=n])
In kernel 2.6.37 EXPERT became EMBEDDED.