80

i have react native porject when run android this error showed

Build file 'C:\dev\icnet_final\android\app\build.gradle' line: 213

A problem occurred evaluating project ':app'.

Could not get unknown property 'compile' for configuration container of type org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer.

0

7 Answers 7

183

If this happens after Gradle upgrade, replace compile with implementation

Sign up to request clarification or add additional context in comments.

11 Comments

Note that this must also be done for the line with BUCK configuration, i.e. changing configurations.compile to configurations.implementation!
it should be runtimeClasspath and not implementation.
about configurations.implementation: Resolving dependency configuration 'implementation' is not allowed as it is defined as 'canBeResolved=false'.
where do i change compile to implementation ?
@joaoricardotg it's in app/build.gradle in the copyDownloadableDepsToLibs task
|
34

I got this error because I upgraded to the latest version of Gradle. I suggest not doing this yet, until React Native has been updated to work with it.

I changed my version of Gradle in android/build.gradle to the old version and the project built again. This version now works for me:

    classpath('com.android.tools.build:gradle:4.2.2')

5 Comments

saved my day.. it should be most accepted answer
So downgrading from gradle 7 to 4 is an acceptable answer :(
@mikegross - same here, I reverted my 4.2.1 => 7.0.3 upgrade down to just 4.2.1 => 4.2.2. It was much less painful.
After a night of digging, here you saved my life, thanks!
Remember: if something wrong or weird -- use expo eject.
20

go to /Users/...../Documents/projectName/android/app/build.gradle

and

replace compile with implementation

configurations.compile => configurations.implementation

Comments

6

Assuming that the gradle task is trying to compile some java code, you have to replace configurations.compile with configurations.compileClasspath. It points out to the list of dependencies that the JDK requires to compile the java code.

This exception is being thrown from gradle 7+ which does not recognize the property 'compile' any more as it requires the use of 'implementation' or 'api' according to the case.

If the .class files are already available, configurations.runtimeClasspath should also work, as it points out to the already compiled java code.

Comments

3

I had to modify the app/build.gradle file by updating the code below

from configurations.compile

to

from configurations.implementation

Comments

1

RN 0.64.1 For the dependence, I use

    classpath('com.android.tools.build:gradle:7.0.0')

and for the wrapper

    distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip

Comments

0

Need to verify the version of "@react-native-community/cli-platform-android" in the bundle. Look for the version for example: "@react-native-community/cli-platform-android" : ^4.10.0

Remove the ^ from the version install manually using npm or yarn

yarn add react-native-community/[email protected]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.