Android studio missing classes.
The layout is blank.
Main.Activity is red letters.
[Soultion in the answer area]
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
add this line under dependencies in your build.gradle file
If Android Studio is not identifying the project as Gradle based, it means you imported the project source code from wrong directory. Try to reimport the project from a directory where you have see build.gradle file.
Follow these steps Add ConstraintLayout to your project
Or if you are using AndroidX
You need to use different build artifacts
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
Refer here for AndroidX Migrating to AndroidX
My Solution:
First,I delete Android Studio,and then Download Android Studio(include emulator and SDK) again.
Second,I change the name of my homework.
Third,I choose "Open an existing Android project".
Forth, Gradle Scripts->build.gradle->
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
}
replace
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
Done.
Related
I recently updated my Android Studio (and I'm pretty sure the Gradle version), and now I've been getting a bunch of errors when trying to compile my project. Here's the one that is plaguing me at the moment:
Duplicate class android.support.v4.app.INotificationSideChannel found in modules classes.jar (androidx.core:core:1.0.1) and classes.jar (com.android.support:support-compat:26.1.0)
This is followed by lots of similar ones.
I tried removing all uses of com.android.support in favor of androidx (see here for what I was using the replace things), but com.android.support libraries are still being used, even when I delete the libraries (they're just remade once I try to compile again).
Here's a link to the full error I get.
Add these lines to your gradle.properties
android.useAndroidX=true
android.enableJetifier=true
If gradle.properties is absent, create the file in the root directory of your project.
It looks like you have some support relics anywhere in your dependencies, maybe from a lib? To investigate and see the dependencies tree, please run:
./gradlew :yourApp:dependencies
and then you see from where it comes.
In your app build.gradle you are using a mix of old support library and new support library artifacts. Remove one of them from your build.gradle to resolve this issue.
Old artifact: com.android.support:support-compat
Corresponding new artifact: androidx.core:core:1.0.0
See this page for more information on migrating to AndroidX.
Like others says, the solution is to migrating to AndroidX, it works for me. However, it isn´t an easy way and it requires a bit of pacience... These are the steps that I did:
First, is very important that you do all this changes in a different branch or you make a backup of your project.
You need to have the Android Gradle Plugin Version 3.5.1. So, in build.gradle set:
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
}
Migrate to AndroidX using Android Studio Tool : Refactor --> Migrate to AndroidX...
When it finishes, it has done all pertinents modification, but posibly you can´t deploy the project correctly because you find any errors. These are the problems that I found and the solutions:
If you use Kotlin, in build.gradle set:
buildscript {
ext.kotlin_version = '1.3.10'
}
and
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
If you use destination method, add "file" parameter: destination file("$reportsDir/checkstyle/checkstyle.xml")
If you use Butterknife, use 10.0.0 version
Finally, Build --> Clean Project and Build --> Rebuild Project
This solution from here worked the best for me. Migrating to androidX
https://developer.android.com/jetpack/androidx/migrate
With Android Studio 3.2 and higher, you can migrate an existing
project to AndroidX by selecting Refactor > Migrate to AndroidX from
the menu bar.
The refactor command makes use of two flags. By default, both of them
are set to true in your gradle.properties file:
android.useAndroidX=true The Android plugin uses the appropriate
AndroidX library instead of a Support Library.
android.enableJetifier=true The Android plugin automatically migrates
existing third-party libraries to use AndroidX by rewriting their
binaries.
If you face any issue regarding duplicate classes after using Facebook mediation and google ad libraries so follow these steps:
1- Add this in build.gradle(Module) in Top
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.gms.google-services'
2- Add this in build.gradle(Module) -> android
packagingOptions {
exclude "META-INF/DEPENDENCIES"
}
3- Add this in build.gradle(Module) -> dependencies
//firebase bom
implementation platform('com.google.firebase:firebase-bom:29.2.0')
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-messaging:23.0.1'
//ADS
def ads_version = "20.6.0"
implementation "com.google.android.gms:play-services-ads:$ads_version"
//facebook ads
implementation 'com.google.ads.mediation:facebook:6.8.0.0'
4- Add this in build.gradle(Project )-> buildscript-> dependencies
classpath "com.android.tools.build:gradle:7.0.4"
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
5- Add this in gradle.wrapper.propertise
#Wed Dec 16 15:32:03 PKT 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-7.0.2-bin.zip
Problem :
Error:Could not find com.android.support.constraint:constraint-layout:1.0.0-alpha2.
Required by:
myapp:app:unspecified
Background :
Android Studio 2.2 P 1
Support libraries for ConstraintLayout could not be installed/updated.
Just open Preferences > Appearance & Behavior > System Settings > Android and move to SDK Tools tab. Check the following fields and install.
In my case, that support libraries for ConstraintLayout were installed, but I was adding the incorrect version of ConstraintLayout Library in my build.gradle file. In order to see what version have you installed, go to Preferences > Appearance & Behavior > System Settings > Android SDK. Now, click on SDK Tools tab in right pane. Check Show Package Details and take note of the version.
Finally you can add the correct version in the build.gradle file
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9'
testCompile 'junit:junit:4.12'
}
The fix is to update the android gradle plugin in your build.gradle.
This should work:
classpath 'com.android.tools.build:gradle:2.2.0-alpha2'
Or you can use the latest:
classpath 'com.android.tools.build:gradle:2.2.0-alpha3'
My problem was, that the SDK Tools updated it to the latest version, in my case it was 1.0.0-alpha9, but in my gradle dependency was set to
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha8'
So, you can change your gradle build file to
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9'
Or you check "Show package details" in the SDK Tools Editor and install your needed version. See screenshow below. Image of SDK Tools
Ensure you have the maven.google.com repository declared in your module-level build.gradle file
repositories {
maven {
url 'https://maven.google.com'
}
}
2.Add the library as a dependency in the same build.gradle file:
dependencies {
compile 'com.android.support.constraint:constraint-layout:1.0.2'
}
I updated my android gradle plugin to 2.2.0-alpha4 and constraint layout dependency to 1.0.0-alpha3 and it seems to be working now
First I tried everything that I have read on stackoverflow...from updating gradle to XY version, to updating ConstraintLayout to XY version...I even update my SDK tools and Android Studio to the latest version...but nothing was working.
The only solution that worked for me was that I delete ConstraintLayout library from gradle and SDK, then I opened random xml layout and in Design view under Palette section search for ConstraintLayout. If you have successfully deleted library from your project then you will be able to install the library from there if you double clicked on ConstraintLayout element.
That has create next line in my app build.gradle:
'com.android.support.constraint:constraint-layout:1.0.0-beta1'
In my project build.gradle I have this:
classpath 'com.android.tools.build:gradle:2.2.2'
Android studio version 2.2.2
Alpha version is no longer available !
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
Just to make sure that in studio version 2.3 you won't see a dropdown near constraint-layout in sdk tools, it will by default install the latest version
To get the desired version check the box saying show package details and boom you can now choose the desired version you want to install
gradle com.android.tools.build:gradle:2.2.0-alpha6
constraint layout dependency com.android.support.constraint:constraint-layout:1.0.0-alpha4
works for me
For me it was a completely different issue. When I installed constraint dependancy in SDK tools, the tools somehow wrote them into the wrong directory. That is
/home/${USER}/Android/Sdk/extras/+m2repository+/com/.../constraint
instead of
/home/${USER}/Android/Sdk/extras/+android+/+m2repository+/com/.../constraint
Remedy:
Just copy the 1.0.0-alpha* directories into the latter path
While updating SDK tools, a dilog box presented with Constraint layout version that is going to get installed. Note that and update your dependency based on that. In my case it was installing beta3.
I changed my dependency like below. After that it worked.
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta3'
In my case, I had to remove the previous versions first and download the latest one instead. v1.0 stable was released on Feb 23rd.
In my case, I had a multi-module project called "app" and "sdk". The "sdk" module is the one where I had added the constraint layout library. I got the error when I tried to incorporate "sdk" into a new multi-module project called "app2". The solution was to ensure I had added the Google Maven Repository to the project-level build.gradle file for "app2". The Google Maven Repository can be added by putting "google()" under allprojects.repositories in the project-level build.gradle file:
allprojects {
repositories {
jcenter()
google()
}
}
In my case, I was using AS 2.3 and I wanted to use the currently latest ConstraintLayout 1.1.3, but the latest version in my Preferences > Appearance & Behavior > System Settings > Android was 1.0.2.
To use ConstraintLayout 1.1.3, I updated my AS from 2.3 to currently latest 3.2.1, com.android.tools.build:gradle from 2.2.2 to 3.2.1, gradle from 3.3 to 4.6 and buildToolsVersion from 25.0.0 to 28.0.3.
I also added maven { url 'https://maven.google.com' } to the Maven repositories in the project-level build.gradle file and that solved my problem.
Just as a heads up to those still searching for this.
ConstraintLayout 1.0.1 and lower have been deprecated by maven.
For a list of available constraint layouts that can be downloaded, see below:
https://maven.google.com/web/index.html?q=Constrain#com.android.support.constraint:constraint-layout
The easiest solution at the moment, is to change
implementation 'com.android.support.constraint:constraint-layout:1.0.0-beta1'
to
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
I used com.android.support.constraint:constraint-layout:1.0.0-alpha2 with classpath 'com.android.tools.build:gradle:2.1.0', it worked like charm.
Not sure if I'm too late, but in case someone has still the error after an update of ConstraintLayout and Solver over the SDK Tools, maybe this solution could help: Error:(30, 13) Failed to resolve: com.android.support.constraint:constraint-layout:1.0.0-alpha4
Its available in androidx as following package
implementation "androidx.constraintlayout:constraintlayout:2.0.0-alpha1"
Update your constraint layout dependency to the relevant version from '1.0.0-alpha2'. In my case, I changed to the following.
compile 'com.android.support.constraint:constraint-layout:2.0.0-alpha5'
I added the following script in build.gradle(app) under android & I was able to compile.
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
Similar issue solved by Reinstalling Android Studio.
i'm try constraint layout dependency update available 1,and plugin gradle alpha-6,it worked
I am new to android studio. I know how to work in eclipse. I downloaded the sweet alert library for Android from here.
But I am unable to import it because of lack of experience in android studio. Can anyone guide me to import it step by step? I don't even know what a maven/gradle is and how to add as AAR dependency, as mentioned on the website.
Add the following lines to your build.gradle file:
repositories {
mavenCentral()
}
dependencies {
compile 'cn.pedant.sweetalert:library:1.3'
}
The first block makes gradle aware of the maven repository. The second block is shorthand for including the library in the "compile" build step.
Further I sugest that you read the gradle docs here: Gradle plugin user guide
If you are importing Library which is gradle supported then you have to write only one line in your Gradle dependencies
sweet-alert-dialog library is Gradle Supported so you the thing you have to do is open Gradle
dependencies {
compile 'cn.pedant.sweetalert:library:1.3' //add this line
}
download the sweet alert library
In android studio [File] --> [New] -->[Import Module].
Now select the directory where you downloaded sweet alert library.
inside sweet alert library folder select library folder and the click ok.
Now go to your build.gradle(app) in your project and add this line
compile project(":library") into
dependencies {
...
...
...
compile project(":library")
}
I recently downloaded the ViewPagerIndicator library and imported it into android studio. After adding it to my project I get a rendering error "The following classes could not be found:" and points to com.viewpagerindicator.IconPageIndicator.
The steps I took were Files->Import Module->'library name', Project Structure -> Dependencies -> + the imported module. Then to my layout xml file I added the <com.viewpagerindicator.IconPageIndicator />, after that I got the missing class problem.
It compiles just fine and I went through all of the build.gradle and settings.gradle files and compared them to what they should be online.
MyApp->build.gradle has compile project(':library') under dependencies
settings.gradle has include ':library' with no build errors.
First of all, you must import your library project by following that path:
File --> New --> Import Module
After you have imported the library project successfully, you must check your build.gradle file inside your project's folder if the following line is present at the "dependencies" section:
implementation project(':NameOfTheLibProject')
Then your project must be built successfully.
I found that my issue was the Android Plugin Version under Project Structure --> Project was different to the version my plugins all used. Once I aligned them to the same version, I could see all my classes from my imported module.
Took me hours :(
I had the same problem. I just did: Invalidate / Restart ..
I too had trouble importing module as it was not appearing in list of modules. And way it worked for me is manually entering it in settings.gradle this way:
include ':app', 'module_name'
And in build.gradle
compile project(':module_name')
In my case, I did add in app gradle:
// Nearly deprecated.
compile project(':NameOfTheLibProject')
// Or
implementation project(':NameOfTheLibProject')
but it only works when I change
compileSdkVersion
minSdkVersion
targetSdkVersion
in app and the other modules are the same.
The following solution worked for me,just two steps.
Go to your project structure on android studio, select project from left side.Change Android plugin version to Gradle version press ok.
If error occurs after synchronization again go to project structure and select project.undo the android plugin version like before.Gradle will align the library and make the class visible to XML files.
The issue in my case was different compile and target SDK version,
mentioned in my main app module and your added lib module.
Once I matched both of them it worked perfectly.
So just open build.gradle file of app-level and lib module-level check for the SDK version.
settings.gradle
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation project(':wheel') // "Wheel" - you're project path name
}
In case you just changed the name of your project in the pubspec.yaml File, make sure to change the import names as well, because they will stay the same and therefore wont find the new named directory.
Ex. change this to :
import 'package:previousName/backend/connector/userConnector.dart';
to this:
import 'package:newName/backend/connector/userConnector.dart';
As far as i know, there is no terminal command for that, only find-in-files-replace :(
Question:
How do I find the version of libraries that are being used when my Gradle file mentions a dependency using the '+' operator in the version number of the dependency?
Context
My build.gradle under app module reads like so:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:5.+'
}
What is the version of the play-services library that is being used here?
You can use gradles' build-in 'dependencyInsight' task to query the resolved version of your dependency:
gradle dependencyInsight --configuration compile --dependency com.google.android.gms:play-services
If you want to get an overview for all your dependencies in one go, you can do
gradle dependencies
If you use the gradle wrapper you must use ./gradlew instead of gradle
Look under .idea folder of your project
In the Project Pane on the left, browse to .idea/libraries
All the library dependencies that your project has have been mentioned, with each one getting its own xml file. You can see the version number included in the xml file title. The xml itself has the library file path.
(OR) Use Gradle's built in task to get dependencies
See steps here: https://stackoverflow.com/a/25236208/1311745
Android Gradle Dependency library version
Android Studio 3.1.4
You are able to use Project view
In Android Studio, in the build.graddle app, select the version and press ALT + ENTER, then select "Replace with specifyc version"