firstly my module build.gradle was like this:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.depressionanalysis"
minSdkVersion 27
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
buildToolsVersion '28.0.3'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.firebase:firebase-firestore:17.1.0'
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.google.guava:guava:27.0.1-jre'
implementation 'com.loopj.android:android-async-http:1.4.9'
}
which resulted in this warning:
" The app gradle file must have a dependency on com.google.firebase:firebase-core for Firebase services to work as intended. "
so i tried to add it in (and updated firestore as well)
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.depressionanalysis"
minSdkVersion 27
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
buildToolsVersion '28.0.3'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.firebase:firebase-firestore:21.4.2'
implementation 'com.google.firebase:firebase-core:17.3.0'
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.google.guava:guava:27.0.1-jre'
implementation 'com.loopj.android:android-async-http:1.4.9'
}
but got this error
" Manifest merger failed : Attribute application#appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:10:5-46:19 to override. "
How do i fix it? I've tried out a few solutions found here but to no avail.. Thanks in advance! Let me know if any other codes are needed!!
You are using the latest version of firestore:
com.google.firebase:firebase-firestore:21.4.2
and on June 2019, firebase started supporting androidX, therefore you need to migrate to androidX to be able to use firebase.
The updated libraries will not work unless you make the following changes in your app:
Upgrade com.android.tools.build:gradle to v3.2.1 or later.
Upgrade compileSdkVersion to 28 or later.
Update your app to use Jetpack (AndroidX); follow the instructions in Migrating to AndroidX.
Check how to migrate:
https://developer.android.com/jetpack/androidx/migrate
Actually, for the same library, you have different versions via different sources, You have support library as well as their AndroidX version, For Now, you can try solving it using
tools:replace="android:appComponentFactory
attribute as given in your error itself.
Go to your AndroidManifest file add this attribute like below.
<application
android:name=".AbcApplication"
tools:replace="android:appComponentFactory
>
</application>
for me i have add two attribute in AndroidMenifest.xml
tools:replace="android:appComponentFactory"
android:appComponentFactory="androidx"
full tag it like :
<application
android:allowBackup="true"
android:icon="#mipmap/logo"
android:label="#string/app_name"
android:roundIcon="#mipmap/logo"
android:theme="#style/AppTheme"
tools:replace="android:appComponentFactory"
android:appComponentFactory="androidx"
tools:ignore="GoogleAppIndexingWarning">
and your project should be in Androidx.
Related
My project is in Java on android studio on IntelliJ.
I downloaded openbeans-1.0.jar, put it in my libs folder, went to Project Structure, and added it to the dependencies. Here is my build.gradle (:app) code:
apply plugin: 'com.android.application'
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.example.gotimejavaversion"
minSdkVersion 15
targetSdkVersion 30
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.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.opencsv:opencsv:5.2'
implementation 'com.googlecode:openbeans:1.0'
implementation 'com.univocity:univocity-parsers:2.9.0'
}
This is the MVN Repository info I found online for OpenBeans using gradle(this is just a visual reference I am using to create the line implementation 'com.googlecode:openbeans:1.0' in my build.gradle file. I am not using Maven):
// https://mvnrepository.com/artifact/com.googlecode/openbeans
compile group: 'com.googlecode', name: 'openbeans', version: '1.0'
I get the error:
Could not determine the dependencies of task ':app:compileDebugRenderscript'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
> Could not find com.googlecode:openbeans:1.0.
Required by:
project :app
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
I couldn't make out what I am doing wrong in the documentation. I've checked how I've typed it in multiple times and have tried implementation 'com.googlecode.openbeans:openbeans:1.0' I'm new to working with repositories and programming at that. Any help is appreciated.
Thank you!
i am trying to import network library , but android studio shows up with this meessage:ERROR: Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve com.amitshekhar.android:android-networking:1.0.2.
here is the build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.myfaild"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.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.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.amitshekhar.android:android-networking:1.0.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
I know this is the old question, but I saw such a problem after removing jcenter() from repositories in gradle file:
repositories {
google()
jcenter()
}
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
this worked for me ,i had to add jitpack.io
Try this
compile 'com.amitshekhar.android:android-networking:1.0.2'
When using it with Jackson Parser
implementation 'com.amitshekhar.android:jackson-android-networking:1.0.2'
When using it with RxJava
implementation 'com.amitshekhar.android:rx-android-networking:1.0.2'
When using it with RxJava2
compile 'com.amitshekhar.android:rx2-android-networking:1.0.2'
add this line in gradle.properties:
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
I don't know what the error means. I'm trying to do an uber app from youtube that uses Firebase and got this error.
Cannot fit requested classes in a single dex file (# methods: 86010 > 65536)
com.android.tools.r8.CompilationFailedException: Compilation failed to complete.
build.gradle(app)
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.ezbusjava"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
debuggable = true
signingConfig signingConfigs.debug
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
implementation 'com.google.firebase:firebase-auth:19.2.0'
implementation 'com.google.firebase:firebase-firestore:21.3.1'
implementation 'com.google.firebase:firebase-database:19.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
build.gradle(project)
buildscript {
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.3'
}
}
allprojects {
repositories {
mavenCentral()
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Android has a 65,536 method limit. If your app exceeds that number, you need to enable multidexing.
Simply add the multiDexEnabled flag and the needed dependency to your build.gradle:
android {
defaultConfig {
...
multiDexEnabled true
...
}
...
}
dependencies {
...
implementation 'com.android.support:multidex:1.0.3'
}
Additionally, you need to configure your app to make use of multidexing.
According to the docs, if your app extends Application, you need it to extend from MultiDexApplication instead.
If your app is not extending Application, you need to add the following line to your manifest:
<application
android:name="android.support.multidex.MultiDexApplication" >
...
</application>
Try Enabling Multidex in the app. You can read more about it here https://developer.android.com/studio/build/multidex
I'm creating wallpaper app in the android studio with firebase.
I got an error while compiling
Error:java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:com.android.dex.DexException: Multiple dex files define Landroid/arch/lifecycle/LiveData$1;
i added "multiDexEnabled true" and
"implementation 'com.android.support:multidex:1.0.3'"
and also i clean and rebuild my project
nothing happens
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.jimdo.saifstudios.wallpfeb"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.firebaseui:firebase-ui-database:3.1.2'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:recyclerview-v7:27.1.0'
implementation 'com.android.support:cardview-v7:27.1.0'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-database:11.8.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'
}
apply plugin: 'com.google.gms.google-services'
Take a look at the docs of the firebase-ui.
https://github.com/firebase/FirebaseUI-Android
For the version you are using you have to use com.google.firebase:firebase-database:11.6.2
If you are extending Application in your app. in my case i fixed it by adding MultiDex.install(this); to attachBaseContext(Context context) method.
you can take a look at:
https://developer.android.com/studio/build/multidex.html
I've encountered this issue in the past, and was able to fix it fairly easily. This time, however, I do not see what's causing it. The only change to the build.gradle I have made since it worked was implementation project(':sharedfiles') - a shared common module for wear/mobile. I didn't add this, I added the module as a dependency and this line was automatically added, so I doubt it is an error. I have multipleDexEnabled true and cannot find any conflicting dependencies. Any help would be appreciated, this is my first time using a common module. Here are the two build.gradle files.
Mobile Module
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "bhprograms.supremis"
minSdkVersion 23
targetSdkVersion 26
multiDexEnabled true
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:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
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'
wearApp project(':wear')
implementation 'com.google.android.gms:play-services-wearable:+'
implementation files('libs/gson.jar')
implementation project(':sharedfiles')
}
The Common Module
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 23
targetSdkVersion 26
versionCode 1
multiDexEnabled true
minSdkVersion 23
targetSdkVersion 26
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'
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'
implementation files('libs/gson.jar')
}
And, of course, the error.
Error:Execution failed for task ':mobile:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Solved by getting rid of implementation files('libs/gson.jar') in the mobile module. Not sure why this fixed it, likely because I was not using this jar anymore in the mobile module. Left it there as I may need it in the future if an experimental feature does not work, but this is what was causing the issue.