DylanVann / react-native-fast-image

🚩 FastImage, performant React Native image component.
MIT License
8.21k stars 1.51k forks source link

Upgrading from 5.1.0 to 5.1.1 results in `Unsupported Modules Detected` gradle sync fail in Android Studio #362

Open JofBigHealth opened 5 years ago

JofBigHealth commented 5 years ago

The app builds on the CLI (./gradlew assembleRelease, react-native run-android etc). Builds in Android Studio at least sometimes (I think I've had at least one instance when it won't build in this state due to Argument for @NotNull parameter 'message' of com/android/tools/idea/gradle/project/sync/GradleSyncState.syncFailed must not be null). Presents the following message:

Unsupported Modules Detected: Compilation is not supported for following modules: react-native-device-info, react-native-locale, react-native-fast-image, lottie-react-native, react-native-google-analytics-bridge, react-native-keep-awake, react-native-fetch-blob, react-native-vector-icons, react-native-sentry, react-native-orientation, react-native-sound. Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one project.

Android Studio 3.2.1

Have done:

1) invalidate caches/restart 2) removed node_modules, yarn.lock and global yarn cache 3) deleted Android Studio project files

Reverting to 5.1.0 fixes it.

app/build.gradle

apply plugin: "com.android.application"

import com.android.build.OutputFile

project.ext.react = [
    entryFile: "index.js"
]

project.ext.sentryCli = [
        logLevel: "debug"
]
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-sentry/sentry.gradle"

def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.bighealth.REDACTED"
        minSdkVersion 26
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        debug {
            minifyEnabled false
        }
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a": 1, "x86": 2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    productFlavors {
    }
}

dependencies {
    implementation project(':react-native-sentry')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-svg')
    implementation project(':react-native-sound')
    implementation project(':react-native-orientation')
    implementation project(':react-native-locale')
    implementation project(':react-native-keep-awake')
    implementation project(':react-native-google-analytics-bridge')
    implementation project(':react-native-fetch-blob')
    implementation project(':react-native-device-info')
    implementation project(':lottie-react-native')
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.facebook.react:react-native:+' // From node_modules
    implementation 'com.yqritc:android-scalablevideoview:1.0.4'
    implementation project(':react-native-fast-image')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:support-media-compat:28.0.0'
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

apply plugin: 'com.android.application'
apply plugin: 'io.sentry.android.gradle'

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.2.1'
        classpath 'io.sentry:sentry-android-gradle-plugin:1.7.5'

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

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"
        }
        google()
    }
}
ashwanimm commented 5 years ago

I am getting similar error in Android Studio when I am building React Native project. Please can you suggest how to solve? I have Android SDK platform 9.0. SDK Tools 28.0.1

Below is the error:

Argument for @NotNull parameter 'message' of com/android/tools/idea/gradle/project/sync/GradleSyncState.syncFailed must not be null java.lang.IllegalArgumentException: Argument for @NotNull parameter 'message' of com/android/tools/idea/gradle/project/sync/GradleSyncState.syncFailed must not be null at com.android.tools.idea.gradle.project.sync.GradleSyncState.$$$reportNull$$$0(GradleSyncState.java) at com.android.tools.idea.gradle.project.sync.GradleSyncState.syncFailed(GradleSyncState.java) at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.doPopulateProject(IdeaSyncPopulateProjectTask.java:135) at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.populate(IdeaSyncPopulateProjectTask.java:97) at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.access$000(IdeaSyncPopulateProjectTask.java:39) at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask$1.run(IdeaSyncPopulateProjectTask.java:86) at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:750) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:157) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:580) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:525) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:85) at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144) at com.intellij.openapi.progress.impl.CoreProgressManager$4.run(CoreProgressManager.java:395) at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:305) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

JofBigHealth commented 5 years ago

@ashwanimm Try downgrading Android Studio to 3.1.x

JofBigHealth commented 5 years ago

And then do the Clean and Restart option and maybe also delete the project dotfiles Android Studio adds.

JofBigHealth commented 5 years ago

If all else fails, upgrade React Native and all associated packages. That's what we did. Took a day or two of work but solved everything. Had to remove some unmaintained third party packages though

ashwanimm commented 5 years ago

@JofBigHealth Great! Thank you so much. I am able to resolve the issue as per your guidance.

JofBigHealth commented 5 years ago

For anyone else who is reading this, RN doesn't support Android Studio 3.2.x currently (0.57.7 - see release notes for 0.57.x) due to changes with Gradle. So try 3.1.x first.

AugustoAleGon commented 5 years ago

@JofBigHealth Thanks a lot. I solved my problem. I had to downgrade the Android Studio to 3.1.x in order to make it work.

jeongsd commented 5 years ago

@AugustoAleGon Where can i downgrade to Android Studio to 3.1.x?

https://developer.android.com/studio/archive

AugustoAleGon commented 5 years ago

@jeongsd Honestly, you have to enter in the developer.android website and you have to search the version that you want. In my case I have installed 3.1.2