I have a problem with my Flutter application, when I used ./gradlew build I got this error message:
Error: Class referenced in the manifest, com.example.pet_store.${applicationName}, was not found in the project or the libraries [MissingClass]
android:name="${applicationName}"
~~~~~~~~~~~~~~~~~~
I used both Android Studio and VSCode. Also Invalidate Cache/Restart didn't work for me.
My gradle version is 6.7.1
Running ./gradlew build --debug gives me this error message
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
How can I solve this?
I downgraded my gradle to 6.6.1 and added these lines to /android/app/build.gradle file:
android{
//...
lintOptions {
abortOnError false
}
}
Then flutter clean, flutter run, ./gradlew clean and finally ./gradlew build
everything works fine.
Following is the build.gradle code in Android Studio
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.sg.blahblah"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
lintOptions {
checkReleaseBuilds true
abortOnError false
xmlReport true
htmlReport true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
lintOptions {
disable 'MissingTranslation'
}
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.google.android.apps.dashclock:dashclock-api:+'
compile 'com.roughike:bottom-bar:1.4.0.1'
compile 'com.diogobernardino:williamchart:2.2'
}
I am getting the below error:
Error:A problem occurred configuring project ':app'.
Failed to notify project evaluation listener.
com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependencyCacheDir(Ljava/io/File;)V
Can anyone please help?
Following is the Instant Run screenshot
I got this problem too. I fix it by Change build.gradle in project
Change
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
And also I change the distributionUrl in gradle-wrapper.properties(Global Version)
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-milestone-1-all.zip
And got succeed.FYI.
I am facing same error before a week I solve by disabling the Instant Run
File → Settings → Build, Execution, Deployment → Instant Run and
uncheck Enable Instant Run.
Hope it works.
Note This answer works on below Android Studio 3
you need check your gradle version. gradle -v
then you should know your gradle version and your gradle plugin version compatible.
Example:
gradle 4.6 is not compatible with gradle plugin 2.2.
so need update com.android.tools.build:gradle version to 2.3.3.
then you need check gradle/wrapper/gradle-wrapper.properties distributionUrl gradle version
google Android Plugin for Gradle Release Notes
on the other hand
using newer plugin version might require to update Android Studio
thanks #antek
I also encountered this error when updating to 'com.android.tools.build:gradle:3.0.0'
To fix it, I had to add the google() repo to both the buildscript and module repositories. The documentation here only mentions adding to to the buildscript.
Project-level build.gradle
buildscript {
repositories {
...
// You need to add the following repository to download the
// new plugin.
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
App-level build.gradle
repositories {
...
// Documentation doesn't specify this, but it must be added here
google()
}
gradle-wrapper.properties
...
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
had similar problem, issue was different versions of included library. to find out what causes problem run build command with stacktrace
./gradlew build --stacktrace
In my case, i got wifi problem. make sure you have valid internet connection
In my case I solved this error only by Invalidating caches.
File > Invalidate caches / Restart
This is neither an exact answer to the question nor a silver bullet.
However, if nothing works for you e.g. Invalidate cache & restart, Checking build dependency, Disabling Instant Run (I never advise that) etc.
Add command-line option --stacktrace in Setting > Build, Execution, Deployment > Compiler
Now build/assemble gradle once again. You will have detailed information about the cause. e.g. in my case:
Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException:
Could not find com.squareup.okhttp3:logging-interceptor:3.9.1Net.
I have misspelled the dependency name in module level gradle file. Hope that help
The problem is probably you're using a Gradle version rather than 3.
go to gradle/wrapper/gradle-wrapper.properties and change the last line to this:
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
For those of you working on a team:
I pulled down some changes that included updating the build tools version, but I had not downloaded that new version of the build tools on my machine. Downloading the new version fixed this issue for me
For me, this issue arose due to an incompatible combination of plugin and gradle.
I added these to the code to have it working:
Main build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
Main gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Usually it depends on Instant run or Gradle, but I tried both variants and nothing helped me. Then I looked through idea.log and saw this error
Caused by: java.lang.RuntimeException: A conflict was found between the
following modules:
- com.android.support:support-core-utils:25.3.1
- com.android.support:support-core-utils:27.0.1
I really don't know why this error is not shown in Gradle Console or Event Log tab. Then I fixed it by adding some code to the end of android{} block.
configurations.all {
resolutionStrategy {
failOnVersionConflict()
eachDependency { DependencyResolveDetails details ->
if (details.requested.name == 'support-core-utils') {
details.useVersion '25.3.1'//Or you can use 27.0.1 if it does not conflict with your other dependencies
}
}
}
I had this issue because I was using Charles proxy on my computer and the SSL was enabled for all hosts. And since AS didn't trust my proxy, the network request failed.
So I had to disable SSL for all hosts and restart my Android Studio.
In my case I have changed version of Kotlin plugin in gradle file related to module but hadn't change it in root gradle file.
It is interesting but as for me help this:
File -> Setting -> Gradle -> disable offline work
I have met the similar problem.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
> org.gradle.api.tasks.compile.CompileOptions.setBootClasspath(Ljava/lang/String;)V
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.0-milestone-1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 7s
Build step 'Invoke Gradle script' changed build result to FAILURE
Build step 'Invoke Gradle script' marked build as failure
Finished: FAILURE
The key is you need to get a way to solve this kind of problems,not to
solve this problem.
According to the log above,the most important information is:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.
Most of the building problems of Gradle will be solved because when you use the specific Gradle build command,you can get more detailed and useful information that are clear.
*clean project
./gradlew clean
*build project
./gradlew build
*build for debug package
./gradlew assembleDebug or ./gradlew aD
*build for release package
./gradlew assembleRelease or ./gradlew aR
*build for release package and install
./gradlew installRelease or ./gradlew iR Release
*build for debug package and install
./gradlew installDebug or ./gradlew iD Debug
*uninstall release package
./gradlew uninstallRelease or ./gradlew uR
*uninstall debug package
./gradlew uninstallDebug or ./gradlew uD
*all the above command + "--info" or "--debug" or "--scan" or "--stacktrace" can get more detail information.
And then I found the problem is related with the version of Gradle,when I have changed Gradle from 5.0 to 4.1,and then it's OK.
For me I had to specifically stop the gradlew and clear caches and this fixed my issues:
./gradlew --stop
// Delete all cache files in your project. With git: `git -xfd clean`
// Delete global cache dir. On Mac it is located in `~/.gradle/caches
Found here:
https://github.com/realm/realm-java/issues/5650#issuecomment-355011135
I've resolved this issue by cleaning all the Gradle cache, stoping the Gradle Daemon process, and created a new build successfully using the following command. Make sure your current directory is android.
rm -rf ~/.gradle/caches && ./gradlew --stop && ./gradlew cleanBuildCache && ./gradlew bundleRelease
I'm using React Native. So I've added following in my scripts in package.json,
"build-android": "rm -rf ~/.gradle/caches && cd android && ./gradlew --stop && ./gradlew cleanBuildCache && ./gradlew bundleRelease && cd ..",
Changing the below line in your gradle.build helps.
classpath 'com.android.tools.build:gradle:4.2.2'
With the new google support gradle plugin (com.google.gms.google-services) this can be caused by some dependency version problems with your com.google.android.gms.* modules.
You can probably see the root cause by running the build command with the --stacktrace parameter. i.e.:
./gradlew :app:dependencies --stacktrace
which might output the cause of the problem:
Caused by: org.gradle.api.GradleException:
The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.2,15.0.2],
[16.0.0,16.0.0]], but resolves to 16.0.0. Disable the plugin and check
your dependencies tree using ./gradlew :app:dependencies.
at com.google.gms.googleservices.GoogleServicesPlugin$1$_afterResolve_closure1.doCall(GoogleServicesPlugin.groovy:328)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:71)
Just Change the Distribution url at gradle-wrapper.properties
Place it : https://services.gradle.org/distributions/gradle-4.10.1-all.zip
I ignored using JDK13 with Android Studio, So I selected below settings and it was solved:
Step 1. (File > Other Settings > Default Project Structure > SDK Location > JDK Location)
Embedded JDK
Step 2. (File > Project Structure > Project)
gradle plugin 3.6.3
gradle 5.6.4
I had buildToolsVersion "27.0.1", upgrading it to 27.0.2 fixed the issue.
Also, my android support deps were at version 27.0.2 so they were not aligned to the buildToolsVersion
The only thing that helped me was to use the system gradle instead of Android Studio's built-in:
SETTINGS -> Build, Execution, Deployment -> Gradle
Select Use local gradle distribution. To find the path, you can do which gradle where the which program is supported. It might be /usr/bin/gradle.
See also Error:Could not initialize class com.android.sdklib.repositoryv2.AndroidSdkHandler for another possible cause.
SETTINGS -> Build, Execution, Deployment -> Gradle -> unselect Offline work
Then sync project, you are good to go.
If not working , then File > Invalidate caches / Restart - > Invalidate and Restart.
In my case, I was missing the target SDK platform installed. I remember this error was straightforward and prompted you to install it automatically. Worth checking that as well.
First Step:File → Settings → Build, Execution, Deployment → Instant Run and uncheck Enable Instant Run.
Second step: Press Invalidate/Restart.
done.... Enjoy.
In my case, I had to do -
File -> Sync Project with Gradle Files
In my case I had to update all the Firebase libraries to the latest versions.
I think u have to change compile by implementation first, then maybe the problem is your android version, it is not compatible with your code, so update it.
And Good luck
I was just trying to compile my app with the new preview SDK 24 Android N in Android Studio 2.1 Preview 1.
I have in app billing in my app.
When trying to build the app I get the following exception
aidl.exe E 6416 3312 io_delegate.cpp:102] Error while creating directories: Invalid argument
Error:Execution failed for task ':app:compileDebugAidl'.
> java.lang.RuntimeException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Gebruiker\AppData\Local\Android\Sdk\build-tools\24.0.0-preview\aidl.exe'' finished with non-zero exit value 1
I already tried to use the latest IInAppBillingService.aidl but I still get the same error. When I remove the IInAppBillingService.aidl file the project compiles fine.
Here's a part of my build gradle
compileSdkVersion 'android-N'
buildToolsVersion "24.0.0 rc1"
defaultConfig {
applicationId "xxx.myapp"
minSdkVersion 14
targetSdkVersion 'N'
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
The IInAppBillingService.aidl file is in the following folder
src/main/aidl/com/android/vending/billing
How to fix this?
I think you have to change below points
minSdkVersion 'N' and compileSdkVersion 'android-N'
update your JAVA JDK to 1.8
android {
...
defaultConfig {
...
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
I had updated to the latest Android Studio 2.0 Beta 6 and had also updated the Settings to support Instant Run due to warning about gradle version not correct. This changed all my buildToolsVersion settings to 24 RC 1. That started causing the aidl error described in this bug report. I had to go back to buildToolsVersion 23.0.2 to be able to compile and run.
Got exactly the same problem with our InApp stuff and IInAppBillingService.aidl and after spending some time on it, and looking through the unsolved google issue tracker thread, found (at least temporarily) solution that allows me to compile the project with the latest stuff under Android N.
It surely is not quite legit, and after Google fixes whatever they need to, it shall be reverted, but in short - it is to replace the aidl.exe from the current beta Build Tools 24.0.0 rc2 with the aidl.exe from the currently stable one 23.1 - voila the "Invalid argument" error is gone :)
Firstly,the most important step is that you need to get more detail information about the error.
You can use one of the the following Gradle commands to get more details.
gradlew assembleDebug
gradlew assembleDebug --info
gradlew assembleDebug --debug
gradlew assembleDebug --scan
gradlew assembleDebug --stacktrace
I have met the similar situation with the environment:
macOS 10.14.2
Android Studio 3.3
The more detail information is:
ifeegoo:AIDLClient ifeegoo$ ./gradlew assembleDebug
Welcome to Gradle 4.10.1!
Here are the highlights of this release:
- Incremental Java compilation by default
- Periodic Gradle caches cleanup
- Gradle Kotlin DSL 1.0-RC6
- Nested included builds
- SNAPSHOT plugin versions in the `plugins {}` block
For more details see https://docs.gradle.org/4.10.1/release-notes.html
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
> Configure project :app
WARNING: The specified Android SDK Build Tools version (28.0.1) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.3.0.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '28.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
> Task :app:compileDebugAidl FAILED
/Users/ifeegoo/Desktop/AIDL/AIDLClient/app/src/main/aidl/com/xb/test/IRomteAidlInterface.aidl:6: couldn't find import for class com.xb.test.IClientAidlInterface
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugAidl'.
> java.io.IOException: com.android.ide.common.process.ProcessException: Error while executing process /Users/ifeegoo/Library/Android/sdk/build-tools/28.0.3/aidl with arguments {-p/Users/ifeegoo/Library/Android/sdk/platforms/android-27/framework.aidl -o/Users/ifeegoo/Desktop/AIDL/AIDLClient/app/build/generated/aidl_source_output_dir/debug/compileDebugAidl/out -I/Users/ifeegoo/Desktop/AIDL/AIDLClient/app/src/main/aidl -I/Users/ifeegoo/Desktop/AIDL/AIDLClient/app/src/debug/aidl -I/Users/ifeegoo/.gradle/caches/transforms-1/files-1.1/support-compat-27.1.1.aar/5625261fa2f53d5e15ed7248754bde52/aidl -d/var/folders/vl/nvypcrfj25n20fhnmtl0t5p40000gn/T/aidl37267774351421868.d /Users/ifeegoo/Desktop/AIDL/AIDLClient/app/src/main/aidl/com/xb/test/IRomteAidlInterface.aidl}
* 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.
* Get more help at https://help.gradle.org
BUILD FAILED in 6s
2 actionable tasks: 1 executed, 1 up-to-date
So the most important detail information is after FAILED
/Users/ifeegoo/Desktop/AIDL/AIDLClient/app/src/main/aidl/com/xb/test/IRomteAidlInterface.aidl:6: couldn't find import for class com.xb.test.IClientAidlInterface
Finally,I found that there is somethings wrong with my AIDL file location.
It seems like without any reason the Gradle refuses to build the project in Android Studio. I haven't change anything in the configurations and I can't find any reason of this error. The output is the following
Error:A problem occurred configuring project ':app'.
java.lang.ClassFormatError: Incompatible magic value 931269604 in class file build_f63dreec96sk8elmstb53lfie
No any Android library is recognized. So maybe there might be some problems with sdk but I have checked the dependencies and the path was set correctly. Here is a screenshot of my build.gradle.
I have already tried
1) rebuilding and cleaning the project.
2) File -> invalidate caches and restart
Are there any other ideas about fixing this problem. Thanks in advance
For anyone who finds this in future.
I had this issue and resolved it by typing:
gradlew --recompile-scripts
The problem was that Gradle had a precompiled build script from a previous version of Java. The .class file for that script was invalid, hence the error. You need to recompile that script.
Basically, you have a project or module that was compiled using a source JRE version less than a dependency.
Try the following
sourceCompatibility = 1.6
targetCompatibility = 1.6
More information is here
Gradle sourceCompatibility has no effect to subprojects
I am trying to run a simple 'hello world' android app with gradle build. It builds fine if I issue the command
sudo ./gradlew build --> builds fine
But without sudo,
./gradlew build --> shows following error
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':MyStudioApplication'.
> Failed to notify project evaluation listener.
> Could not resolve all dependencies for configuration ':MyStudioApplication:_DebugCompile'.
> Could not find any version that matches com.android.support:appcompat-v7:+.
Required by:
workspace:MyStudioApplication:unspecified
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 12.621 secs
following is my build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 19
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
}
Please help
Taking a shot in the dark here, you may have run your initial gradle build with sudo which may have caused the artifacts to be downloaded and permisionned to root and are not accessible to your regular user. To test this assumption you may want to rename your local repository where gradle downloads the dependencies and rerun gradle as the standard user.
if you get the similar "cannot resolve symbol" appcompatactivity but running as sudo resolves things, try deleting the .AndroidStudio folder in your /home directory
This started happening to me after cleaning/building with sudo.
What worked for me was:
sudo ./gradlew clean
File -> Invalidate caches (check clear file system..., and restart)
delete manually one of the build folders, it was a multi-module project, and for some reason that module wasn't been deleted