2

我試圖將庫添加到Kotlin但它沒有得到正確的安裝。Kotlin ||無法將庫添加到我的應用程序中?

繼錯誤我收到在導入庫,請檢查一下

Error:Could not find com.android.tools.build:gradle:2.3.1. Searched in the following locations: file:/C:/Program Files/Android/Android Studio Preview/gradle/m2repository/com/android/tools/build/gradle/2.3.1/gradle-2.3.1.pom file:/C:/Program Files/Android/Android Studio Preview/gradle/m2repository/com/android/tools/build/gradle/2.3.1/gradle-2.3.1.jar https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.3.1/gradle-2.3.1.pom https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.3.1/gradle-2.3.1.jar Required by: project :slidingmenulib

我使用以下項目build.gradle,請一次檢查

// Top-level build file where you can add configuration options common to all sub-projects/modules. 

buildscript { 
    ext.kotlin_version = '1.1.3-2' 
    repositories { 
     google() 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:3.0.0-alpha9' 
     classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 


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

allprojects { 
    repositories { 
     google() 
     jcenter() 
     mavenCentral() 
    } 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 

而我的模塊gradle這個是如下:

apply plugin: 'com.android.application' 

apply plugin: 'kotlin-android' 

apply plugin: 'kotlin-android-extensions' 

android { 
    compileSdkVersion 26 
    buildToolsVersion "25.0.2" 
    defaultConfig { 
     applicationId "com.zargow.kotlin" 
     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 { 
    implementation fileTree(dir: 'libs', include: ['*.jar']) 
    androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.0', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" 
    implementation 'com.android.support:appcompat-v7:26.0.0-beta2' 
    testImplementation 'junit:junit:4.12' 
    implementation 'com.android.support.constraint:constraint-layout:1.0.2' 
    implementation 'com.android.support:recyclerview-v7:26.0.0-beta2' 

    compile 'com.github.bumptech.glide:glide:3.8.0' 
    compile 'org.jetbrains.anko:anko-design:0.8.3' 

    compile 'com.squareup.okhttp3:okhttp:3.8.1' 
    compile 'com.android.support:cardview-v7:26.0.0-beta2' 
    compile 'com.android.support:design:26.0.0-beta2' 
    compile 'de.hdodenhof:circleimageview:2.1.0' 
    implementation 'com.android.support:design:26.0.0-beta2' 

} 

我正在使用滑動菜單庫,請檢查click here。這些庫需要導入到我的kotlin項目中,但出現錯誤。

請幫我解決這個問題。由於

回答

2

在progect gradle這個文件使用

allprojects { 
repositories { 
    google() 
    jcenter() 
    mavenCentral() 
    maven { url "http://jzaccone.github.io/SlidingMenu-aar" } 
    } 
} 

和應用程序添加的gradle

dependencies { 
.... 
compile 'com.jeremyfeinstein.slidingmenu:library:[email protected]' 
} 
+0

Thanks..It爲我工作:)...有一個問題是,爲什麼我收到錯誤在'Kotlin'上導入庫。在'Andorid studio'中使用過的同一個libraray,它工作但不在'Kotlin' ?? ..對此有何建議? –

+0

@Ravindra Kushwaha看起來像你試圖添加庫作爲模塊,但它取決於最早的gradle構建版本'https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.3.1/ gradle-2.3.1.jar必需:project:slidingmenulib' –

相關問題