I had this issue with my android studio and I solved it with this answer.
Now my application is running on android studio and I will get a notification from android studio that the application has been installed and is launched but the application will not open on an emulator or on a physical device.
After android studio says the app has been installed the icon will show on the device bit if I click on it, I will get "App isn't installed" toast.
What can I do?
App level build.gradle file contains:
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 31
defaultConfig {
configurations.all {
resolutionStrategy { force 'androidx.core:core:1.6.0' }
}
applicationId "com.olalekanamoo.service"
minSdkVersion 16
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
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 {
// def work_version = "2.6.0"
// // Force WorkManager 2.6.0 for transitive dependency
// implementation("androidx.work:work-runtime:$work_version") {
// force = true
// }
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
My physical device that I use for debugging is running android 11.
I also tried this solution but it didn't work.
I am new to Android development, and not very good at gradle.
I come from "standard" Java development, using Maven.
I need to help a friend that wanted to do a quizz app, and he wants to be able to monitoring playing teams, so I suggested a REST service. I wanted to do it using openAPI.
I have created a simple openapi spec file, and used it to generate the server side (using the java spring generator).
Now, I want to add the client android part. My first try was to build it using the maven part (with the server) and use the mavenLocal() repository into gradle for the android project to be able to include the client library, but I had a bunch of problems.
So I switched to using the gradle openapi generator, to be able to do the same thing.
I have just finished to manage to import the library into the project, and I have the exact same problems with the maven lib.
I am lost, I don't know what to do.
android_project/settings.gradle :
rootProject.name = "MIMI_Quizz"
include ':app'
include ':openapi'
project(':openapi').projectDir = new File(settingsDir, '../android/openapi')
android_project/app/build.gradle :
plugins {
id 'com.android.application'
id "org.openapi.generator" version "5.3.0"
}
android {
compileSdkVersion 31
buildToolsVersion '31.0.0'
defaultConfig {
applicationId 'mimi_quiz'
minSdkVersion 16
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding true
}
}
openApiValidate {
inputSpec = "$rootDir/../rest/quizzapprestapi.json"
recommend = true
}
openApiGenerate {
generatorName = "android"
inputSpec = "$rootDir/../rest/quizzapprestapi.json"
outputDir = "$rootDir/../android/openapi"
groupId = "$project.group"
id = "$project.name-openapi"
version = "$project.version"
apiPackage = "quizz.android.rest.api"
invokerPackage = "quizz.android.rest"
modelPackage = "quizz.android.rest.model"
configOptions = [
java8 : "true",
dateLibrary : "java8",
library : "volley"
]
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
implementation 'androidx.navigation:navigation-fragment:2.4.1'
implementation 'androidx.navigation:navigation-ui:2.4.1'
implementation 'androidx.preference:preference:1.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation project(':openapi')
}
Now, when I try to build the solution, I have a lot of problems :
Cannot fit requested classes in a single dex file (# methods: 68312 > 65536)
I found that I needed to use multidex, but I tried it, and it wasn't a success.
Then I also have this error :
3 files found with path 'META-INF/DEPENDENCIES'.
Adding a packagingOptions block may help, please refer to
https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html
for more information
I don't know what to do. Is my openapi generation wrong ? how can I solve these errors ?
Edit : I read about the multidex modification, and I found that if the minSdkVersion is set to at least 21, it is enabled by default. So I did that, and indeed the error about the number of methods is now gone. As I am a novice to android, is the min sdk version set to 21 would prevent it to be able to be executed on a still used vast majority of phones ?
For the META-INF problem, I have added this in my build.gradle file :
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}
And now, everything builds as expected, is the way I solved these 2 problems right ? Should I have done it differently ?
started a new blank template project and just after adding draglinearlayout dependency i started getting these errors, while before adding this dependency i ran my project and it worked fine. the error is as follows
Execution failed for task ':app:checkDebugDuplicateClasses'.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-v4-22.1.1-runtime (com.android.support:support-v4:22.1.1)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-v4-22.1.1-runtime (com.android.support:support-v4:22.1.1)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules core-1.5.0-runtime (androidx.core:core:1.5.0) and support-v4-22.1.1-runtime (com.android.support:support-v4:22.1.1)
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
this is the error i'm getting
and this is my module grade file
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.ujjwal.drag_and_drop"
minSdkVersion 19
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'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'com.jmedeisis:draglinearlayout:1.1.0'
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.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Android has a solution to this problem where a new Android project uses AndroidX with some old libraries that use the legacy android support libraries, you are in that case.
The solution is to enable Jetifier in your gradle.properties, like this:
android.enableJetifier=true
You can find more info in these two posts:
Can I use library that used android support with Androidx projects.
What is Jetifier?
I'm building a face detection Android app. When I add dependency inside the app/build.gradle it gives me an error. Here is my gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "com.example.android.emojify"
minSdkVersion 15
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support ', module: 'support-annotations'
})
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.google.android.gms:play-services-vision:10.2.0'
testImplementation 'junit:junit:4.12'
}
Error is reported in the following lines:
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
Show us a screenshot of your error or format your error to easier reading, just click code button and paste it.
Edit: thank you :)
I think you should use refresh gradle after any changes in gradle.build and maybe you got this error because your build tools sdk is 28.0.3 and you want to use tool from sdk 28.0.0, just change compile sdk to 28.0.0 and click sync gradle on actionbar.
Your buildToolVersion is greater than your design and appcompat-v7.
Try to change,
implementation 'com.android.support:design:28.0.3' //or greater than 28.0.3
implementation 'com.android.support:appcompat-v7:28.0.3' //or greater than 28.0.3
connect to the internet and then build your project. Problem will be solved.
Whenever i add implemntation 'com.google.android.material:material:1.0.0-alpha1' when i try to build my project Android Studio says:
Program type already present: android.support.v4.app.INotificationSideChannel$Stub$Proxy
Message{kind=ERROR, text=Program type already present: android.support.v4.app.INotificationSideChannel$Stub$Proxy, sources=[Unknown source file], tool name=Optional.of(D8)}
This is my gradle script:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-P'
defaultConfig {
applicationId "it.smart.bab3"
minSdkVersion 21
targetSdkVersion 'p'
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:28.0.0-alpha1'
implementation 'com.google.android.material:material:1.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.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.android.support:design:28.0.0-alpha1'
implementation 'com.android.support:support-v4:28.0.0-alpha1'
}
I'm new ith this type of errors, and i didn't find anithing with this error. Thanks
I've been struggling all day with this issue too. Finally I managed to compile and run the project successfully.
First of all, get rid of this:
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:design:28.0.0-alpha1'
implementation 'com.android.support:support-v4:28.0.0-alpha1'
Add the following in your gradle.properties file:
android.useAndroidX = true
android.enableJetifier = false
And finally, sync the project and then compile.
If it doesn't work, clean the project and then rebuild.
PS: I can't get targetSdkVersion 'p' to work. My build.gradle file end up as follows:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-P'
defaultConfig {
applicationId "com.github.alvarosct02.demo"
minSdkVersion 19
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 'com.google.android.material:material:1.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.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'
}
Hope it works for you too.
I wasted 2 days looking for a solution. Anyone who's still looking for a solution can follow the steps below:
Update your Android Studio to the latest version.
Update your compileSdkVersion and targetSdkVersion to 28.
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.your.appid"
minSdkVersion 19
targetSdkVersion 28
versionCode 50
versionName "1.50"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
setProperty("archivesBaseName", "your-app-$versionName")
resConfigs "en"
}
}
Go to your project structure and change your gradle version to 4.10.
Add this dependency first:
implementation 'com.google.android.material:material:1.0.0'
Now remove all the support library dependencies:
implementation "com.android.support:design:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:support-v4:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:cardview-v7:$SUPPORT_LIBRARY_VERSION"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:multidex:1.0.3'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
androidTestImplementation('com.android.support.test.espresso:espresso-
core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.google.code.findbugs', module: 'jsr305'
})
Now paste the following into your gradle.properties file:
android.useAndroidX = true
android.enableJetifier = true
In your project level build.gradle file:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.google.gms:google-services:4.1.0'
};
For those who are using Butterknife add below lines in your project level build.gradle file:
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://dl.bintray.com/drummer-aidan/maven/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
}
And in your module build.gradle file add below dependencies:
implementation "com.jakewharton:butterknife:9.0.0-SNAPSHOT"
annotationProcessor "com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT"
Now Goto Build > Rebuild Project then you might be getting a lot of errors.
Now refer this link.
It has the list of all the old (android.support) vs new (androidx.*) dependencies.
Replace all your old imports with the new ones(Use replaceAll feature of android studio [ctrl + shift + R] which will save you some time).
Finally After refactoring all the old libraries with the new ones:Rebuild the project again and hopefully it should work.
Note: You can also use Refactor > Migrate to androidx in android studio but it didn't work for me.
I started getting this error after upgrading the ButterKnife to the version 8.8.1.
So, I run the command gradle -q dependencies to generate a dependency report, after that you should see where D8 is coming from. In my case from the "ButterKnife" library:
+--- com.jakewharton:butterknife:8.8.1
| | \--- com.android.support:support-compat:d8
Also you can see your android dependencies by going to your Android Studio Gradle view (In Android Studio tool bar navigate to "View/Tool Windows/Gradle"), and selecting the target "androidDependencies" under "My-Project-Name/Tasks/android" (Double click to run or Right click and run).
To solve this problem I added this piece of code exclude module: 'support-compat' to my "app/build.gradle" as below:
implementation ('com.jakewharton:butterknife:8.8.1') {
exclude module: 'support-compat'
}
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
Hope it works for someone else :] Cheers!
Android Studio v3.2+ resolves this issue. It also adds a "Migrate to AndroidX" item under the Refactor menu. No work-around or rollback required.
Update Android Studio from the beta channel to use 3.2+ or wait until a stable version is released.
EDIT: Android Studio v3.2 is now in the stable channel. It is important you no longer use the support libraries and migrate to AndroidX libraries because support for the old support libraries has ended.
If you are including a library that has a transitive dependency on the Android support library you also have to use the jetifier feature that is part of the Android Gradle plugin version 3.2.0-alpha14 or higher. You can determine if you have a library that depends on the support library by running your Gradle dependencies task.
From the Android Developer's blog post (https://android-developers.googleblog.com/2018/05/hello-world-androidx.html):
If you depend on a library that references the older Support Library,
Android Studio will update that library to reference androidx instead
via dependency translation. Dependency translation is automatically
applied by the Android Gradle Plugin 3.2.0-alpha14, which rewrites
bytecode and resources of JAR and AAR dependencies (and transitive
dependencies) to reference the new androidx-packaged classes and
artifacts. We will also provide a standalone translation tool as a
JAR.
In your gradle.properties file make sure that you have:
android.enableJetifier=true
android.useAndroidX=true
I had this issue with Leak Canary on a small project and it was solved by upgrading the Android Gradle plugin to the appropriate version. https://github.com/square/leakcanary/issues/1103
Go to app/build.gradle, in dependencies, remove this line:
implementation "com.android.support:appcompat-v7
Try to add
android.enableD8 = false
to gradle.properties file.
If you want to use
com.android.support:support-v4:28.0.0-alpha1,
then you have to use
com.android.support:design:28.0.0-alpha1
instead of
com.google.android.material:material:1.0.0-alpha1.
Use this
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 28
defaultConfig {
applicationId "ir.uncode.newdesign"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguardrules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support:cardview-v7:28.0.0-alpha3'
implementation 'com.android.support:design:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
implementation 'com.android.support:animated-vector-drawable:28.0.0-alpha3'}
repositories {
mavenCentral()
}
and If the problem persists change "import" on class and xml.
like :
import androidx.fragment.app.Fragment;
import android.support.v4.app.Fragment;
or
import androidx.core.app.ActivityCompat;
import android.support.v4.app.ActivityCompat;
or
com.google.android.material.bottomappbar.BottomAppBar
android.support.design.bottomappbar.BottomAppBar
If you are using Android Studio V. 3.2.1 , You can simply go to the tools bar open Refactor -> migrate to AndroidX and Android studio will take care of the rest.
I am using android studio 3.3 version. I wasted my one and a half day looking for this solution. I tried all the answer in this post but nothing helped. Then I find the link which helped me to solve the error.
I removed the below dependency I added,
implemntation 'com.google.android.material:material:1.0.0'
Instead, I used android design support library,
implementation 'com.android.support:design:27.1.1'
try setting android.enableJetifier=true and android.useAndroidX=true
in your gradle.properties file.
If you have 3.1.0 change to 3.2.0:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
}
You need to move to androidx
Remove all the imports which start with
import android.support.*
Change All imports to import androix.* and corresponding components.