You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Android集成ObjectBox报错:无法找到objectbox-gradle-plugin:1.3.4

Fixing ObjectBox 1.3.4 Integration with Gradle 4.3.1

Hey there, let's get this ObjectBox integration sorted out. The error you're seeing (Could not find io.objectbox:objectbox-gradle-plugin:1.3.4) comes from mixed version references and a couple of configuration oversights. Let's fix this step by step:

1. Unify ObjectBox Versions

You mentioned wanting to use ObjectBox 1.3.4, but your current setup uses 1.4.0 for all dependencies. Let's standardize on 1.3.4 across all files and use a version variable to make future updates easier.

Update Root build.gradle

Uncomment and set the objectboxVersion variable, match the plugin classpath to 1.3.4, and ensure the beta repository is correctly added in both buildscript and allprojects:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.objectboxVersion = '1.3.4' // Uncomment and set to your target version
    repositories {
        google()
        jcenter()
        maven { url "http://objectbox.net/beta-repo/" } // Required for ObjectBox 1.3.4
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion" // Use the version variable
    }
}

allprojects {
    repositories {
        maven { url "http://objectbox.net/beta-repo/" }
        google()
        jcenter()
        mavenCentral()
    }
}

// Remove this redundant repositories block (it duplicates the allprojects config)
// repositories {
//     //maven { url "http://objectbox.net/beta-repo/" }
//     jcenter()
//     mavenCentral()
//     google()
// }

Update App Module build.gradle

Update all ObjectBox dependencies to use the version variable, remove the redundant Java library dependency (the Android variants already include it), and ensure the ObjectBox plugin is applied after dependencies:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "27.0.1"
    defaultConfig {
        applicationId "com.example.novo0007.objectbox"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    debugImplementation "io.objectbox:objectbox-android-objectbrowser:$objectboxVersion"
    releaseImplementation "io.objectbox:objectbox-android:$objectboxVersion"
    annotationProcessor "io.objectbox:objectbox-processor:$objectboxVersion"
    
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

apply plugin: 'io.objectbox' // Must come AFTER the dependencies block

Note: I replaced deprecated debugCompile/releaseCompile with debugImplementation/releaseImplementation (AGP 3.0+ preferred syntax), but both will work for your setup.

2. Verify Compatibility

Your Gradle 4.3.1 + Android Gradle Plugin 3.0.1 setup is fully compatible with ObjectBox 1.3.4—no version conflicts here as long as references are unified.

3. Clean and Rebuild

After making these changes:

  • Go to File > Invalidate Caches... > Invalidate and Restart in Android Studio to clear cached configurations
  • Run ./gradlew clean build from the terminal (or use the Build menu to clean and rebuild your project)

This should resolve the "Could not find..." error and get ObjectBox running smoothly in your app.

内容的提问来源于stack exchange,提问作者Vishnu Sookdeo

火山引擎 最新活动