Library not installed with build make Android Studio but works with CMAKE-GUI - android-studio

System information:
Android Studio 3.2.1
Linux Ubuntu 16.04
Introduction
I recently came across a problem with my IDE (Android Studio). I use it to develop a Native / Java Application alongside Gradle and CMakeLists.
I use a few CMakeLists to export some functions in C/C++ to use with my app.
So these Cmakelists will create some library that can be used.
Problem
When I "make" my project it will build successfully, but the library doesn't change, whether it's modified, or not.
After that, I thought that I might need to "Clean my project" before doing it, but nothing good happened.
You can see my build.gradle under the post.
Tried Solution
The workaround I found is to compile each library with CMAKE-GUI and then compile my Android project to see the modification previously made.
That's bad and not normal, I think.
Help
I want to know why my project doesn't make again my library and "install" it in the appropriate folder.
It's unnecessary to show my CMakeLists because it works on CLion with Linux and Windows with Visual Studio.
Build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.media.[NAME_OF_MY_PROJET]"
minSdkVersion 24
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk { abiFilters "armeabi-v7a" }
externalNativeBuild {
cmake {
cppFlags "-O3 -fno-stack-protector -fintegrated-as "
arguments "-DANDROID_ABI=armeabi-v7a", "-DANDROID_TOOLCHAIN=clang",
"-DANDROID_NATIVE_API_LEVEL=24", "-DANDROID_NDK=/Android/Sdk/ndk-bundle",
"-DANDROID_STL=c++_static", "-DANDROID_SDK_ROOT=/Android/Sdk/"
}
}
}
buildTypes {
/* customDebugType {
debuggable true
} */
debug {
jniDebuggable true
}
/* release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}*/
}
externalNativeBuild {
cmake {
path "../CMakeLists.txt"
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
}

Related

Will apps developed using chaquopy create issues while deployment?

I would like to use chaquopy for the communication between java/kotlin and python code in android Studio. Below shown is my build gradle file:
plugins {
id 'com.android.application'
id 'com.chaquo.python'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.image_processing_using_chaquopy"
python{
pip{
install "numpy"
install "opencv-contrib-python-headless"
install "pillow"
}
}
sourceSets{
main{
python{
srcDirs = ["src/main/python"]
}
}
}
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
abiFilters "armeabi-v7a", "x86"
}
python{
buildPython "C:/Users/hp/AppData/Local/Programs/Python/Python39/python.exe"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Here, we are giving the python.exe local path and chaquopy is not listed in the dependencies too. Will it cause any problem while deploying this app on android phones or some other external devices?
Here, we are giving the python.exe local path
This only affects the build process: this path is not used at runtime. In fact, it couldn't be used at runtime even if we wanted to, because an Android app has no direct access to the filesystem of your computer, even when you're using an emulator.
However, to make it easier for other developers to build your source code, it would be better to remove the buildPython line and allow Chaquopy to find Python on the PATH, as it says in the documentation. If you installed Python from python.org using the default settings, then the py launcher will already be on the PATH, so this will work automatically.
chaquopy is not listed in the dependencies too
That's no problem: the Chaquopy plugin at the top of the file will add any necessary dependencies.

can't get gradle to accept java-client-6.0.0-BETA1.jar in android studio 3

I'm new to android studio. I'm trying to get Android Studio Gradle to build with appium's java-client-6.0.0-BETA1.jar. I'm implementing appium. I believe android studio is install right. I've downloaded the recommended files for appium, selenium-server-standalone-3.8.1.jar, selenium-remote-driver.jar, selenium-java-3.8.1.zip and anything else I can see needed. Appium server is installed and working. An android emulator is running and working.
I get this error:
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Repositories\ApkProjects\EndToEndAndroidTest\app\libs\java-client-6.0.0-BETA1.jar
at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.launchProcessing(DexArchiveBuilderTransform.java:550)
at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.lambda$convertToDexArchive$1(DexArchiveBuilderTransform.java:488)
at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Error while dexing io/appium/java_client/touch/TapOptions.class
The dependency contains Java 8 bytecode. Please enable desugaring by adding the following to build.gradle
android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
I've tried the recommended fix - makes no difference. I've updated guava-23.3-android also which was giving similar errors.
The gradle.build file is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.nwri.endtoendandroidtest"
minSdkVersion 18
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
// compile 'com.google.guava:guava:23.3-android'
}
I've searched the web and can't find anyone having this issue. Here is a screen shot if that helps:
Android studio
Setting Source Compatibility and Target Compatibility to 1.8 in Project Structure dialog helped me.
While manual adding
android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
did not help.

failed to resolve com.android.support.espresso:espresso-core:2.2.2

I've just downloaded android studio for the first time and i'm getting gradle errors. I've downloaded everything the SDK provided and still the same errors.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.noelly.myapplication"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.+'
testCompile 'junit:junit:4.12'
}
The errors I'm getting are
(Failed to resolve: com.android.support.appcompat-v7:25.+)
and
(Failed to resolve: com.android.support.espresso:espresso-core:2.2.2)
Everything by the way is up to date,please help this is really frustrating starting out.
**EDIT FROM ANSWER ONE- PICTURE OF INSTALLED TOOLS---
sdktoolsscreenshot
Code form project build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
New Error messages_____newerrorscreenshot
failed to resolve com.android.support.espresso:espresso-core:2.2.2
This error can occur when we refactor layout name.
I had the same problem and my mistake was that I had created the layout naming test.xml and then when I refactored that name with like layout_offers.xml, my gradle was changed something like
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.detail_layout.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
})
Whereas It should be like follow
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
So, one solution is that we should avoid using test.xml as a layout name.
Here's how your gradle file should look like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.noelly.myapplication"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.1.0'
}
Update:
There must be a problem with the SDK you downloaded. Navigate to C:/Users/Noelly/AppData/Local/Android/Sdk/extras/android/m2repository/com/android and delete the support folder.
Now open your SDK Manager and re-install the Android Support Repository.
I got same trouble as yours, and I have found how to solve the problem.
It was because I was using x86 operating system, while android studio was x64.
I went to https://developer.android.com/studio/index.html and pressed 'download option', and installed x86 version of android studio.
Do not uninstall your previous x64 android studio. It is required because of the android sdk.
unpack your x86 android studio anywhere, and find 'bin' folder. There should be your 'studio.exe'.
I got this same error message after renaming a layout file, although everything had just worked before. I fixed this by commenting out these lines from gradle:
androidTestCompile('com.android.support.detail_layout.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
I have no idea why this happened or if this is a good way of fixing it, only hoping that this could be a quick fix for some beginner like me.

Decompiling a self generated jar in lib in Android Studio

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'com.github.triplet.play'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.prototype"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
testCoverageEnabled = false
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:1.10.19"
testCompile 'org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:0.31'
}
I have generated a jar using swagger codegen and have placed in lib folder of my app in the Android studio. It is not getting decompiled, i.e., I am not able to see classes of my jar here.
I have tried Invalidate caches/Restart. It worked sometimes before.
But it is not working anymore. Any help will be appreciated.
You probably missing in your build.gradle something like:
compile files('libs/your-jar-filename.jar')
The following worked for me :
Right-click the jar file.
Select 'Add as Library.
Do Gradle Sync.

Android Studio: Error: Error:(205, 24) error: exception handling disabled, use -fexceptions to enable

I am very new to Android Studio. I am trying to build some Sqlite3 wrapper classes (written in C++). I tried to build them with NDK using Android studio, but I am getting error that "Error:(205, 24) error: exception handling disabled, use -fexceptions to enable". I am not able to find what option should I give in gradle.build file. I have seen many posts but they all refer to some Android.mk or Application.mk file. I have pasted content of my gradle.build file below:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.asite.ndksample"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
ndk{
moduleName "myLib"
stl "gnustl_static"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
Let me know how to come out from this error using Android Studio with gradle.build file. Also let me know detail about all parameters mentioned under "ndk" section. I am not aware what all possible values can be put there.
you can use the cFlags parameter under the ndk section:
ndk{
moduleName "myLib"
stl "gnustl_static"
cFlags "-fexceptions"
}
The only other paramters you can use for this ndk configuration are ldLibs and abiFilter, to specify respectively required ndk libs (log...) and cpu architectures to compile for (x86, armeabi-v7a, x86_64...).

Resources