簡體   English   中英

Gradle項目同步無法使用GitHub中的庫

[英]Gradle project sync failed in using a library from GitHub

我正在嘗試從GitHub使用SwipeLayout 庫,但出現此錯誤:

Failed to resolve: com.daimajia.swipelayout:library:1.2.0

我嘗試了一切,包括:

  • 刪除@aar
  • ProjectStructure -> app -> Dependencies搜索並添加庫

等等..

首先,我雖然也許問題是這樣的庫,但我試圖用這一個 ,但仍然收到這個錯誤..如果任何人都可以給我一個線索,我會如此感激。 並且可以ü解釋有什么區別 compile ' ,並 compile " 我都嘗試

*這是我的`build.gradle'文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "com.drgnme.listhamrah"
        minSdkVersion 23
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
    compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
    compile 'com.android.support:cardview-v7:26.0.0-alpha1'
    compile 'com.android.support:design:26.0.0-alpha1'
    compile 'com.github.roojin:persian-calendar-view:1.2.1'
    compile 'com.android.support:support-v4:26.0.0-alpha1'    
    compile "com.daimajia.swipelayout:library:1.2.0@aar"
}

只需這樣嘗試:

 <android.support.v4.widget.SwipeRefreshLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/swipe_refresh_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
    android:id="@+id/study_level_list"
    android:scrollbars="vertical"
    android:paddingBottom="85dp"
    android:clipToPadding="false"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.SwipeRefreshLayout>

在Java文件中;

private SwipeRefreshLayout mSwipeRefreshLayout;

mSwipeRefreshLayout = (SwipeRefreshLayout)rootView. findViewById(R.id.swipe_refresh_layout);

並像這樣綁定您的列表視圖;

 mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            // Refresh the data
            // Calls setRefreshing(false) when it is finish
              mAdapter = new MyAdapter(studypojo.getStudylevelList());
              list_view.setAdapter(mAdapter);
              mSwipeRefreshLayout.setRefreshing(false);
        }
    });

作者沒有聲明,但是在檢查了項目文件之后,似乎他正在將工件部署到中央(又名Maven中央)。 因此,將mavenCentral()添加到您的存儲庫列表中,您將獲得工件。 或者,您可以使用jitpack存儲庫。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM