如何在Android Astudio中添加依赖项

时间:2017-04-17 12:37:49

标签: android android-studio

我想将此依赖项compile 'com.github.ar-android:DrawRouteMaps:1.0.0'添加到我的Android工作室项目中 将此添加到依赖项中并单击“同步”时显示此错误:

Error:(39, 13) Failed to resolve: com.github.ar-android:DrawRouteMaps:1.0.0
<a href="openFile:G:/Android/Projects/1-MapTutorial/app/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>

build.gradle codes:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.2'

    defaultConfig {
        applicationId "com.example.mohammadn.a1_maptutorial"
        minSdkVersion 14
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    mavenCentral()
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.google.android.gms:play-services:9.2.1'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    compile 'com.google.android.gms:play-services-maps:9.2.1'
    testCompile 'junit:junit:4.12'

    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.google.code.gson:gson:2.6.1'

    compile 'com.github.ar-android:DrawRouteMaps:1.0.0'
}

如何修复它并将此库添加到我的依赖项中?

5 个答案:

答案 0 :(得分:2)

在存储库末尾的根 a[href^=tel] { color: inherit; text-decoration: none; } .navbar-default { display: flex; align-items: center; padding-left: 10px; padding-right: 10px; border: 0; -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; background-color: #00a3fe; font-size: 14pt; font-weight: 400; } a:hover { text-decoration: none; } .nav.navbar-nav.navbar-right li a { color: #ffffff; } .nav.navbar-nav.navbar-nav li a { color: #ffffff; } .navbar-default .navbar-nav>li>a:hover, .navbar-default .navbar-nav>li>a:focus { background-color: #49bdfe; color: #FFFFFF; } .navbar-toggle, .icon-bar { border: 1px solid white; background-color: white; } .navbar-toggle { color: : white; border: none; background: transparent !important; } .navbar-toggle:hover { background: transparent !important; } .navbar-toggle { border: none; background: transparent !important; } .navbar-toggle:hover { background: transparent !important; } .navbar-toggle .icon-bar { width: 22px; transition: all 0.2s; } .navbar-toggle .top-bar { transform: rotate(45deg); transform-origin: 10% 10%; } .navbar-toggle .middle-bar { opacity: 0; } .navbar-toggle .bottom-bar { transform: rotate(-45deg); transform-origin: 10% 90%; } .navbar-toggle.collapsed .top-bar { transform: rotate(0); } .navbar-toggle.collapsed .middle-bar { opacity: 1; } .navbar-toggle.collapsed .bottom-bar { transform: rotate(0); } .btn { display: inline-block; padding: 6px 12px; margin-bottom: 0; font-size: 14px; font-weight: normal; line-height: 1.42857143; text-align: center; white-space: nowrap; vertical-align: middle; cursor: pointer; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; background-image: none; border: 1px solid transparent; border-radius: 4px; padding: 10px 16px; transition: all 0.4s ease 0s; } .navbar-brand { font: 30px cursive; display: flex; align-items: center; } .navbar-brand { padding: 0px; } .navbar-brand>img { height: 100%; padding: 15px; width: auto; } /* EXAMPLE 3 line height is 20px by default so add 30px top and bottom to equal the new .navbar-brand 80px height */ .example3 .navbar-brand { height: 80px; } .example3 .nav>li>a { padding-top: 2.1vw; padding-bottom: 2.1vw; } .example3 .navbar-toggle { padding: 10px; margin: 25px 15px 25px 0; } .navspacing { padding-left: 30px; padding-right: 30px; } .example3 { padding-left: 30px; padding-right: 30px; }中添加支持 jitpact存储库

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <!-- NAVBAR -->
    <nav class='navbar navbar-default example3'>
      <div class='container'>
        <div class='navbar-header'>
          <button type='button' class='navbar-toggle collapsed' data-toggle='collapse' data-target='#example-navbar-collapse'>
        <span class='sr-only'>Toggle navigation</span>
        <span class='icon-bar top-bar'></span>
        <span class='icon-bar middle-bar'></span>
        <span class='icon-bar bottom-bar'></span></button>
          <span class='navbar-brand'><img src="images/f2p7.png" alt="faces2places" class="img-responsive" /></span></div>
        <div class='collapse navbar-collapse' id='example-navbar-collapse'>
          <ul class='nav navbar-nav'>
            <li><a href='about.php' class='btn btn-primary btn-lg sharp' role='button'>About</a></li>
            <li><a href='get_bids.php' class='btn btn-primary btn-lg sharp' role='button'>Get bids</a></li>
            <li><a href='register.php' class='btn btn-primary btn-lg sharp' role='button'>Register company</a></li>
            <li><a href='contact.php' class='btn btn-primary btn-lg sharp' role='button'>Contact</a></li>
          </ul>
          <ul class='nav navbar-nav navbar-right'>
            <li><a href='login.php' class='btn btn-primary btn-lg sharp' role='button'><span class='glyphicon glyphicon-user'></span> Login</a></li>
          </ul>
        </div>
      </div>
    </nav>
    <!-- NAVBAR -->

阅读有关 DrawRouteMaps .

的官方指南

答案 1 :(得分:1)

尝试将以下行添加到 project / build.gradle (不是app / build.gradle)

class TestClass(var testService: TestService) {
    fun test() = testService.testfun()
}

应用/的build.gradle

function cargarDonut(idElemento, color){
   google.charts.load("current", {packages:["corechart"]});
   google.charts.setOnLoadCallback(drawChart);

function drawChart() {
  var data = google.visualization.arrayToDataTable([
    ['Task', 'Hours per Day'],
    ['Work',     11],
    ['Eat',      2],
    ]);

  var options = {
    chartArea:{top:'0%',width:'100%', height:'80%'},
    height: 240,
    backgroundColor: 'transparent',
    pieHole: 0.67,
    legend: 'none',
    pieSliceBorder: 100,
    pieSliceText: 'none',
    slices: {  2: {offset: 1}},

    colors: [ '#797879', color],

  };

  var chart = new 
google.visualization.PieChart(document.getElementById(idElemento));
chart.draw(data, options);
// initial value
    var percent = 0;
    // start the animation loop
    var handler = setInterval(function(){
        // values increment
        percent += 1;
        // apply new values
        data.setValue(0, 1, percent);
        data.setValue(1, 1, 100 - percent);
        // update the pie
        chart.draw(data, options);
        // check if we have reached the desired value
        if (percent > 74)
            // stop the loop
            clearInterval(handler);
    }, 30);

}

}

答案 2 :(得分:1)

首先,您必须在项目中添加Maven资源库:

compile 'com.github.ar-android:DrawRouteMaps:1.0.0'

然后,在foreach ($cidades as $c) { @$registros = array( "Estado" => $estados[$c], "Municipio" => $c, "tres_dias" => $focos_3[ (array_search("$c", $cidades_3) >=0 ? array_search("$c", $cidades_3) : ('') ) ], "dois_dias" => $focos_2[ (array_search("$c", $cidades_2) >=0 ? array_search("$c", $cidades_2) : ('') ) ], "um_dia" => $focos_1[ (array_search("$c", $cidades_1) >=0 ? array_search("$c", $cidades_1) : ('') ) ], "total" => ( ($focos_3[ (array_search("$c", $cidades_3) >=0 ? array_search("$c", $cidades_3) : ('') ) ]) + ($focos_2[ (array_search("$c", $cidades_2) >=0 ? array_search("$c", $cidades_2) : ('') ) ]) + ($focos_1[ (array_search("$c", $cidades_1) >=0 ? array_search("$c", $cidades_1) : ('') ) ]) ) ); } 模块应用中添加依赖项:

allprojects {
   repositories {
    maven { url "https://jitpack.io" }
   }
}

答案 3 :(得分:1)

将此项添加到您的项目中:build.gradle文件到此

allprojects {
   repositories {
    maven { url "https://jitpack.io" }
   }
}

答案 4 :(得分:1)

除了以上评论,您还可以在file-&gt;项目结构中添加依赖项 - &gt; add-&gt; +(加号) - &gt;添加库