Gradle配置国内镜像

全局配置,对所有项目生效,在~/.gradle/下创建init.gradle文件

allprojects{
    repositories {
        def ALIYUN_REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public'
        def ALIYUN_JCENTER_URL = 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
        all { ArtifactRepository repo ->
            if(repo instanceof MavenArtifactRepository){
                def url = repo.url.toString()
                if (url.startsWith('https://repo1.maven.org/maven2')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL."
                    remove repo
                }
                if (url.startsWith('https://jcenter.bintray.com/')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL."
                    remove repo
                }
            }
        }
        maven {
            url ALIYUN_REPOSITORY_URL
            url ALIYUN_JCENTER_URL
        }
    }
}

react native Unknown argument type ‘__attribute__’ in method

找到myproject/node_modules/react-native/React/Base/RCTModuleMethod.mm. 【或者(.m)】文件

修改static BOOL RCTParseUnused 方法如下:

static BOOL RCTParseUnused(const char **input)
{
return RCTReadString(input, “unused”) || RCTReadString(input, “__attribute((unused))”) ||
RCTReadString(input, “attribute((unused))”);
}

重新编译

android studio unsupported modules detected

首先是出现如下情况:
unsupported modules detected Compilation is not supported for following modules: app. Unfortunately you can’t have non-Gradle Java modules and Android-Gradle modules in one project

然后项目正下方一直出现加载:indexing paused due to batch update

自从更新到android studio 3.2之后,首次打开项目出现错误:indexing paused due to batch update(由于批量更新而暂停的索引),个人猜想可能是第一种情况导致的吧。然后网上查找到了一些方法如下:

1、关闭Android Studio ,去项目根目录删除.idea文件,重启AS搞定
2、File -> Invalidate Caches / Restart -> Invalidate Caches & Restart.
3、File -> Sync Project With Gradle Files

当时我试过后面两种不行,第一种就OK。