【问题标题】:Getting error when try to import picasso library尝试导入毕加索库时出错
【发布时间】:2016-09-05 16:04:18
【问题描述】:

我想将毕加索库导入我的 android 工作室,但是当我尝试这样做时。 Android studio 给我留言:

错误:(3, 0) 在 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@71d5a575 上找不到属性“dep”。 打开文件

那么如何解决呢?我真的需要你的帮助。 这是我的应用程序:

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.1.2'

    // 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
}

还有一个:

  apply plugin: 'com.android.application'

  android {
compileSdkVersion 23
buildToolsVersion "23.0.0"

defaultConfig {
    applicationId "com.example.hp.refomandaapps"
    minSdkVersion 19
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

  dependencies {
   compile fileTree(dir: 'libs', include: ['*.jar'])
   testCompile 'junit:junit:4.12'
   compile project(":lib-release")
   compile project(":circleindicator-debug")
   compile 'com.android.support:appcompat-v7:23.4.0'
   compile 'com.google.android.gms:play-services:9.0.2'
   compile 'com.android.support:support-v4:23.4.0'
   compile 'com.squareup.picasso:picasso:2.5.2'

   }

【问题讨论】:

  • 你能否评论一下 compile project(":lib-release") compile project(":circleindicator-debug") 只是为了尝试
  • 只是一个建议,不要导入整个 google play 服务库,link 专门导入。
  • @MinaFawzy 对不起,我不明白你在说什么 :(
  • 在 import picasso 之前应用程序是否正常工作?
  • @MinaFawzy 是的,在我尝试导入毕加索之前,这些应用程序按我的预期工作。

标签: android gradle build.gradle


【解决方案1】:

这是我的示例 build.gradle 文件。注意有两个build.gradle文件,一个在app文件夹下,一个在项目文件夹下。

App文件夹下的那个是这样的

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "app.com.example.android.appname"
        minSdkVersion 10
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    mavenCentral ()
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.2.0'
    compile 'com.android.support:design:23.2.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
}

我发现你的 gradle 文件中没有 repositories 标签。尝试添加它,看看是否能解决问题。 Project文件夹下的那个是这样的

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.3'

        // 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
}

也可能是不同的库发生冲突,您必须启用多索引。有关更多信息,请参阅此帖子 Runtime Error When Adding Picasso to Gradle 让我知道这个是否奏效。祝你好运!

【讨论】:

  • “将毕加索添加到 Gradle 时出现运行时错误”中的问题是您导入的库过多。但我的问题是在 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@71d5a575 上找不到属性“dep”。打开文件。您对我的问题有其他解决方案吗?谢谢。
【解决方案2】:

试试multidex这可能会解决你的问题

模块.gradle

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.0"

    defaultConfig {
        ...
        minSdkVersion 14
        targetSdkVersion 21
        ...

        // Enabling multidex support.
        multiDexEnabled true
    }
    ...
}

dependencies {
  compile 'com.android.support:multidex:1.0.0'
}android {
    compileSdkVersion 21
    buildToolsVersion "21.1.0"

    defaultConfig {
        ...
        minSdkVersion 14
        targetSdkVersion 21
        ...

        // Enabling multidex support.
        multiDexEnabled true
    }
    ...
}

dependencies {
  compile 'com.android.support:multidex:1.0.0'
}

清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.multidex.myapplication">
    <application
        ...
        android:name="android.support.multidex.MultiDexApplication">
        ...
    </application>
</manifest>

【讨论】:

  • 您是否将您的项目上传到任何网站进行检查,这可能是您的 gradle 错误,这可能有多种原因
  • 对不起,我没听懂你在说什么,你的意思是要检查我的项目吗?
  • 是的,你可以给我发邮件或上传到 github
  • 然后上传它以检查问题的确切位置
猜你喜欢
  • 1970-01-01
  • 2014-10-27
  • 1970-01-01
  • 1970-01-01
  • 2021-02-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多