1. 程式人生 > >解決Android studio中Plugin with id 'realm-android' not found

解決Android studio中Plugin with id 'realm-android' not found

問題

Plugin with id ‘realm-android’ not found

解決方案

安裝 Realm 作為 Gradle plugin.

第一步:
把 class path dependency 加入到 project 裡面的 build.gradle 檔案中。

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath "io.realm:realm-gradle-plugin:5.4.1"
    }
}

專案裡面的 build.gradle 檔案如下圖所示:
這裡寫圖片描述


第二步
把 realm-android plugin 加入到app層的 build.gradle 檔案中.

apply plugin: 'realm-android'

app層的build.gradle 檔案如下圖所示:
這裡寫圖片描述

加入完後點擊rebuild project就可以了。