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

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.

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.

shadow jar to avoid dependency duplication in android studio

I am building an android application in android studio but am having trouble with duplicate dependencies.
Duplicate class javax.inject.Inject found in modules jetified-javax.inject-1.jar (javax.inject:javax.inject:1) and jetified-javax.inject-2.5.0-b42.jar (org.glassfish.hk2.external:javax.inject:2.5.0-b42)
Both these dependencies were quite useful to me and i tried excluding the offending part of the dependencies from either of them which just ended up breaking one or the other.
I have been reading about shadow jars which from what i heard of sounded like a magic bullet so i tried it. From what i had read and heard you just added it as a dependency and it magically fixed everything. I tried adding it and i was still getting the error but i read online it is necessary to have the java or groovy plugin if you want it to work with out a lot of work. Either of these makes android studio very unhappy as android has its own slightly modified java or something.
Advice on how to get the shadow jar working would be much appreciated, but also if anyone has any other work arounds that would let me keep using the two clashing dependencies i would love to hear. I sorry if i made some newbie mistakes.
My gradle file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.example.scrood"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.github.jengelman.gradle.plugins:shadow:6.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.squareup.picasso:picasso:2.5.1'
implementation 'org.glassfish.jersey.core:jersey-client:2.27'
implementation 'org.glassfish.jersey.media:jersey-media-json-jackson:2.27'
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.10.4'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.4'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation ('com.google.android.libraries.places:places:2.3.0')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

isuess sync gradle for some old project from git

ERROR: Could not find com.android.tools.build:gradle:3.4.1. Searched
in the following locations:
https://jcenter.bintray.com/com/android/tools/build/gradle/3.4.1/gradle-3.4.1.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.4.1/gradle-3.4.1.jar
Required by:
project : Add Google Maven repository and sync project Open File Enable embedded Maven repository and sync project
i have try to update distributionUrl
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
and this my build gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.example.android.miwok"
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
implementation "com.android.support:appcompat-v7:$supportVersion"
implementation "com.android.support:support-v4:$supportVersion"
implementation "com.android.support:design:$supportVersion"
}
well this is not best practice to do that, first of all, run that project in android studio and update the gradle, follow one method from this link Link.

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

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'
}

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.

Resources