Error: transformDexArchiveWithExternalLibsDexMergerForDebug FAILED - android

I am trying to develop an SFTP client using sshj on Android studio such that the App can connect securely to the server using SFTP over ssh. The code was running fine, but when I added the "sshj-0.10.0" module, it gives me this complicated error.
The "sshj-0.10.0" module is needed to run server code using net library as below:
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.sftp.SFTPClient;
I added the module the project and configured it in the dependencies in build.gradel of the app as shown below:
What I have tried so far (but not limited to):
1- Clean Project then Rebuild Project - failed
2- Invalidate Caches / Restart - failed
3- Delete .gradle and .idea from my root project- failed
4- Added
android {
defaultConfig {
multiDexEnabled true
}
}
and
dependencies {// Multidex
implementation 'com.android.support:multidex:1.0.3'
implementation project(path: ':sshj-0.10.0')
}
No solution was worked with me.
Here is my build.gradle(:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.mohsenali.autosen"
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
android {
defaultConfig {
multiDexEnabled true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
//TedPermission
implementation 'gun0912.ted:tedpermission:1.0.3'
implementation files('D:/SKKU_PhD/Android/workspace_2018_projects/AutoSen/app/libs/commons-net-3.7.1.jar')
// Multidex
implementation 'com.android.support:multidex:1.0.3'
implementation project(path: ':sshj-0.10.0')
}
I know that this kind of error is popular but I tried many possible solutions available on SO since two days ago but none of them has helped me. So please don't mark it duplicated, maybe someone could help. Thanks.

Finally, I solved this error bu creating "libs" folder in the root of "app" project, and added the .jar library to it. After that I updated the code in "build.gradle(:app)" by adding this line: "implementation files('path to/app/libs/jsch-0.1.55.jar')".

Related

Untiy android plugin class not found exception

I'm writing an android plugin for unity to be able to check if notifications are enabled for the game. I have one java class with a method for checking if notifications are enabled. When i build the plugin and then the .apk with unity everything works fine. But after installation, when calling the mehthod i get the following exception:
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/app/NotificationManagerCompat;
The Java class
package com.example.plugin;
import android.app.Activity;
import androidx.core.app.NotificationManagerCompat;
public class NotificationPlugin {
public static boolean areNotificationEnabled(Activity unityActivity) {
return NotificationManagerCompat.from(unityActivity).areNotificationsEnabled();
}
}
buld.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
gradle.properties
org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
android.enableJetifier=true
Haven't found a solution anywhere else yet. Thank in advance. It's probably a super simple fix that i miss.
Update
Custom gradle.properties in unity set with android.enableJetifier and android.useAndroidX set to true
Jetifier was enabled in unity
Androidx.Core libary was added to the dependencies of the gradle.build file of the plugin
None of the above solved the issue
Solution
As Hamid Yusifli suggested in his answer a custom gradle build template needs to be enabled (Project Settings>Player>Publishing Settings>Custom Main Gralde Template) and the dependencies for the libary need to be added (implementation 'androidx.core:core:1.5.0' in my case). This solved the issue.
So, seems like in your case unity ignores your library gradle dependencies,
there are many different reasons why this could happen. To force unity to include missing dependencies you must provide a custom Gradle build template and add your dependencies in that file.

This project uses AndroidX Dependencies,but the 'android.useAndroidX' property is not enabled

I have updated my android build.gradle to latest version now i am getting an error.
I have searched answers regarding this here(stackover flow),but none work for me .
my build.gradle code is:--->
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.parse.starter"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
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 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
when i click on "sync now" then the error appears as:--->
This project uses AndroidX Dependencies,but the 'android.useAndroidX' property is not enabled.
After searching some answers here(stackover flow) .i created a file 'gradle.property' from File>new>Files(named as gradle.property) and added codes on it as:--->
org.gradle.jvmargs=-Xmx2048m
android.useAndroidX=true
android.enableJetifier=true
After doing this when i click again on "sync now".then again the same error appears (This project uses AndroidX Dependencies,but the 'android.useAndroidX' property is not enabled.)
I dont know how to fix this issue.
please Help
thankyou.
Try this solution go to :
Refactor -> Refactor this -> Migrate to Androidx -> click migrate , then a pop up message will show up to ask you if you want to save a copy of the project by ticking that checkbox ( up to you ) --> then do refactor
You might have migrated to android x manually
Try using built in migrator
https://developer.android.com/jetpack/androidx/migrate
Just right click , then go to refractor> migrate to AndroidX

Android studio intellisense cannot resolve symbol on import

I'm new to Android development and inherited a project from an old collegue. At some point in time, I changed something in the project structure. I'm not sure what I changed that triggered these errors. However, now intellisense shows all kind of errors: Ex. on import android.content.Intent; it says Cannot resolve symbol 'Intent'.
Now, the project still builds and runs without a problem, however, everywhere in the project are red squiggly lines and autocomplete doesn't work.
I have tried all i could find on this problem (invalidate cache / deleting files / reimport project / etc) The only thing I found to work is changing the API version to 27, in which case every intellisense warning dissappears, although the project breaks, because it uses version 28 stuff.
Currently, the app module has compileSdkVersion 28 and targetSdkVerion 27. Changing both to 27 resolves the intellisense, but breaks the projct, changing both to 28 (or 29) doesn't resolve anything.
It feels like i might need to update something else?
*update as requested by haresh, *
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "nl.app.ofme"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
abiFilters "armeabi", "armeabi-v7a"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion = '28.0.3'
//Used to get clear warning details about deprecated methods
allprojects {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.1.2'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.squareup.okio:okio:1.15.0'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.android.volley:volley:1.1.0#aar'
implementation 'com.google.firebase:firebase-analytics:17.2.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
}
dependencies {
implementation 'com.google.firebase:firebase-messaging:20.0.1'
}
apply plugin: 'com.google.gms.google-services'
In Android Studio, go to File -> Invalidate Caches / Restart ...
Try to use updated version for all of your module and project level library.
File -> Snyc Project with gradle files.
Migrate with androidx. Refactor -> Migrate to Android
In Android Studio, go to File -> Invalidate Caches / Restart
This are the all things you can try.

Incorrect value for field 'Signature': value is 662655099 but 67324752 expected

I've been working with Firebase Database.The code was working fine for Firebase Authentication but showed this error message when added Firebase Database.
Incorrect value for field 'Signature': value is 662655099 but 67324752 expected.
Following is the gradle script:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.sudhanshujaisani.mywhatsapp"
minSdkVersion 21
targetSdkVersion 27
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(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:support-v4:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.2'
implementation 'com.android.support:design:27.1.1'
implementation 'de.hdodenhof:circleimageview:3.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
}
Thanks in advance.
I don't really know what causes this error but I had it too and I figured out (after some research) that it's something going on with Instant Run. It hasn't got anything to do with firebase, but I think it's something about Gradle and importing packages.
Anyway, I figured disabling Instant Run as a simple workaround and it worked! :)
In Android Studio:
File -> Settings (or press Ctrl+Alt+S).
Build, Execution, Deployment -> Instant Run (on the left panel).
Uncheck the first checkbox "Enable Instant Run to hot swap code/resource changes on deploy (default enabled)".
If you actually need Instant Run, this workaround won't help. I'm still trying to find the actual solution.
Invalidate Cache & Restart didn't work for me.
Try,
Build -> Clean Project
Build -> Rebuild project
File -> Invalidate Caches/Restart -
Update your android sdk, partial installations cause this problem.

ApolloGraphql FileNotFoundException: source/apollo/generatedIR/debug/src (Is a directory)

I am trying to add ApolloGraphql to my android project, but when i try to rebuild the project, i get :
org.gradle.api.UncheckedIOException: java.io.FileNotFoundException: /Users/mcebotari/Downloads/Projects/Barcloud/app/build/generated/source/apollo/generatedIR/snapshotDebug/src (Is a directory)
in build.gradle i have added the needed dependencies:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.apollographql.android'
android {
compileSdkVersion 27
defaultConfig {
applicationId "barcloud.com"
minSdkVersion 21
targetSdkVersion 27
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 "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
//Design
implementation 'com.github.rasoulmiri:buttonloading:v1.0.8'
//Vision Library
implementation 'com.google.android.gms:play-services-vision:15.0.2'
// RxJava
implementation "io.reactivex.rxjava2:rxjava:2.1.16"
implementation "io.reactivex:rxandroid:1.2.1"
implementation "com.jakewharton.rxbinding:rxbinding:1.0.1"
implementation "com.squareup.retrofit2:adapter-rxjava:2.3.0"
implementation 'com.jakewharton.rxbinding:rxbinding-appcompat-v7:1.0.1'
//RxPermissions
implementation 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.5#aar'
//Retrofit
implementation "com.squareup.retrofit2:retrofit:2.4.0"
implementation "com.squareup.retrofit2:adapter-rxjava2:2.4.0"
implementation "com.squareup.retrofit2:converter-gson:2.4.0"
// rxandroid
implementation "io.reactivex.rxjava2:rxandroid:2.0.1"
// Dagger
implementation "com.google.dagger:dagger:2.12"
kapt "com.google.dagger:dagger-compiler:2.12"
//GraphQL
implementation 'com.apollographql.apollo:apollo-runtime:1.0.0-alpha'
implementation 'com.apollographql.apollo:apollo-rx2-support:1.0.0-alpha'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
and also the dependency:
classpath 'com.apollographql.apollo:apollo-gradle-plugin:1.0.0-alpha'
Trying to rebuild the project i get :
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:generateDebugApolloClasses'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
...
Caused by: org.gradle.api.UncheckedIOException: java.io.FileNotFoundException: /Users/mcebotari/Downloads/samples/Barcloud/app/build/generated/source/apollo/generatedIR/debug/src (Is a directory)
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:57)
...
Caused by: java.io.FileNotFoundException: /Users/mcebotari/Downloads/samples/Barcloud/app/build/generated/source/apollo/generatedIR/debug/src (Is a directory)
at java.io.FileInputStream.open0(Native Method)
The graphql files are the ones from the official sample - GithuntFeedQuery.graphql and their schema.json, pasted in main folder.
Any ideas?
There are two solutions which I came accross while researching this problem:
Remove apollo from your project, (by editing your gradle files) clean your project, and add apollo again.
Try changing the apollo version in your project gradle file,
ie. mine worked with
classpath 'com.apollographql.apollo:gradle-plugin:0.3.1
and it was 0.3.2 originally.
Had the same issue with prodRelease config, fixed by renaming prod flavor.
In apps build.gradle I have:
buildTypes {
debug {...}
release {...}
}
productFlavors {
dev {...}
stage {...}
prod {...}
}
which gives me 6 buildVariants
devDebug
devRelease
stageDebug
stageRelease
prodDebug
prodRelease
top 5 were building without a problems locally and on CI, while prodRelease was giving me the same error as you described without any logical explanation. GraphQL files are the same for dev, stage and prod... I've tried to create specific folders for "prod" then for "prodRelease", checked their access rights - all the same for all variants, nothing helped. And prodDebug were building correctly all the time. Then I've renamed prod flavor(don't forget to rename graphql files folder accordingly) and it now works like a charm.

Categories

Resources