【问题标题】:fixing cannot resolve all dependencies修复无法解决所有依赖项
【发布时间】:2018-02-19 11:22:10
【问题描述】:

第一个gradle代码如下 我会很高兴您的回应。运行中的错误说无法解决所有依赖项。其中包括;身份验证、核心和数据库。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.appsound.instagram.tinder"
        minSdkVersion 14
        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(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.firebase:firebase-core:11.8.0'
    compile 'com.google.firebase:firebase-database:11.8.0'
    compile 'com.google.firebase:firebase-auth:11.8.0'
    compile 'com.lorentzos.swipecards:library:1.0.9'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

第二个gradle代码如下图 我会很高兴您的回应。运行中的错误说无法解决所有依赖项。其中包括;身份验证、核心和数据库。

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

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'
        classpath 'com.google.gms:google-services:3.0.0'

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

allprojects {
    repositories {
        jcenter()
    }
}

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

主要活动java代码如下图 我会很高兴您的回应。运行中的错误说无法解决所有依赖项。其中包括;身份验证、核心和数据库。

package com.appsound.instagram.tinder;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.Toast;

import com.lorentzos.flingswipe.SwipeFlingAdapterView;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {

    private ArrayList<String> al;
    private ArrayAdapter<String> arrayAdapter;
    private int i;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        al = new ArrayList<>();
        al.add("php");
        al.add("c");
        al.add("python");
        al.add("java");
        al.add("html");
        al.add("c++");
        al.add("css");
        al.add("javascript");

        arrayAdapter = new ArrayAdapter<>(this, R.layout.item, R.id.helloText, al);


        SwipeFlingAdapterView Flingcontainer = ( SwipeFlingAdapterView) findViewById(R.id.frame);
        Flingcontainer.setAdapter(arrayAdapter);
        Flingcontainer.setFlingListener(new SwipeFlingAdapterView.onFlingListener(){
            @Override
            public void removeFirstObjectInAdapter() {
                // this is the simplest way to delete an object from the Adapter (/AdapterView)
                Log.d("LIST", "removed object!");
                al.remove(0);
                arrayAdapter.notifyDataSetChanged();
            }

            @Override
            public void onLeftCardExit(Object dataObject) {
                //Do something on the left!
                //You also have access to the original object.
                //If you want to use it just cast it (String) dataObject
                Toast.makeText(MainActivity.this, "left", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onRightCardExit(Object dataObject) {
                Toast.makeText(MainActivity.this, "right", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onAdapterAboutToEmpty(int itemsInAdapter) {
                // Ask for more data here
                al.add("XML ".concat(String.valueOf(i)));
                arrayAdapter.notifyDataSetChanged();
                Log.d("LIST", "notified");
                i++;
            }

            @Override
            public void onScroll(float scrollProgressPercent) {

            }

        });


        // Optionally add an OnItemClickListener
        Flingcontainer.setOnItemClickListener(new SwipeFlingAdapterView.OnItemClickListener() {
            @Override
            public void onItemClicked(int itemPosition, Object dataObject) {
                Toast.makeText(MainActivity.this, "click", Toast.LENGTH_SHORT).show();
            }
        });

    }
}

我会很高兴您的回复。运行中的错误说无法解决所有依赖项。其中包括;身份验证、核心和数据库。

【问题讨论】:

    标签: java android


    【解决方案1】:

    阅读Dependency types

    • 设置:gradle:3.0.1
    • 添加google()

    在您的顶级 build.gradle 文件中添加 Google's Maven repository

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

    演示

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
        repositories {
            google()
            jcenter()
        }
        dependencies {
           classpath 'com.android.tools.build:gradle:3.0.1'
            classpath 'com.google.gms:google-services:3.0.0'
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            google()
            jcenter()
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    

    build.gradle

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 27
        buildToolsVersion "27.0.2"
        defaultConfig {
            applicationId "com.appsound.instagram.tinder"
            minSdkVersion 14
            targetSdkVersion 27
            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(dir: 'libs', include: ['*.jar'])
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        compile 'com.android.support:appcompat-v7:27.0.2'
        compile 'com.android.support.constraint:constraint-layout:1.0.2'
        compile 'com.google.firebase:firebase-core:11.8.0'
        compile 'com.google.firebase:firebase-database:11.8.0'
        compile 'com.google.firebase:firebase-auth:11.8.0'
        compile 'com.lorentzos.swipecards:library:1.0.9'
        testCompile 'junit:junit:4.12'
    }
    apply plugin: 'com.google.gms.google-services'
    

    FYI

    打开 gradle-wrapper.properties 并确保您使用的是 gradle-4.1-all 版本。

    distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
    

    【讨论】:

    • 我希望在同步 gradle 时不会收到任何错误,请帮忙
    • @moses 你应该先Clean-Rebuild-Sync 项目
    • 错误:配置项目 ':app' 时出现问题。 > 无法解析配置“:app:_debugApkCopy”的所有依赖项。 > 找不到 com.google.firebase:firebase-core:11.8.0。要求:项目:app > 找不到 com.google.firebase:firebase-database:11.8.0。要求:项目:app > 找不到 com.google.firebase:firebase-auth:11.8.0。要求:项目:app
    • @moses 请使用最新的build.gradle,然后重新启动 IDE 并运行。
    • 这是最新的 gradle 请发送代码..以及如何重新启动 IDE。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-12
    • 2012-01-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多