react-native-splash-screen icon indicating copy to clipboard operation
react-native-splash-screen copied to clipboard

Build failed on Android, HELP

Open junchenjun opened this issue 7 years ago • 48 comments

FAILURE: Build failed with an exception.

  • Where: Build file '/Users/----/workspace/----/node_modules/react-native-splash-screen/android/build.gradle' line: 22

  • What went wrong: A problem occurred evaluating project ':react-native-splash-screen'.

Could not find method implementation() for arguments [directory 'libs'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

I followed the instruction again and again, but still build failed on Android, no problem on IOS.

junchenjun avatar May 29 '18 21:05 junchenjun

same issue here. I can build the APK successfully yesterday, but it fails today without any code change.

splash issue

react native version:

"react": "^16.0.0-alpha.12",
"react-native": "^0.47.0",

In build.gradle under app folder:

dependencies {
    compile project(':react-native-splash-screen')
    ....
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.facebook.react:react-native:+'
}

Also, I've imported the package in MainActivity & MainApplication.java file.

Not sure what cause this issue.
I run the same project which I clone from gitlab yesterday, it works fine now. But I run the same project which I clone today, it pop up this issue. Does the splash package cause this problem or gitlab cause this problem?

Anyone has any idea what cause this issue? really appreciate.

vivikenen avatar May 30 '18 02:05 vivikenen

I googled and found out this might be a problem related to gradle, and I found that in the /node_module/react-native-splash/-screen/android/build.gradle are using implementation instead of compile, implementation is a new gradle version api, and I am using gradle:2.2.3.

Should I update my gradle and give it a try? but I don't want to cause other problem from my other libs

junchenjun avatar May 30 '18 07:05 junchenjun

@vivikenen check out android/build.gredle what is your gredle version

junchenjun avatar May 30 '18 07:05 junchenjun

classpath 'com.android.tools.build:gradle:2.2.3'

vivikenen avatar May 30 '18 07:05 vivikenen

https://stackoverflow.com/questions/45099716/error40-0-could-not-find-method-implementation-for-arguments-directory-l try?

Darkhorse-Fraternity avatar May 30 '18 08:05 Darkhorse-Fraternity

I finally fixed this ! Upgrade your gradle is the solution.

junchenjun avatar May 30 '18 09:05 junchenjun

If anyone have any other errors after upgrading gradle, then try to upgrade compileSdkVersion& buildToolsVersion in android/app/build.gradle

junchenjun avatar May 30 '18 09:05 junchenjun

I reopened this issue cause I realized more and more people are having this issue, I think upgrading gradle would be the best solution, although it is quite painful.

Hope this gets fixed soon.

junchenjun avatar May 30 '18 12:05 junchenjun

I'm using gradle3.1.1 and still having this issue #220. The only solution is to change com.android.support:appcompat-v7:27.0.2 to com.android.support:appcompat-v7:23.0.1 and change compiledSdkVersion to 23.

Any solutions?

vikrantnegi avatar May 30 '18 12:05 vikrantnegi

@vikrantnegi


// in the android/build.gradle
buildscript {
...
}

allprojects {
...
}

// add this
subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                && !details.requested.name.contains('multidex') ) 
            {
                details.useVersion "26.1.0"
            }
        }
    }
}

junchenjun avatar May 30 '18 13:05 junchenjun

@jaychenjun That but it did not help. I think that this since this library is using gradle implementation 'com.android.support:appcompat-v7:27.0.2' & compileSdkVersion 27

and my react native is using gradle implementation 'com.android.support:appcompat-v7:23.0.1' & compileSdkVersion 23

This is the reason that is causing the error. When I change this library gradle to match the project gradle the project builds successfully.

vikrantnegi avatar May 30 '18 15:05 vikrantnegi

Fixed it, it is due to the com.android.support:appcompat version.

The solution from @vikrantnegi works, thank you.

I upgraded com.android.support:appcompat-v7:23.0.1 to compile 'com.android.support:appcompat-v7:27.0.2'

and upgraded compileSdkVersion 23 to compileSdkVersion 27

Android APK can build successfully now.

vivikenen avatar May 31 '18 01:05 vivikenen

@jaychenjun Hi, My gradle version in android/build.gradle is classpath 'com.android.tools.build:gradle:2.3.3' But I have same problem. What version of gradle do I install?

alihesari avatar May 31 '18 17:05 alihesari

classpath 'com.android.tools.build:gradle:3.1.0'

Upgrading gradle is my solution though, you can try to upgrade com.android.support:appcompat first as mentioned by others above.

junchenjun avatar May 31 '18 18:05 junchenjun

@jaychenjun I upgraded gradle to 3.1.2 but I have error! Please see the Image. How to solve errors?! screen shot 1397-03-11 at 12 09 40 am Also When I run react-native run-android get this error in terminal:

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details

alihesari avatar May 31 '18 19:05 alihesari

@alihesari In your android/app/build.gradle snipaste_2018-06-01_03-46-12

junchenjun avatar May 31 '18 19:05 junchenjun

This seems to be caused by 3.0.7 upgrade. If it requires gradle upgrade, it should be a major revision, not a patch

ndreckshage avatar May 31 '18 20:05 ndreckshage

Syncing gradle versions is a very very very painful process! Dear contributors please don't change the default gradle/supportlibs/buildTools/... versions! and leave them as react-native default version.

AlirezaAkbarix avatar Jun 02 '18 04:06 AlirezaAkbarix

Ok, so i tried to repair this issue without any change to my code:

First I initiate a new project, and installed react-native-splash-screen

I removed locally, the changes made before https://github.com/crazycodeboy/react-native-splash-screen/commit/c078edfb93640b96ef5cda877a716cb500366a15 and the building part is looking fine with react-native default gradle/supportlibs/buildTools/...

nicovak avatar Jun 04 '18 16:06 nicovak

Still doesnt seem to work:


android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"

    defaultConfig {
        applicationId "com.blog"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
dependencies {
    compile 'com.android.support:appcompat-v7:27.0.2'
}

rasselll avatar Jun 04 '18 20:06 rasselll

I finally made It works, here is my conf if anyone want to test.

  • I had to enable multiDexEnabled because I had a error on opening.
  • I also had to add a piece of code because I used Onesignal

These two steps above are specific to my use case.

My android/app/build.gradle

android {
    compileSdkVersion 27
    buildToolsVersion '25.0.3'

    defaultConfig {
        applicationId "YOUR APP ID"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 12
        versionName "2.0"
        multiDexEnabled true
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }

My android/build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files

react-native-splash-screen build.gradle c078edf

apply plugin: 'com.android.library'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile "com.facebook.react:react-native:+"  // From node_modules
}

nicovak avatar Jun 05 '18 07:06 nicovak

Hi @nicovak , you downgrade the build gradle of the package?

vivikenen avatar Jun 05 '18 08:06 vivikenen

@vivikenen yes, I also tried https://github.com/facebook/react-native/issues/15448 and everything works fine now with last gradle's version and build tools (react-native default ones are pretty old)

I also upvoted : https://react-native.canny.io/feature-requests/p/update-android-build-tools-version-in-project-generated-by-react-native-init

nicovak avatar Jun 05 '18 08:06 nicovak

Upgrade gradle can fixed this,but change default setting is not a good way.

MR03web avatar Jun 06 '18 05:06 MR03web

I don't know what's happen.... I was build successfully use the solution for upgrading com.android.support:appcompat-v7:23.0.1 to 'com.android.support:appcompat-v7:27.0.2' and upgrading compileSdkVersion 23 to compileSdkVersion 27.

But suddenly, it does not work again since yesterday.

And I try to upgrade the gradle to distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip in gradle-wrapper.properties and classpath 'com.android.tools.build:gradle:3.1.0' in build.gradle under android folder.

It helped me to build APK successfully, but the app keep crashing when I try to open it, it says The app has stoped.

And then, I try to run on ios, ios does not throw any error message, but the splash image does not show when I open the app, just black screen, and then navigate to the main page.

Do you have the same issue?

vivikenen avatar Jun 06 '18 07:06 vivikenen

    compileSdkVersion 27
    buildToolsVersion "27.0.3"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 23
        ...
    }

@vivikenen, try upgrading buildToolsVersion, minSdkVersion and targetSdkVersion?

MR03web avatar Jun 06 '18 08:06 MR03web

Hi @MR03web , Thx for your help, but I try to upgrading the buildToolsVersion, minSdkVersion and targetSdkVersion. Doesn't work as well. It can be built successfully, but crash when I try to open it. (No code change)

Even when I try to upgrade the gradle to classpath 'com.android.tools.build:gradle:3.1.0', still crash when I try to open the app.

vivikenen avatar Jun 07 '18 02:06 vivikenen

@vivikenen,

I created a demo only used react-native-splash-screen. It can be built successfully and running on my phone,if still can't succeed. you may need to check the android sdk environment or change a phone...

PS: delete android/app/build and build apk

https://github.com/MR03web/splashDemo

MR03web avatar Jun 07 '18 06:06 MR03web

this is my app/build.gradle

compile fileTree(dir: "libs", include: ["*.jar"]) compile "com.android.support:appcompat-v7:23.0.1" compile "com.facebook.react:react-native:+" // From node_modules

I replaced the react-native-splash-screen build.gradle with app/build.gradle

implementation fileTree(dir: 'libs', include: ['*.jar']) testImplementation 'junit:junit:4.12' implementation 'com.android.support:appcompat-v7:27.0.2' implementation "com.facebook.react:react-native:+"

to

compile fileTree(dir: "libs", include: ["*.jar"]) compile "com.android.support:appcompat-v7:23.0.1" compile "com.facebook.react:react-native:+" // From node_modules

I'm not sure but it worked. I'm not sure is this correct approaach or not. Because no one goes to change the content inside node_modules folder.

rvasoya avatar Jun 07 '18 07:06 rvasoya

same issue

aqnaruto avatar Jun 07 '18 07:06 aqnaruto