Closed rodrigofbm closed 5 years ago
i am also getting this exact same issue with this exact same step by step. i would LOVE to know why this is happening for release builds but not debug builds.
For me this works: add this code in /android/build.gradle
subprojects {
project.configurations.all {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
}
}
}
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "26.0.2"
}
}
}
}
26.0.2 is the vs that I've seted in /android/app/build.gradle file for buildToolsVersion. Give a shoot.
@rodrigofbm, you workaround not works for me =/
* Where:
Build file '/home/felipe/Projects/personal/grioty/android/build.gradle' line: 33
* What went wrong:
A problem occurred configuring project ':app'.
> Android tasks have already been created.
This happens when calling android.applicationVariants,
android.libraryVariants or android.testVariants.
Once these methods are called, it is not possible to
continue configuring the model.
Can you explain what this code are doing? Perhaps I can understand what is happening with my project. Thanks!
@FSPinho try only this:
subprojects {
project.configurations.all {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
}
}
}
}
}
Thanks! But the errors are occurring exactly due to this two lines. compileSdkVersion 26 buildToolsVersion '26.0.2'
Can you send me information about the development environment?
With the terminal open in the project folder: react-native info
Environment:
OS: macOS High Sierra 10.13.4
Node: 6.11.3
Yarn: Not Found
npm: 6.0.1
Watchman: 4.9.0
Xcode: Xcode 9.3.1 Build version 9E501
Android Studio: 3.0 AI-171.4443003
Packages: (wanted => installed)
react: 16.0.0 => 16.0.0
react-native: ^0.55.4 => 0.55.4
for my case, I uses below Gradle v4.4 classpath 'com.android.tools.build:gradle:3.1.1' classpath 'com.google.gms:google-services:3.2.0'
compileSdkVersion = 27 buildToolsVersion = '27.0.3'
So you have to change the code for:
subprojects {
project.configurations.all {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
}
}
}
}
}
About that, I had tried it. still the same error result.
For Gradle v4.4. the minimum compile version seems to be 27.0.3 or 27.1.0 either one.
It just like something linking to this problem after I install react-native-camera latest version. Forced to update to newer version in order to compile. And here it is, this problem show up.
@kkusanagi I have the same problem after installing react-native-camera v1.1.4. Did you solve it?
hi, @pkhien95 . This is how it work for me now by using react-native-camera v0.10.0. About newest version, sorry, still got problem.
Environment: OS: macOS High Sierra 10.13.4 Node: 6.11.3 Yarn: Not Found npm: 6.0.1 Watchman: 4.9.0 Xcode: Xcode 9.3.1 Build version 9E501 Android Studio: 3.0 AI-171.4443003
Packages: (wanted => installed) react: 16.0.0 => 16.0.0 react-native: ^0.51.1 => 0.51.1 react-native-camera: 0.10.0
In android android/gradle/wrapper/gradle-wrapper.properties change this
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
Add below in android/gradle.properties to SOLVE this thread problem TEMPORARILY workaround. Need remove in future before year 2019.
android.enableAapt2=false
Then you may meet another error as duplicate file for drawable-**** png file. As to solve this, goto android/app/src/main/res folder and delete all drawable-** folder only left mipmap-** and values. Also temporarily, please back up deleted folder for IN CASE.
in android/build.gradle, setting like below.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.google.gms:google-services:3.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 27 //do this in android/app/build.gradle too
buildToolsVersion '27.0.3' //do this in android/app/build.gradle too
}
}
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
//maven {
// url 'https://maven.google.com'
//}
google()
}
}
@kkusanagi Thanks. This is my solution for the latest version of react-native-camera (1.1.4):
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "27.1.1"
}
}
}
afterEvaluate {
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
targetSdkVersion 27
}
}
}
}
In my case, none of the above worked, nor was necessary.....
aapt in build tools 23 is a 32bit binary... I'm on a 64 bit system. I didn't have correct 32 bit libs installed so it didn't run.
Installing libncurses5:i386, libstdc++6:i386 and zlib1g:i386 fixed it.
@pkhien95 Your solution works for me, thank you for saving my day.
in android/gradle.properties, setting like below.
android.enableAapt2=false
@Scimanyd your solution work for me . thank for that
@Scimanyd Thanks bro, your solution worked, but what exactly does it do though.
@matt-goingout you are genious, vlws!!! nince
@matt-goingout
In my case, none of the above worked, nor was necessary.....
aapt in build tools 23 is a 32bit binary... I'm on a 64 bit system. I didn't have correct 32 bit libs installed so it didn't run.
Installing libncurses5:i386, libstdc++6:i386 and zlib1g:i386 fixed it.
where and how to install these libraries?
@viv3kk just run sudo apt-get install libncurses5:i386 libstdc++6:i386 zlib1g:i386 in ubuntu
@Scimanyd I feel like it's worth noting that
WARNING: The option 'android.enableAapt2' is deprecated and should not be used anymore. Use 'android.enableAapt2=true' to remove this warning. It will be removed at the end of 2018.
It seems that this will not be a viable option in the long run.
"apt-get install libncurses5:i386 libstdc++6:i386 zlib1g:i386 in ubuntu"
How about MacOS? how to install it?
@pkhien95 i'm also run into the same error, tried your solution, and got this error:
Execution failed for task ':app:preReleaseBuild'.
> Android dependency 'com.android.support:support-v4' has different version for the compile (27.1.0) and runtime (27.1.1) classpath. You should manually set the same version via DependencyResolution
How does your android/build.gradle
and android/app/build.gradle
looks like?
Hey, guys.
I've also got the same issue after upgrade from RN 0.55 to 0.56, then I added this to my android/build.gradle
, and it helped me to generate .apk, but this .apk doesn't work! It just shows the launch screen and then stops...
Does anyone has an idea?
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "27.1.1"
}
}
}
afterEvaluate {
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
targetSdkVersion 27
}
}
}
}
For those who are doing this before generating apk
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
it generate unnecessary drawable images in drawable folder. so make sure to remove it and try again.
android-> app -> src -> main -> res -> drawable
After trying all the above solutions, facing the same issue. A bit digging into the matter and the workaround to build release apk is: Delete your android dir in your root folder.
Now generate the release apk by command line
I have the same issue after moving to react-native 0.57
android.enableAapt2=false didn't help me.
Same problem, can't solve it: https://github.com/rebeccahughes/react-native-device-info/issues/365#issuecomment-425609406
My solution that helps me with 0.57 react-native
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
}
}
}
}
So you have to change the code for:
subprojects { project.configurations.all { afterEvaluate {project -> if (project.hasProperty("android")) { android { compileSdkVersion 27 buildToolsVersion '27.0.3' } } } } }
Worked for me! Thanks My bro
@rodrigofbm thanks dude it worked for me
@antonsivogrivov thanks it worked for me
So you have to change the code for:
subprojects { project.configurations.all { afterEvaluate {project -> if (project.hasProperty("android")) { android { compileSdkVersion 27 buildToolsVersion '27.0.3' } } } } }
Worked for me! Thanks My bro
struggling with same issue now and nothing works ;/
https://github.com/facebook/react-native/issues/19239#issuecomment-425623992 this worked for me. version 0.57
My solution that helps me with 0.57 react-native
subprojects { afterEvaluate {project -> if (project.hasProperty("android")) { android { compileSdkVersion rootProject.ext.compileSdkVersion buildToolsVersion rootProject.ext.buildToolsVersion } } } }
this worked for me. version 0.57 👍
@kkusanagi Thanks. This is my solution for the latest version of react-native-camera (1.1.4):
subprojects { project.configurations.all { resolutionStrategy.eachDependency { details -> if (details.requested.group == 'com.android.support' && !details.requested.name.contains('multidex') ) { details.useVersion "27.1.1" } } } afterEvaluate { android { compileSdkVersion 27 buildToolsVersion "27.0.3" defaultConfig { targetSdkVersion 27 } } } }
If someone is facing this bug using react-native-image-resizer, this solution fixes it!
worked for me ! thank you @Scimanyd
This is my solution 👍 gradle.properties >> android.enableAapt2=false
project-->>build.gradle>> // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { repositories { jcenter() google() } dependencies { classpath 'com.android.tools.build:gradle:3.1.0' classpath 'com.google.gms:google-services:3.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects { repositories { mavenLocal() jcenter() google() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } } }
subprojects { project.configurations.all { resolutionStrategy.eachDependency { details -> if (details.requested.group == 'com.android.support' && !details.requested.name.contains('multidex') ) { details.useVersion "26.0.2" } }
afterEvaluate {
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
targetSdkVersion 26
}
}
}
} }
在转向react-native 0.57之后,我遇到了同样的问题
android.enableAapt2 = false没有帮助我。
解决了吗?
I had the same issue, @rodrigofbm 's solution worked for me. Just add the following at the end of ../android/build.gradle file
subprojects {
project.configurations.all {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
}
}
}
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "26.0.2"
}
}
}
}
Hey, guys.
I've also got the same issue after upgrade from RN 0.55 to 0.56, then I added this to my
android/build.gradle
, and it helped me to generate .apk, but this .apk doesn't work! It just shows the launch screen and then stops... Does anyone has an idea?subprojects { project.configurations.all { resolutionStrategy.eachDependency { details -> if (details.requested.group == 'com.android.support' && !details.requested.name.contains('multidex') ) { details.useVersion "27.1.1" } } } afterEvaluate { android { compileSdkVersion 27 buildToolsVersion "27.0.3" defaultConfig { targetSdkVersion 27 } } } }
I have the same problem, but i have no idea,did you solved it?
So you have to change the code for:
subprojects { project.configurations.all { afterEvaluate {project -> if (project.hasProperty("android")) { android { compileSdkVersion 27 buildToolsVersion '27.0.3' } } } } }
work for me like a boss! thank for saving time
@antonsivogrivov where should i add this: subprojects { project.configurations.all { afterEvaluate {project -> if (project.hasProperty("android")) { android { compileSdkVersion 27 buildToolsVersion '27.0.3' } } } } }
@vivek-walecha-657 in <ROOT>/android/build.gradle
if you are on 0.57 ++ I would recommend using @antonsivogrivov solution. as it has the variables defined from RN.
My solution that helps me with 0.57 react-native
subprojects { afterEvaluate {project -> if (project.hasProperty("android")) { android { compileSdkVersion rootProject.ext.compileSdkVersion buildToolsVersion rootProject.ext.buildToolsVersion } } } }
My solution that helps me with 0.57 react-native
subprojects { afterEvaluate {project -> if (project.hasProperty("android")) { android { compileSdkVersion rootProject.ext.compileSdkVersion buildToolsVersion rootProject.ext.buildToolsVersion } } } }
You saved my day. Thanks alot.
Here is my Gist with my sample project bulid.gradle , package.json using react native 55.4
https://gist.github.com/Abhishekgarg727/daf031fb9f94fdfd985e84db57dedbe1
@kkusanagi Thanks. This is my solution for the latest version of react-native-camera (1.1.4):
subprojects { project.configurations.all { resolutionStrategy.eachDependency { details -> if (details.requested.group == 'com.android.support' && !details.requested.name.contains('multidex') ) { details.useVersion "27.1.1" } } } afterEvaluate { android { compileSdkVersion 27 buildToolsVersion "27.0.3" defaultConfig { targetSdkVersion 27 } } } }
Thanks @pkhien95, you saved my night. 🙏
Hello there 👋 this issue has been reported for an old version of React Native. Ideally, we'd like everyone to be using 0.59 (see the awesome changes it brought) but we know updating can be a pain. During 0.59 update, some changes were made to the android build system, things like compileSdkVersion and others have been updated. I'll close the issue now.
But please, if it's actually still an issue with 0.59 please comment below and we can reopen it. Even better, please send us a pull request with a fix 😊
Environment:
OS: Linux 4.13 Node: 9.10.1 Yarn: 1.6.0 npm: 5.6.0 Watchman: Not Found Xcode: N/A Android Studio: Not Found
Packages: (wanted => installed)
react: 16.3.1 => 16.3.1 react-native: 0.55.3 => 0.55.3
Steps to Reproduce
./gradlew assembleRelease
Expected Behavior
make work???
Actual Behavior
The log:
build.gradle:
UPDATE
I've seted
android.enableAapt2 = false
in gradle.properties file, but now I'm receiving this log:Why is this happening?